summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2008-05-27 17:35:20 (GMT)
committerColin Walters <walters@verbum.org>2008-05-27 17:35:20 (GMT)
commitfde77bff42fac9ed95869a69acff4f9daab23e04 (patch)
tree516c4da7a990354cbd7a2ec642fa04ec68f15e95
parentb26f1887f6907d4c9a1dac013649f28950c6b2d3 (diff)
downloaddbus-glib-fde77bff42fac9ed95869a69acff4f9daab23e04.tar.gz
dbus-glib-fde77bff42fac9ed95869a69acff4f9daab23e04.tar.xz
Bug 16079: Return an error on unknown property
https://bugs.freedesktop.org/show_bug.cgi?id=16079 Previously we just asserted, not very useful.
-rw-r--r--dbus/dbus-gobject.c6
-rw-r--r--test/core/test-dbus-glib.c62
2 files changed, 67 insertions, 1 deletions
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index 6596309..3744d84 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -1503,6 +1503,12 @@ gobject_message_function (DBusConnection *connection,
ret = NULL;
}
}
+ else
+ {
+ ret = dbus_message_new_error_printf (message,
+ DBUS_ERROR_INVALID_ARGS,
+ "No such property %s", wincaps_propname);
+ }
}
g_assert (ret != NULL);
diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c
index d8e3336..3117fd3 100644
--- a/test/core/test-dbus-glib.c
+++ b/test/core/test-dbus-glib.c
@@ -313,6 +313,7 @@ main (int argc, char **argv)
DBusGProxy *driver;
DBusGProxy *proxy;
DBusGProxy *proxy2;
+ DBusGProxy *property_proxy;
char **name_list;
guint name_list_len;
guint i;
@@ -1623,7 +1624,66 @@ main (int argc, char **argv)
lose ("Missing interface");
}
g_free (v_STRING_2);
-
+
+ /* Properties tests */
+ property_proxy = dbus_g_proxy_new_from_proxy (proxy, DBUS_INTERFACE_PROPERTIES, NULL);
+
+ g_print ("Calling GetProperty (1)\n");
+ {
+ GValue value = {0,};
+ if (!dbus_g_proxy_call (property_proxy, "Get", &error,
+ G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
+ G_TYPE_STRING, "this_is_a_string",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value, G_TYPE_INVALID))
+ lose_gerror ("Failed to complete GetProperty call", error);
+ g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING));
+ g_assert (!strcmp (g_value_get_string (&value), ""));
+ g_value_unset (&value);
+ }
+
+ g_print ("Calling SetProperty (1)\n");
+ {
+ GValue value = {0,};
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, "testing value");
+ if (!dbus_g_proxy_call (property_proxy, "Set", &error,
+ G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
+ G_TYPE_STRING, "this_is_a_string",
+ G_TYPE_VALUE, &value, G_TYPE_INVALID, G_TYPE_INVALID))
+ lose_gerror ("Failed to complete SetProperty call", error);
+ g_value_unset (&value);
+ }
+
+ g_print ("Calling GetProperty (2)\n");
+ {
+ GValue value = {0,};
+ if (!dbus_g_proxy_call (property_proxy, "Get", &error,
+ G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
+ G_TYPE_STRING, "this_is_a_string",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value, G_TYPE_INVALID))
+ lose_gerror ("Failed to complete GetProperty call", error);
+ g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING));
+ g_assert (!strcmp (g_value_get_string (&value), "testing value"));
+ g_value_unset (&value);
+ }
+
+ g_print ("Calling GetProperty (3)\n");
+ {
+ GValue value = {0,};
+ if (dbus_g_proxy_call (property_proxy, "Get", &error,
+ G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
+ G_TYPE_STRING, "SomeUnknownProperty",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value, G_TYPE_INVALID))
+ lose_gerror ("Unexpected success for GetProperty call of unknown property", error);
+
+ g_clear_error (&error);
+ }
+
+ g_object_unref (property_proxy);
+ property_proxy = NULL;
test_terminate_proxy1 = dbus_g_proxy_new_for_name_owner (connection,
"org.freedesktop.DBus.GLib.TestService",