[gupnp] tests: Add test for #678701
- From: Jussi Kukkonen <jussik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] tests: Add test for #678701
- Date: Mon, 20 Jan 2014 13:54:52 +0000 (UTC)
commit ab2a6ec4f364d90791a76655a05650346a548aac
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date: Sat Jan 18 17:34:14 2014 +0200
tests: Add test for #678701
Test that proxies created by ResourceFactory have the GType
set in gupnp_resource_factory_register_resource_proxy_type()
https://bugzilla.gnome.org/show_bug.cgi?id=678701
tests/gtest/data/TestDevice.xml | 7 +++
tests/gtest/test-bugs.c | 107 +++++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+), 0 deletions(-)
---
diff --git a/tests/gtest/data/TestDevice.xml b/tests/gtest/data/TestDevice.xml
index 87f3d87..d210ee2 100644
--- a/tests/gtest/data/TestDevice.xml
+++ b/tests/gtest/data/TestDevice.xml
@@ -17,5 +17,12 @@
<eventSubURL>/TestService/Event</eventSubURL>
</service>
</serviceList>
+<deviceList>
+<device>
+<deviceType>urn:test-gupnp-org:device:TestSubDevice:1</deviceType>
+<friendlyName>Regression Test subdevice</friendlyName>
+<UDN>uuid:5678</UDN>
+</device>
+</deviceList>
</device>
</root>
diff --git a/tests/gtest/test-bugs.c b/tests/gtest/test-bugs.c
index 5f5cdfd..9b36a61 100644
--- a/tests/gtest/test-bugs.c
+++ b/tests/gtest/test-bugs.c
@@ -44,11 +44,44 @@ struct _GUPnPServiceAction {
guint argument_count;
};
+
+typedef struct _TestBgo678701Service {
+ GUPnPServiceProxy parent_instance;
+}TestBgo678701Service;
+
+typedef struct _TestBgo678701ServiceClass
+{
+ GUPnPServiceProxyClass parent_class;
+}TestBgo678701ServiceClass;
+
+G_DEFINE_TYPE(TestBgo678701Service, test_bgo_678701_service, GUPNP_TYPE_SERVICE_PROXY);
+static void test_bgo_678701_service_class_init (TestBgo678701ServiceClass *klass) {}
+static void test_bgo_678701_service_init (TestBgo678701Service *self) {}
+
+typedef struct _TestBgo678701Device {
+ GUPnPDeviceProxy parent_instance;
+}TestBgo678701Device;
+
+typedef struct _TestBgo678701DeviceClass
+{
+ GUPnPDeviceProxyClass parent_class;
+}TestBgo678701DeviceClass;
+
+G_DEFINE_TYPE(TestBgo678701Device, test_bgo_678701_device, GUPNP_TYPE_DEVICE_PROXY);
+static void test_bgo_678701_device_class_init (TestBgo678701DeviceClass *klass) {}
+static void test_bgo_678701_device_init (TestBgo678701Device *self) {}
+
+
typedef struct _TestBgo696762Data {
GMainLoop *loop;
GUPnPServiceProxy *proxy;
} TestBgo696762Data;
+typedef struct _TestBgo678701Data {
+ GMainLoop *loop;
+ GUPnPDeviceProxy *proxy;
+} TestBgo678701Data;
+
static void
test_bgo_696762_on_browse_call (G_GNUC_UNUSED GUPnPService *service,
G_GNUC_UNUSED GUPnPServiceAction *action,
@@ -103,6 +136,18 @@ test_bgo_696762_on_sp_available (G_GNUC_UNUSED GUPnPControlPoint *cp,
g_main_loop_quit (data->loop);
}
+static void
+test_bgo_678701_on_dp_available (G_GNUC_UNUSED GUPnPControlPoint *cp,
+ GUPnPDeviceProxy *proxy,
+ gpointer user_data)
+{
+ TestBgo678701Data *data = (TestBgo678701Data *) user_data;
+
+ data->proxy = g_object_ref (proxy);
+
+ g_main_loop_quit (data->loop);
+}
+
static gboolean
test_on_timeout (G_GNUC_UNUSED gpointer user_data)
{
@@ -177,6 +222,67 @@ test_bgo_696762 (void)
g_object_unref (context);
}
+/* Test that proxies created by ResourceFactory are of the GType
+ * set with gupnp_resource_factory_register_resource_proxy_type().
+ * https://bugzilla.gnome.org/show_bug.cgi?id=678701 */
+static void
+test_bgo_678701 (void)
+{
+ GUPnPContext *context = NULL;
+ GError *error = NULL;
+ GUPnPControlPoint *cp = NULL;
+ guint timeout_id = 0;
+ TestBgo678701Data data = { NULL, NULL };
+ GUPnPRootDevice *rd;
+ GUPnPServiceInfo *info = NULL;
+ GUPnPDeviceInfo *dev_info = NULL;
+ GUPnPResourceFactory *factory;
+
+ data.loop = g_main_loop_new (NULL, FALSE);
+
+ context = gupnp_context_new (NULL, "lo", 0, &error);
+ g_assert (context != NULL);
+ g_assert (error == NULL);
+
+ factory = gupnp_resource_factory_get_default ();
+ gupnp_resource_factory_register_resource_proxy_type (factory,
+ "urn:test-gupnp-org:service:TestService:1",
+ test_bgo_678701_service_get_type ());
+ gupnp_resource_factory_register_resource_proxy_type (factory,
+ "urn:test-gupnp-org:device:TestSubDevice:1",
+ test_bgo_678701_device_get_type ());
+
+ rd = gupnp_root_device_new (context, "TestDevice.xml", DATA_PATH);
+ gupnp_root_device_set_available (rd, TRUE);
+
+ cp = gupnp_control_point_new (context,
+ "urn:test-gupnp-org:device:TestDevice:1");
+ gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE);
+ g_signal_connect (G_OBJECT (cp),
+ "device-proxy-available",
+ G_CALLBACK (test_bgo_678701_on_dp_available),
+ &data);
+
+ timeout_id = g_timeout_add_seconds (2, test_on_timeout, &(data.loop));
+ g_main_loop_run (data.loop);
+ g_source_remove (timeout_id);
+ g_assert (data.proxy != NULL);
+
+ info = gupnp_device_info_get_service (GUPNP_DEVICE_INFO (data.proxy),
+ "urn:test-gupnp-org:service:TestService:1");
+ g_assert_cmpstr(G_OBJECT_TYPE_NAME (info), ==, "TestBgo678701Service");
+
+ dev_info = gupnp_device_info_get_device (GUPNP_DEVICE_INFO (data.proxy),
+ "urn:test-gupnp-org:device:TestSubDevice:1");
+ g_assert_cmpstr(G_OBJECT_TYPE_NAME (dev_info), ==, "TestBgo678701Device");
+
+ g_main_loop_unref (data.loop);
+ g_object_unref (data.proxy);
+ g_object_unref (cp);
+ g_object_unref (rd);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[]) {
#if !GLIB_CHECK_VERSION(2,35,0)
@@ -184,6 +290,7 @@ main (int argc, char *argv[]) {
#endif
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/bugs/696762", test_bgo_696762);
+ g_test_add_func ("/bugs/678701", test_bgo_678701);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]