From: Matthias Clasen Date: Mon, 23 Aug 2010 04:36:36 +0000 (-0400) Subject: Improve GDBus introspection test coverage X-Git-Tag: 2.25.15~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f40c0e45a158440edb7f4e4fcc95471c028a2e3;p=platform%2Fupstream%2Fglib.git Improve GDBus introspection test coverage --- diff --git a/gio/tests/gdbus-introspection.c b/gio/tests/gdbus-introspection.c index 3b1cf92..7ee36b1 100644 --- a/gio/tests/gdbus-introspection.c +++ b/gio/tests/gdbus-introspection.c @@ -141,6 +141,85 @@ test_introspection_parser (void) g_object_unref (connection); } +static void +test_generate (void) +{ + GDBusNodeInfo *info; + GDBusNodeInfo *info2; + GDBusInterfaceInfo *iinfo; + GDBusMethodInfo *minfo; + GDBusSignalInfo *sinfo; + GDBusArgInfo *arginfo; + GDBusPropertyInfo *pinfo; + GDBusAnnotationInfo *aninfo; + + const gchar *data = + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; + + GString *string; + GString *string2; + GError *error; + + error = NULL; + info = g_dbus_node_info_new_for_xml (data, &error); + g_assert_no_error (error); + + iinfo = g_dbus_node_info_lookup_interface (info, "com.example.Frob"); + aninfo = iinfo->annotations[0]; + g_assert_cmpstr (aninfo->key, ==, "foo"); + g_assert_cmpstr (aninfo->value, ==, "bar"); + g_assert (iinfo->annotations[1] == NULL); + minfo = g_dbus_interface_info_lookup_method (iinfo, "PairReturn"); + g_assert_cmpstr (g_dbus_annotation_info_lookup (minfo->annotations, "org.freedesktop.DBus.GLib.Async"), ==, ""); + arginfo = minfo->in_args[0]; + g_assert_cmpstr (arginfo->name, ==, "somenumber"); + g_assert_cmpstr (arginfo->signature, ==, "u"); + g_assert (minfo->in_args[1] == NULL); + arginfo = minfo->out_args[0]; + g_assert_cmpstr (arginfo->name, ==, "somestring"); + g_assert_cmpstr (arginfo->signature, ==, "s"); + g_assert (minfo->out_args[1] == NULL); + sinfo = g_dbus_interface_info_lookup_signal (iinfo, "HelloWorld"); + arginfo = minfo->out_args[0]; + g_assert_cmpstr (arginfo->name, ==, "somestring"); + g_assert_cmpstr (arginfo->signature, ==, "s"); + g_assert (minfo->out_args[1] == NULL); + pinfo = g_dbus_interface_info_lookup_property (iinfo, "y"); + g_assert_cmpstr (pinfo->signature, ==, "y"); + g_assert_cmpint (pinfo->flags, ==, G_DBUS_PROPERTY_INFO_FLAGS_READABLE | + G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE); + + string = g_string_new (""); + g_dbus_node_info_generate_xml (info, 2, string); + + info2 = g_dbus_node_info_new_for_xml (string->str, &error); + string2 = g_string_new (""); + g_dbus_node_info_generate_xml (info2, 2, string2); + + g_assert_cmpstr (string->str, ==, string2->str); + g_string_free (string, TRUE); + g_string_free (string2, TRUE); + + g_dbus_node_info_unref (info); + g_dbus_node_info_unref (info2); +} + /* ---------------------------------------------------------------------------------------------------- */ int @@ -160,5 +239,7 @@ main (int argc, g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE); g_test_add_func ("/gdbus/introspection-parser", test_introspection_parser); + g_test_add_func ("/gdbus/introspection-generate", test_generate); + return g_test_run(); } diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c index 7c3eecd..5aa9754 100644 --- a/gio/tests/gdbus-peer.c +++ b/gio/tests/gdbus-peer.c @@ -99,12 +99,16 @@ test_interface_method_call (GDBusConnection *connection, gpointer user_data) { PeerData *data = user_data; + const GDBusMethodInfo *info; data->num_method_calls++; g_assert_cmpstr (object_path, ==, "/org/gtk/GDBus/PeerTestObject"); g_assert_cmpstr (interface_name, ==, "org.gtk.GDBus.PeerTestInterface"); + info = g_dbus_method_invocation_get_method_info (invocation); + g_assert_cmpstr (info->name, ==, method_name); + if (g_strcmp0 (method_name, "HelloPeer") == 0) { const gchar *greeting;