summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2021-12-06 18:31:17 +0100
committerJens Georg <mail@jensge.org>2021-12-30 10:11:12 +0100
commit851f2222d4647592e1f1efc653707669d1ca8dba (patch)
treeeeedb30b63073e0e5dae75fd3121900e4e170959 /tests
parent3cc9ff3f21538ddd981288fdf9d3dffe2acc8ef0 (diff)
downloadgupnp-851f2222d4647592e1f1efc653707669d1ca8dba.tar.gz
tests: Add test for ggo#58
https://gitlab.gnome.org/GNOME/gupnp/-/issues/58
Diffstat (limited to 'tests')
-rw-r--r--tests/data/TestService.xml3
-rw-r--r--tests/test-bugs.c138
2 files changed, 141 insertions, 0 deletions
diff --git a/tests/data/TestService.xml b/tests/data/TestService.xml
index 8f02269..21848e1 100644
--- a/tests/data/TestService.xml
+++ b/tests/data/TestService.xml
@@ -43,6 +43,9 @@
</serviceStateTable>
<actionList>
<action>
+ <name>Ping</name>
+ </action>
+ <action>
<name>Browse</name>
<argumentList>
<argument>
diff --git a/tests/test-bugs.c b/tests/test-bugs.c
index 0b41011..8e9b361 100644
--- a/tests/test-bugs.c
+++ b/tests/test-bugs.c
@@ -522,6 +522,143 @@ test_ggo_24 (void)
validate_host_header ("[fe80::01%eth0]", "fe80::acab", 4711));
}
+/*
+ * Test that the legacy async _end_action calls still work
+ *
+ * https://gitlab.gnome.org/GNOME/gupnp/-/issues/58
+ */
+
+static void
+test_ggo_58_on_ping (GUPnPServiceProxy *proxy,
+ GUPnPServiceProxyAction *action,
+ gpointer user_data)
+{
+ TestServiceProxyData *data = (TestServiceProxyData *) user_data;
+
+ g_main_loop_quit (data->loop);
+}
+
+static void
+test_ggo_58_on_ping_call (GUPnPService *service,
+ GUPnPServiceAction *action,
+ gpointer user_data)
+{
+ gupnp_service_action_return (action);
+}
+
+static void
+test_ggo_58 ()
+{
+ GUPnPContext *context = NULL;
+ GError *error = NULL;
+ GUPnPControlPoint *cp = NULL;
+ GUPnPRootDevice *rd;
+ TestServiceProxyData data = { NULL, NULL };
+ GUPnPServiceInfo *info = NULL;
+
+ data.loop = g_main_loop_new (NULL, FALSE);
+
+ context = create_context (0, &error);
+ g_assert_no_error (error);
+ g_assert (context != NULL);
+
+ cp = gupnp_control_point_new (
+ context,
+ "urn:test-gupnp-org:service:TestService:1");
+
+ gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE);
+
+ g_signal_connect (G_OBJECT (cp),
+ "service-proxy-available",
+ G_CALLBACK (test_on_sp_available),
+ &data);
+
+
+ rd = gupnp_root_device_new (context,
+ "TestDevice.xml",
+ DATA_PATH,
+ &error);
+ g_assert_no_error (error);
+ g_assert (rd != NULL);
+ gupnp_root_device_set_available (rd, TRUE);
+ info = gupnp_device_info_get_service (
+ GUPNP_DEVICE_INFO (rd),
+ "urn:test-gupnp-org:service:TestService:1");
+ g_signal_connect (G_OBJECT (info),
+ "action-invoked::Ping",
+ G_CALLBACK (test_ggo_58_on_ping_call),
+ &data);
+
+ test_run_loop (data.loop);
+ g_assert (data.proxy != NULL);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ GUPnPServiceProxyAction *action =
+ gupnp_service_proxy_begin_action (data.proxy,
+ "Ping",
+ test_ggo_58_on_ping,
+ &data,
+ NULL);
+
+ test_run_loop (data.loop);
+
+ gboolean success = gupnp_service_proxy_end_action (data.proxy,
+ action,
+ &error,
+ NULL);
+
+ g_assert (success);
+ g_assert_no_error (error);
+
+ action = gupnp_service_proxy_begin_action (data.proxy,
+ "Ping",
+ test_ggo_58_on_ping,
+ &data,
+ NULL);
+
+ test_run_loop (data.loop);
+
+ GHashTable *result_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ success = gupnp_service_proxy_end_action_hash (data.proxy,
+ action,
+ result_hash,
+ &error);
+ g_hash_table_destroy (result_hash);
+
+ g_assert (success);
+ g_assert_no_error (error);
+
+ action = gupnp_service_proxy_begin_action (data.proxy,
+ "Ping",
+ test_ggo_58_on_ping,
+ &data,
+ NULL);
+
+ test_run_loop (data.loop);
+
+ GList *result_list = NULL;
+ success = gupnp_service_proxy_end_action_list (data.proxy,
+ action,
+ NULL,
+ NULL,
+ &result_list,
+ &error);
+
+ g_assert (success);
+ g_assert_no_error (error);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ g_object_unref (info);
+ g_object_unref (data.proxy);
+ g_object_unref (cp);
+ g_object_unref (rd);
+ g_object_unref (context);
+
+ g_main_loop_unref (data.loop);
+}
+
int
main (int argc, char *argv[]) {
g_test_init (&argc, &argv, NULL);
@@ -531,6 +668,7 @@ main (int argc, char *argv[]) {
g_test_add_func ("/bugs/bgo/722696", test_bgo_722696);
g_test_add_func ("/bugs/bgo/743233", test_bgo_743233);
g_test_add_func ("/bugs/ggo/24", test_ggo_24);
+ g_test_add_func ("/bugs/ggo/58", test_ggo_58);
return g_test_run ();
}