summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-11-24 23:11:52 -0500
committerRyan Lortie <desrt@desrt.ca>2013-11-25 00:34:44 -0500
commitfa270c41e31f19b366beb03eaf340a38586144f9 (patch)
tree02d7f53d54131e0b04351aaff5d6e43f83038314
parent2b232dbfbd771e5ca4b67ab64ac28264b67336e5 (diff)
downloaddconf-fa270c41e31f19b366beb03eaf340a38586144f9.tar.gz
tests: improve coverage of D-Bus backends
Add a weird test to hit two additional obscure cases
-rw-r--r--dbus-1/dconf-libdbus-1.c8
-rw-r--r--tests/dbus.c43
2 files changed, 51 insertions, 0 deletions
diff --git a/dbus-1/dconf-libdbus-1.c b/dbus-1/dconf-libdbus-1.c
index f04062d..8ea187b 100644
--- a/dbus-1/dconf-libdbus-1.c
+++ b/dbus-1/dconf-libdbus-1.c
@@ -65,6 +65,14 @@ dconf_libdbus_1_new_method_call (const gchar *bus_name,
dbus_message_iter_append_basic (&dbus_iter, DBUS_TYPE_STRING, &str);
}
+ else if (g_variant_is_of_type (child, G_VARIANT_TYPE_UINT32))
+ {
+ guint32 uint;
+
+ uint = g_variant_get_uint32 (child);
+ dbus_message_iter_append_basic (&dbus_iter, DBUS_TYPE_UINT32, &uint);
+ }
+
else
{
DBusMessageIter subiter;
diff --git a/tests/dbus.c b/tests/dbus.c
index f11be97..8d564e6 100644
--- a/tests/dbus.c
+++ b/tests/dbus.c
@@ -295,6 +295,49 @@ test_sync_call_error (void)
g_assert (error != NULL);
g_assert (strstr (error->message, " type "));
g_clear_error (&error);
+
+ /* Test two oddities:
+ *
+ * - first, the dbus-1 backend can't handle return types other than
+ * 's' and 'as', so we do a method call that will get something
+ * else in order that we can check that the failure is treated
+ * properly
+ *
+ * - next, we want to make sure that the filter function for
+ * gdbus-filter doesn't block incoming method calls
+ */
+ reply = dconf_engine_dbus_call_sync_func (G_BUS_TYPE_SESSION,
+ "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "RequestName",
+ g_variant_new_parsed ("('ca.desrt.dconf.testsuite', uint32 0)"),
+ G_VARIANT_TYPE ("(u)"), &error);
+ if (reply != NULL)
+ {
+ guint s;
+
+ /* It worked, so we must be on gdbus... */
+ g_assert_no_error (error);
+
+ g_variant_get (reply, "(u)", &s);
+ g_assert_cmpuint (s, ==, 1);
+ g_variant_unref (reply);
+
+ /* Ping ourselves... */
+ reply = dconf_engine_dbus_call_sync_func (G_BUS_TYPE_SESSION,
+ "ca.desrt.dconf.testsuite", "/", "org.freedesktop.DBus.Peer",
+ "Ping", g_variant_new ("()"), G_VARIANT_TYPE_UNIT, &error);
+ g_assert (reply != NULL);
+ g_assert_no_error (error);
+ g_variant_unref (reply);
+ }
+ else
+ {
+ /* Else, we're on dbus1...
+ *
+ * Check that the error was emitted correctly.
+ */
+ g_assert_cmpstr (error->message, ==, "unable to handle message type '(u)'");
+ g_clear_error (&error);
+ }
}
static void