[gupnp] test-proxy: Test call_finish for SOAP errors
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] test-proxy: Test call_finish for SOAP errors
- Date: Sat, 2 Apr 2022 08:59:56 +0000 (UTC)
commit ef9fe1ae0e9cee75bc7938d6a1c95333513c8f59
Author: Jens Georg <mail jensge org>
Date: Sat Apr 2 10:58:11 2022 +0200
test-proxy: Test call_finish for SOAP errors
tests/test-service-proxy.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
---
diff --git a/tests/test-service-proxy.c b/tests/test-service-proxy.c
index 3388723..267f2c8 100644
--- a/tests/test-service-proxy.c
+++ b/tests/test-service-proxy.c
@@ -552,6 +552,58 @@ test_cancel_sync_call (ProxyTestFixture *tf, gconstpointer user_data)
g_main_loop_run (tf->loop);
}
+void
+on_test_async_call_ping_error (G_GNUC_UNUSED GUPnPService *service,
+ GUPnPServiceAction *action,
+ gpointer user_data)
+{
+ gupnp_service_action_return_error (action,
+ GUPNP_CONTROL_ERROR_OUT_OF_SYNC,
+ "Test error");
+}
+
+void
+on_test_soap_error (GObject *source, GAsyncResult *res, gpointer user_data)
+{
+ GError *error = NULL;
+ g_assert_nonnull (user_data);
+
+ gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (source),
+ res,
+ &error);
+ g_assert_error (error,
+ GUPNP_CONTROL_ERROR,
+ GUPNP_CONTROL_ERROR_OUT_OF_SYNC);
+
+ ProxyTestFixture *tf = (ProxyTestFixture *) user_data;
+ g_main_loop_quit (tf->loop);
+}
+
+void
+test_finish_soap_error (ProxyTestFixture *tf, gconstpointer user_data)
+{
+ g_signal_connect (tf->service,
+ "action-invoked::Ping",
+ G_CALLBACK (on_test_async_call_ping_error),
+ tf);
+
+ GUPnPServiceProxyAction *action =
+ gupnp_service_proxy_action_new ("Ping", NULL);
+
+ gupnp_service_proxy_call_action_async (tf->proxy,
+ action,
+ NULL,
+ on_test_soap_error,
+ tf);
+
+ gupnp_service_proxy_action_unref (action);
+ test_run_loop (tf->loop, g_test_get_path ());
+
+ // Spin the loop for a bit...
+ g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop);
+ g_main_loop_run (tf->loop);
+}
+
int
main (int argc, char *argv[])
{
@@ -599,5 +651,12 @@ main (int argc, char *argv[])
test_cancel_sync_call,
test_fixture_teardown);
+ g_test_add ("/service-proxy/async/soap-error-in-finish",
+ ProxyTestFixture,
+ "127.0.0.1",
+ test_fixture_setup,
+ test_finish_soap_error,
+ test_fixture_teardown);
+
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]