[glib: 2/3] tests: Add a test for peer-to-peer GDBusProxy usage with a bus name
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] tests: Add a test for peer-to-peer GDBusProxy usage with a bus name
- Date: Wed, 21 Aug 2019 17:25:47 +0000 (UTC)
commit 87a71fe4d3c2ff4d008cc855c188914203680dd1
Author: Philip Withnall <withnall endlessm com>
Date: Wed Aug 21 19:48:18 2019 +0300
tests: Add a test for peer-to-peer GDBusProxy usage with a bus name
This is a regression test for the fix in !554.
Signed-off-by: Philip Withnall <withnall endlessm com>
Fixes: #1620
gio/tests/gdbus-peer.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
---
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index c46340386..a3260a6e0 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -1053,6 +1053,76 @@ test_peer (void)
/* ---------------------------------------------------------------------------------------------------- */
+static void
+test_peer_signals (void)
+{
+ GDBusConnection *c;
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ PeerData data;
+ GThread *service_thread;
+
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1620");
+
+ setup_test_address ();
+ memset (&data, '\0', sizeof (PeerData));
+ data.current_connections = g_ptr_array_new_with_free_func (g_object_unref);
+
+ /* bring up a server - we run the server in a different thread to avoid deadlocks */
+ service_thread = g_thread_new ("test_peer",
+ service_thread_func,
+ &data);
+ await_service_loop ();
+ g_assert_nonnull (server);
+
+ /* bring up a connection and accept it */
+ data.accept_connection = TRUE;
+ c = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server),
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+ NULL, /* GDBusAuthObserver */
+ NULL, /* cancellable */
+ &error);
+ g_assert_no_error (error);
+ g_assert_nonnull (c);
+ while (data.current_connections->len < 1)
+ g_main_loop_run (loop);
+ g_assert_cmpint (data.current_connections->len, ==, 1);
+ g_assert_cmpint (data.num_connection_attempts, ==, 1);
+ g_assert_null (g_dbus_connection_get_unique_name (c));
+ g_assert_cmpstr (g_dbus_connection_get_guid (c), ==, test_guid);
+
+ /* Check that we can create a proxy with a non-NULL bus name, even though it's
+ * irrelevant in the non-message-bus case. Since the server runs in another
+ * thread it's fine to use synchronous blocking API here.
+ */
+ proxy = g_dbus_proxy_new_sync (c,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+ NULL,
+ ":1.1", /* bus_name */
+ "/org/gtk/GDBus/PeerTestObject",
+ "org.gtk.GDBus.PeerTestInterface",
+ NULL, /* GCancellable */
+ &error);
+ g_assert_no_error (error);
+ g_assert_nonnull (proxy);
+
+ /* unref the server and stop listening for new connections */
+ g_dbus_server_stop (server);
+ g_clear_object (&server);
+
+ g_object_unref (c);
+ g_ptr_array_unref (data.current_connections);
+ g_object_unref (proxy);
+
+ g_main_loop_quit (service_loop);
+ g_thread_join (service_thread);
+
+ teardown_test_address ();
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
typedef struct
{
GDBusServer *server;
@@ -1828,6 +1898,7 @@ main (int argc,
loop = g_main_loop_new (NULL, FALSE);
g_test_add_func ("/gdbus/peer-to-peer", test_peer);
+ g_test_add_func ("/gdbus/peer-to-peer/signals", test_peer_signals);
g_test_add_func ("/gdbus/delayed-message-processing", delayed_message_processing);
g_test_add_func ("/gdbus/nonce-tcp", test_nonce_tcp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]