summaryrefslogtreecommitdiff
path: root/gio/tests
diff options
context:
space:
mode:
authorHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 11:01:36 +0900
committerHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 11:01:36 +0900
commit3751706729c090c34d59c5284c3f80063a337afc (patch)
tree2f9ba678f1139115c131d13624707052457aae50 /gio/tests
parent85ef543166f81464323d083c9a21096cc634cad0 (diff)
downloadglib-3751706729c090c34d59c5284c3f80063a337afc.tar.gz
glib-3751706729c090c34d59c5284c3f80063a337afc.tar.bz2
glib-3751706729c090c34d59c5284c3f80063a337afc.zip
Imported Upstream version 2.61.3
Diffstat (limited to 'gio/tests')
-rw-r--r--gio/tests/gdbus-connection.c6
-rw-r--r--gio/tests/gdbus-peer.c71
-rw-r--r--gio/tests/gsettings.c18
-rw-r--r--gio/tests/meson.build6
-rw-r--r--gio/tests/task.c1
5 files changed, 96 insertions, 6 deletions
diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c
index 35593be9f..6e4c7eb05 100644
--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -1197,6 +1197,7 @@ test_connection_basic (void)
GDBusConnection *connection;
GError *error;
GDBusCapabilityFlags flags;
+ GDBusConnectionFlags connection_flags;
gchar *guid;
gchar *name;
gboolean closed;
@@ -1215,6 +1216,11 @@ test_connection_basic (void)
g_assert (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
+ connection_flags = g_dbus_connection_get_flags (connection);
+ g_assert_cmpint (connection_flags, ==,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+ G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION);
+
credentials = g_dbus_connection_get_peer_credentials (connection);
g_assert (credentials == NULL);
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);
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 77905ec7a..baadca8f5 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -509,6 +509,24 @@ test_delay_apply (void)
g_assert_true (changed_cb_called);
g_assert_false (changed_cb_called2);
+ /* Try resetting the key and ensure a notification is emitted on the delayed #GSettings object. */
+ changed_cb_called = FALSE;
+ changed_cb_called2 = FALSE;
+
+ g_settings_reset (settings, "greeting");
+
+ g_assert_true (changed_cb_called);
+ g_assert_false (changed_cb_called2);
+
+ /* Locally change the greeting again. */
+ changed_cb_called = FALSE;
+ changed_cb_called2 = FALSE;
+
+ g_settings_set (settings, "greeting", "s", "greetings from test_delay_apply");
+
+ g_assert_true (changed_cb_called);
+ g_assert_false (changed_cb_called2);
+
writable = g_settings_is_writable (settings, "greeting");
g_assert_true (writable);
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 3a6b50bb5..b5593a4ec 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -140,17 +140,13 @@ if host_machine.system() != 'windows'
}
if have_rtld_next
- # FIXME: This list will probably grow; see
- # https://gitlab.gnome.org/GNOME/glib/issues/1739
- no_libdl_systems = ['freebsd', 'netbsd', 'openbsd']
-
gio_tests += {
'gsocketclient-slow' : {
'depends' : [
shared_library('slow-connect-preload',
'slow-connect-preload.c',
name_prefix : '',
- dependencies: cc.find_library('dl', required: not no_libdl_systems.contains(host_machine.system())),
+ dependencies: libdl_dep,
install_dir : installed_tests_execdir,
install: installed_tests_enabled,
)
diff --git a/gio/tests/task.c b/gio/tests/task.c
index 9b2c6912c..0caed4403 100644
--- a/gio/tests/task.c
+++ b/gio/tests/task.c
@@ -2321,7 +2321,6 @@ main (int argc, char **argv)
int ret;
g_test_init (&argc, &argv, NULL);
- g_test_bug_base ("");
loop = g_main_loop_new (NULL, FALSE);
main_thread = g_thread_self ();