On Mon, 2010-06-21 at 13:32 +0200, Javier Fernandez Garcia-Boente wrote:
> On Thu, 2010-06-17 at 11:25 +0200, Javier Fernandez Garcia-Boente wrote:
>> Anyway, getting back to the WebKit Geolocation unit tests topic, i think
> we should provide a way of forcing one provider as the selected one,
> even though if several are available. When programming unit tests, not
> every functionality have to be enabled; even more, some of them could be
> dangerous or inefficient for the automatic testing framework. The usual
> way of programming unit tests by setting a dummy GPS coordinates before
> executing the test and retrieving such dummy coordinates as the result
> of the operation, so the Manual provider seems to be the more
> appropriated for this way of use the Geolocation API.
>> Do you think this is the right way to proceed ? Implementing a way of
> selecting a fixed provider.
>
New version of the patch attached. Besides that, after further
investigations in the WebKit part, it seems that the position-changed
notifications were not being received correctly in the WebKit unit
tests. I initially implemented the mockup calls this way:
GeocluePosition *pos = NULL;
const char *service = "org.freedesktop.Geoclue.Providers.Manual";
const char *path = "/org/freedesktop/Geoclue/Providers/Manual";
const char *iface = "org.freedesktop.Geoclue.Manual";
pos = geoclue_position_iface_new (service, path, iface);
geoclue_position_set_position (pos,accuracy,longitude,latitude,0,NULL);
g_object_unref (pos);
That way, the GeoclueManual provider stores the dummy position, but
there is no client connected to the postition-changed signal; since the
GeoclueManual has the ProvidesUpdate flag (already set because of the
Address iface), the master provider started afterwards, during the
actual unit test call, does not retrieve the correct info, but the
initial cached values. So, after figure out how to proceed I decided to
use the MasterClient instance to build the Position provider, so that
the client could be connected to the position-changed signal.
However, in the implementation of the SetPosition method i considered
better not to expose this method in the PositionIface, mainly because i
see such method as a way of performing unit tests. The problem if this
approach is that since the PositionIface does not implement itself the
SetPosition method the GeolcuePosition object created by the
MasterClient can be used to set the dummy position. The solution i chose
was to define a new API method in the MasterClient class, called
create_iface-osition, which internally calls to the
geoclue_position_iface_new for accessing directly to the selected
position provider. See bellow:
GError *error = NULL;
GeoclueMaster* master = geoclue_master_get_default();
GeoclueMasterClient* client = geoclue_master_create_client(master,0,0);
if (geoclue_master_client_set_requirements(client,
GEOCLUE_ACCURACY_LEVEL_LOCALITY,
0, false, GEOCLUE_RESOURCE_ALL,
&error)) {
pos = geoclue_master_client_create_iface_position (client,
service, path, iface, &error);
geoclue_position_set_position (pos, accuracy, longitude,
latitude, 0, &error);
g_object_unref (pos);
}
/* FIXME: it can be unreferenced because it will receive the DBus
signal asynchronously, some time after unreferencing the
client instance. */
// g_object_unref(client);
g_object_unref(master);
Sorry for this long email, but at the end, i think I've got a solution
to at least enabling the success.html unit test in the WebKitGtk port.
Thanks you all, and greetings.
--
Javier Fernández García-Boente
http://blogs.igalia.com/jfernandez/
www.igalia.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-The-Manual-provider-implements-the-Position-interfac.patch
Type: text/x-patch
Size: 10533 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/geoclue/attachments/20100624/1d1162dc/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-The-GeoclueManual-emits-the-postition-changed-signal.patch
Type: text/x-patch
Size: 5784 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/geoclue/attachments/20100624/1d1162dc/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-The-GeoclueMasterClient-object-has-a-new-GeocluePosi.patch
Type: text/x-patch
Size: 2371 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/geoclue/attachments/20100624/1d1162dc/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/geoclue/attachments/20100624/1d1162dc/attachment-0001.pgp>