1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 #include <dbus/dbus-glib.h>
6 #include "test-service-glib-bindings.h"
7 #include <glib/dbus-gidl.h>
8 #include <glib/dbus-gparser.h>
10 #include <glib-object.h>
11 #include "my-object-marshal.h"
13 static GMainLoop *loop = NULL;
14 static const char *await_terminating_service = NULL;
15 static int n_times_foo_received = 0;
16 static int n_times_frobnicate_received = 0;
17 static int n_times_frobnicate_received_2 = 0;
18 static int n_times_sig0_received = 0;
19 static int n_times_sig1_received = 0;
20 static int n_times_sig2_received = 0;
21 static guint exit_timeout = 0;
22 static gboolean proxy_destroyed = FALSE;
23 static gboolean proxy_destroy_and_nameowner = FALSE;
24 static gboolean proxy_destroy_and_nameowner_complete = FALSE;
26 static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
27 static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
30 unset_and_free_gvalue (gpointer val)
37 timed_exit (gpointer loop)
39 g_print ("timed exit!\n");
40 g_main_loop_quit (loop);
45 proxy_destroyed_cb (DBusGProxy *proxy, gpointer user_data)
47 proxy_destroyed = TRUE;
48 if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL)
50 g_source_remove (exit_timeout);
51 g_main_loop_quit (loop);
52 proxy_destroy_and_nameowner_complete = TRUE;
57 name_owner_changed (DBusGProxy *proxy,
59 const char *prev_owner,
60 const char *new_owner,
63 g_print ("(signal NameOwnerChanged) name owner changed for %s from %s to %s\n",
64 name, prev_owner, new_owner);
65 if (await_terminating_service &&
66 !strcmp (name, await_terminating_service)
67 && !strcmp ("", new_owner))
69 g_print ("Caught expected ownership loss for %s\n", name);
70 await_terminating_service = NULL;
71 if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && proxy_destroyed)
73 g_source_remove (exit_timeout);
74 g_main_loop_quit (loop);
75 proxy_destroy_and_nameowner_complete = TRUE;
77 else if (!proxy_destroy_and_nameowner)
79 g_source_remove (exit_timeout);
80 g_main_loop_quit (loop);
86 foo_signal_handler (DBusGProxy *proxy,
90 n_times_foo_received += 1;
92 g_print ("Got Foo signal\n");
94 g_main_loop_quit (loop);
95 g_source_remove (exit_timeout);
99 frobnicate_signal_handler (DBusGProxy *proxy,
103 n_times_frobnicate_received += 1;
105 g_assert (val == 42);
106 g_print ("Got Frobnicate signal\n");
108 g_main_loop_quit (loop);
109 g_source_remove (exit_timeout);
113 frobnicate_signal_handler_2 (DBusGProxy *proxy,
117 n_times_frobnicate_received_2 += 1;
119 g_assert (val == 42);
120 g_print ("Got Frobnicate signal (again)\n");
124 sig0_signal_handler (DBusGProxy *proxy,
130 n_times_sig0_received += 1;
132 g_assert (!strcmp (str0, "foo"));
134 g_assert (val == 22);
136 g_assert (!strcmp (str1, "moo"));
138 g_print ("Got Sig0 signal\n");
140 g_main_loop_quit (loop);
141 g_source_remove (exit_timeout);
145 sig1_signal_handler (DBusGProxy *proxy,
150 n_times_sig1_received += 1;
152 g_assert (!strcmp (str0, "baz"));
154 g_assert (G_VALUE_HOLDS_STRING (value));
156 g_assert (!strcmp (g_value_get_string (value), "bar"));
158 g_print ("Got Sig1 signal\n");
160 g_main_loop_quit (loop);
161 g_source_remove (exit_timeout);
165 sig2_signal_handler (DBusGProxy *proxy,
169 n_times_sig2_received += 1;
171 g_assert (g_hash_table_size (table) == 2);
173 g_assert (g_hash_table_lookup (table, "baz") != NULL);
174 g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow"));
175 g_assert (g_hash_table_lookup (table, "bar") != NULL);
176 g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo"));
178 g_print ("Got Sig2 signal\n");
180 g_main_loop_quit (loop);
181 g_source_remove (exit_timeout);
184 static DBusGProxyCall *echo_call;
185 static guint n_times_echo_cb_entered;
187 echo_received_cb (DBusGProxy *proxy,
188 DBusGProxyCall *call,
194 g_assert (call == echo_call);
195 g_assert (data == NULL);
199 n_times_echo_cb_entered++;
201 if (!dbus_g_proxy_end_call (proxy, call, &error,
205 lose_gerror ("Failed to complete async Echo", error);
206 g_assert (echo_data != NULL);
207 g_print ("Async echo gave \"%s\"\n", echo_data);
209 g_main_loop_quit (loop);
210 g_source_remove (exit_timeout);
214 increment_received_cb (DBusGProxy *proxy,
215 DBusGProxyCall *call,
222 g_assert (!strcmp (data, "moo"));
226 if (!dbus_g_proxy_end_call (proxy, call, &error,
229 lose_gerror ("Failed to complete (async) Increment call", error);
232 lose ("Increment call returned %d, should be 43", val);
234 g_print ("Async increment gave \"%d\"\n", val);
235 g_main_loop_quit (loop);
236 g_source_remove (exit_timeout);
240 increment_async_cb (DBusGProxy *proxy, guint val, GError *error, gpointer data)
243 lose_gerror ("Failed to complete (wrapped async) Increment call", error);
246 lose ("(wrapped async) Increment call gave unexpected data");
248 lose ("(wrapped async) Increment call returned %d, should be 43", val);
250 g_print ("(wrapped async) increment gave \"%d\"\n", val);
251 g_main_loop_quit (loop);
252 g_source_remove (exit_timeout);
257 lose (const char *str, ...)
261 va_start (args, str);
263 vfprintf (stderr, str, args);
264 fputc ('\n', stderr);
272 lose_gerror (const char *prefix, GError *error)
274 if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
275 lose ("%s (%s): %s", prefix, dbus_g_error_get_name (error),
278 lose ("%s: %s", prefix, error->message);
286 ctx = g_main_loop_get_context (loop);
288 while (g_main_context_pending (ctx))
289 g_main_context_iteration (ctx, FALSE);
293 main (int argc, char **argv)
295 DBusGConnection *connection;
303 DBusGProxyCall *call;
311 g_log_set_always_fatal (G_LOG_LEVEL_WARNING);
313 loop = g_main_loop_new (NULL, FALSE);
316 connection = dbus_g_bus_get (DBUS_BUS_SESSION,
318 if (connection == NULL)
319 lose_gerror ("Failed to open connection to bus", error);
321 /* should always get the same one */
322 g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
323 g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
324 g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
326 /* Create a proxy object for the "bus driver" */
328 driver = dbus_g_proxy_new_for_name (connection,
331 DBUS_INTERFACE_DBUS);
333 dbus_g_proxy_add_signal (driver,
340 dbus_g_proxy_connect_signal (driver,
342 G_CALLBACK (name_owner_changed),
345 /* Call ListNames method */
348 if (!dbus_g_proxy_call (driver, "ListNames", &error,
350 G_TYPE_STRV, &name_list,
352 lose_gerror ("Failed to complete ListNames call", error);
354 g_print ("Names on the message bus:\n");
356 name_list_len = g_strv_length (name_list);
357 while (i < name_list_len)
359 g_assert (name_list[i] != NULL);
360 g_print (" %s\n", name_list[i]);
363 g_assert (name_list[i] == NULL);
365 g_strfreev (name_list);
367 g_print ("calling ThisMethodDoesNotExist\n");
368 /* Test handling of unknown method */
369 if (dbus_g_proxy_call (driver, "ThisMethodDoesNotExist", &error,
371 "blah blah blah blah blah",
374 G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
375 lose ("Calling nonexistent method succeeded!");
377 g_print ("Got EXPECTED error from calling unknown method: %s\n", error->message);
378 g_clear_error (&error);
382 /* Activate a service */
383 g_print ("Activating echo service\n");
384 if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
386 "org.freedesktop.DBus.TestSuiteEchoService",
389 G_TYPE_UINT, &result,
391 lose_gerror ("Failed to complete Activate call", error);
393 g_print ("Starting echo service result = 0x%x\n", result);
395 /* Activate a service again */
396 g_print ("Activating echo service again\n");
397 if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
399 "org.freedesktop.DBus.TestSuiteEchoService",
403 G_TYPE_UINT, &result,
405 lose_gerror ("Failed to complete Activate call", error);
407 g_print ("Duplicate start of echo service = 0x%x\n", result);
409 /* Talk to the new service */
411 g_print ("Creating proxy for echo service\n");
412 proxy = dbus_g_proxy_new_for_name_owner (connection,
413 "org.freedesktop.DBus.TestSuiteEchoService",
414 "/org/freedesktop/TestSuite",
415 "org.freedesktop.TestSuite",
419 lose_gerror ("Failed to create proxy for name owner", error);
423 g_print ("Calling Echo\n");
424 if (!dbus_g_proxy_call (proxy, "Echo", &error,
425 G_TYPE_STRING, "my string hello",
427 G_TYPE_STRING, &v_STRING_2,
429 lose_gerror ("Failed to complete Echo call", error);
431 g_print ("String echoed = \"%s\"\n", v_STRING_2);
434 g_print ("Calling Echo (async)\n");
435 echo_call = dbus_g_proxy_begin_call (proxy, "Echo",
436 echo_received_cb, NULL, NULL,
437 G_TYPE_STRING, "my string hello",
439 dbus_g_connection_flush (connection);
440 exit_timeout = g_timeout_add (5000, timed_exit, loop);
441 g_main_loop_run (loop);
443 /* Test oneway call and signal handling */
445 g_print ("Testing Foo emission\n");
446 dbus_g_proxy_add_signal (proxy, "Foo", G_TYPE_DOUBLE, G_TYPE_INVALID);
448 dbus_g_proxy_connect_signal (proxy, "Foo",
449 G_CALLBACK (foo_signal_handler),
452 dbus_g_proxy_call_no_reply (proxy, "EmitFoo",
455 dbus_g_connection_flush (connection);
456 exit_timeout = g_timeout_add (5000, timed_exit, loop);
457 g_main_loop_run (loop);
459 if (n_times_foo_received != 1)
460 lose ("Foo signal received %d times, should have been 1", n_times_foo_received);
462 /* Activate test servie */
463 g_print ("Activating TestSuiteGLibService\n");
465 if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
467 "org.freedesktop.DBus.TestSuiteGLibService",
471 G_TYPE_UINT, &result,
473 lose_gerror ("Failed to complete Activate call", error);
476 g_print ("TestSuiteGLibService activated\n");
478 if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION"))
479 g_usleep (8 * G_USEC_PER_SEC);
481 g_object_unref (G_OBJECT (proxy));
485 proxy = dbus_g_proxy_new_for_name_owner (connection,
486 "org.freedesktop.DBus.TestSuiteGLibService",
487 "/org/freedesktop/DBus/Tests/MyTestObject",
488 "org.freedesktop.DBus.Tests.MyObject",
492 lose_gerror ("Failed to create proxy for name owner", error);
494 g_print ("Calling DoNothing\n");
495 if (!dbus_g_proxy_call (proxy, "DoNothing", &error,
496 G_TYPE_INVALID, G_TYPE_INVALID))
497 lose_gerror ("Failed to complete DoNothing call", error);
499 g_print ("Calling Increment\n");
501 if (!dbus_g_proxy_call (proxy, "Increment", &error,
504 G_TYPE_UINT, &v_UINT32_2,
506 lose_gerror ("Failed to complete Increment call", error);
507 if (v_UINT32_2 != 43)
508 lose ("Increment call returned %d, should be 43", v_UINT32_2);
511 g_print ("Calling Increment (async)\n");
512 call = dbus_g_proxy_begin_call (proxy, "Increment",
513 increment_received_cb, g_strdup ("moo"), g_free,
516 dbus_g_connection_flush (connection);
517 exit_timeout = g_timeout_add (5000, timed_exit, loop);
518 g_main_loop_run (loop);
520 g_print ("Calling IncrementRetval\n");
523 if (!dbus_g_proxy_call (proxy, "IncrementRetval", &error,
526 G_TYPE_UINT, &v_UINT32_2,
528 lose_gerror ("Failed to complete Increment call", error);
529 if (v_UINT32_2 != 43)
530 lose ("IncrementRetval call returned %d, should be 43", v_UINT32_2);
532 g_print ("Calling IncrementRetvalError\n");
535 if (!dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
538 G_TYPE_UINT, &v_UINT32_2,
540 lose_gerror ("Failed to complete Increment call", error);
542 lose ("IncrementRetval call returned %d, should be 6", v_UINT32_2);
544 g_print ("Calling ThrowError\n");
545 if (dbus_g_proxy_call (proxy, "ThrowError", &error,
546 G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
547 lose ("ThrowError call unexpectedly succeeded!");
549 if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.Tests.MyObject.Foo"))
550 lose ("ThrowError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error),
553 g_print ("ThrowError failed (as expected) returned error: %s\n", error->message);
554 g_clear_error (&error);
556 g_print ("Calling IncrementRetvalError (for error)\n");
559 if (dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
562 G_TYPE_UINT, &v_UINT32_2,
563 G_TYPE_INVALID) != FALSE)
564 lose ("IncrementRetvalError call unexpectedly succeeded!");
565 if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.Tests.MyObject.Foo"))
566 lose ("IncrementRetvalError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error), error->message);
567 g_clear_error (&error);
570 g_print ("Calling Uppercase\n");
571 if (!dbus_g_proxy_call (proxy, "Uppercase", &error,
572 G_TYPE_STRING, "foobar",
574 G_TYPE_STRING, &v_STRING_2,
576 lose_gerror ("Failed to complete Uppercase call", error);
577 if (strcmp ("FOOBAR", v_STRING_2) != 0)
578 lose ("Uppercase call returned unexpected string %s", v_STRING_2);
583 g_print ("Calling ManyArgs\n");
584 if (!dbus_g_proxy_call (proxy, "ManyArgs", &error,
586 G_TYPE_STRING, "bazwhee",
589 G_TYPE_DOUBLE, &v_DOUBLE_2,
590 G_TYPE_STRING, &v_STRING_2,
592 lose_gerror ("Failed to complete ManyArgs call", error);
593 if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56)
594 lose ("ManyArgs call returned unexpected double value %f", v_DOUBLE_2);
595 if (strcmp ("BAZWHEE", v_STRING_2) != 0)
596 lose ("ManyArgs call returned unexpected string %s", v_STRING_2);
599 g_print ("Calling (wrapped) do_nothing\n");
600 if (!org_freedesktop_DBus_Tests_MyObject_do_nothing (proxy, &error))
601 lose_gerror ("Failed to complete (wrapped) DoNothing call", error);
603 g_print ("Calling (wrapped) increment\n");
604 if (!org_freedesktop_DBus_Tests_MyObject_increment (proxy, 42, &v_UINT32_2, &error))
605 lose_gerror ("Failed to complete (wrapped) Increment call", error);
607 if (v_UINT32_2 != 43)
608 lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2);
610 g_print ("Calling (wrapped async) increment\n");
611 if (!org_freedesktop_DBus_Tests_MyObject_increment_async (proxy, 42, increment_async_cb, NULL))
612 lose_gerror ("Failed to complete (wrapped) Increment call", error);
613 dbus_g_connection_flush (connection);
614 exit_timeout = g_timeout_add (5000, timed_exit, loop);
615 g_main_loop_run (loop);
618 if (!org_freedesktop_DBus_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error))
619 lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error);
621 if (v_UINT32_2 != 43)
622 lose ("(wrapped) async increment call returned %d, should be 43", v_UINT32_2);
624 g_print ("Calling (wrapped) throw_error\n");
625 if (org_freedesktop_DBus_Tests_MyObject_throw_error (proxy, &error) != FALSE)
626 lose ("(wrapped) ThrowError call unexpectedly succeeded!");
628 g_print ("(wrapped) ThrowError failed (as expected) returned error: %s\n", error->message);
629 g_clear_error (&error);
631 if (org_freedesktop_DBus_Tests_MyObject_async_throw_error (proxy, &error) != FALSE)
632 lose ("(wrapped) AsyncThrowError call unexpectedly succeeded!");
634 g_print ("(wrapped) AsyncThrowError failed (as expected) returned error: %s\n", error->message);
635 g_clear_error (&error);
637 g_print ("Calling (wrapped) uppercase\n");
638 if (!org_freedesktop_DBus_Tests_MyObject_uppercase (proxy, "foobar", &v_STRING_2, &error))
639 lose_gerror ("Failed to complete (wrapped) Uppercase call", error);
640 if (strcmp ("FOOBAR", v_STRING_2) != 0)
641 lose ("(wrapped) Uppercase call returned unexpected string %s", v_STRING_2);
644 g_print ("Calling (wrapped) many_args\n");
645 if (!org_freedesktop_DBus_Tests_MyObject_many_args (proxy, 26, "bazwhee", G_PI,
646 &v_DOUBLE_2, &v_STRING_2, &error))
647 lose_gerror ("Failed to complete (wrapped) ManyArgs call", error);
649 if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56)
651 lose ("(wrapped) ManyArgs call returned unexpected double value %f", v_DOUBLE_2);
653 if (strcmp ("BAZWHEE", v_STRING_2) != 0)
654 lose ("(wrapped) ManyArgs call returned unexpected string %s", v_STRING_2);
665 g_print ("Calling (wrapped) many_return\n");
666 if (!org_freedesktop_DBus_Tests_MyObject_many_return (proxy, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &error))
667 lose_gerror ("Failed to complete (wrapped) ManyReturn call", error);
670 lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg0);
672 if (strcmp ("42", arg1) != 0)
673 lose ("(wrapped) ManyReturn call returned unexpected string %s", arg1);
677 lose ("(wrapped) ManyReturn call returned unexpected gint32 value %u", arg2);
680 lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg3);
683 lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg4);
685 if (strcmp ("hello world", arg5))
686 lose ("(wrapped) ManyReturn call returned unexpected string %s", arg5);
693 GValue value = {0, };
695 g_value_init (&value, G_TYPE_STRING);
696 g_value_set_string (&value, "foo");
698 g_print ("Calling (wrapped) stringify, with string\n");
699 if (!org_freedesktop_DBus_Tests_MyObject_stringify (proxy,
703 lose_gerror ("Failed to complete (wrapped) stringify call", error);
704 if (strcmp ("foo", v_STRING_2) != 0)
705 lose ("(wrapped) stringify call returned unexpected string %s", v_STRING_2);
708 g_value_unset (&value);
709 g_value_init (&value, G_TYPE_INT);
710 g_value_set_int (&value, 42);
712 g_print ("Calling (wrapped) stringify, with int\n");
713 if (!org_freedesktop_DBus_Tests_MyObject_stringify (proxy,
717 lose_gerror ("Failed to complete (wrapped) stringify call 2", error);
718 if (strcmp ("42", v_STRING_2) != 0)
719 lose ("(wrapped) stringify call 2 returned unexpected string %s", v_STRING_2);
720 g_value_unset (&value);
723 g_value_init (&value, G_TYPE_INT);
724 g_value_set_int (&value, 88);
725 g_print ("Calling (wrapped) stringify, with another int\n");
726 if (!org_freedesktop_DBus_Tests_MyObject_stringify (proxy,
730 lose_gerror ("Failed to complete (wrapped) stringify call 3", error);
731 g_value_unset (&value);
733 g_print ("Calling (wrapped) unstringify, for string\n");
734 if (!org_freedesktop_DBus_Tests_MyObject_unstringify (proxy,
738 lose_gerror ("Failed to complete (wrapped) unstringify call", error);
739 if (!G_VALUE_HOLDS_STRING (&value))
740 lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value));
741 if (strcmp (g_value_get_string (&value), "foo"))
742 lose ("(wrapped) unstringify call returned unexpected string %s",
743 g_value_get_string (&value));
745 g_value_unset (&value);
747 g_print ("Calling (wrapped) unstringify, for int\n");
748 if (!org_freedesktop_DBus_Tests_MyObject_unstringify (proxy,
752 lose_gerror ("Failed to complete (wrapped) unstringify call", error);
753 if (!G_VALUE_HOLDS_INT (&value))
754 lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value));
755 if (g_value_get_int (&value) != 10)
756 lose ("(wrapped) unstringify call returned unexpected integer %d",
757 g_value_get_int (&value));
759 g_value_unset (&value);
769 array = g_array_new (FALSE, TRUE, sizeof (guint32));
771 g_array_append_val (array, val);
773 g_array_append_val (array, val);
775 g_array_append_val (array, val);
777 g_array_append_val (array, val);
779 g_array_append_val (array, val);
782 g_print ("Calling (wrapped) recursive1\n");
783 if (!org_freedesktop_DBus_Tests_MyObject_recursive1 (proxy, array,
785 lose_gerror ("Failed to complete (wrapped) recursive1 call", error);
787 lose ("(wrapped) recursive1 call returned invalid length %u", arraylen);
791 GArray *array = NULL;
794 g_print ("Calling (wrapped) recursive2\n");
795 if (!org_freedesktop_DBus_Tests_MyObject_recursive2 (proxy, 2, &array, &error))
796 lose_gerror ("Failed to complete (wrapped) Recursive2 call", error);
799 lose ("(wrapped) Recursive2 call returned NULL");
801 lose ("(wrapped) Recursive2 call returned unexpected array length %u", array->len);
803 arrayvals = (guint32*) array->data;
804 if (arrayvals[0] != 42)
805 lose ("(wrapped) Recursive2 call returned unexpected value %d in position 0", arrayvals[0]);
806 if (arrayvals[1] != 26)
807 lose ("(wrapped) Recursive2 call returned unexpected value %d in position 1", arrayvals[1]);
808 if (arrayvals[4] != 2)
809 lose ("(wrapped) Recursive2 call returned unexpected value %d in position 4", arrayvals[4]);
811 g_array_free (array, TRUE);
820 strs = g_new0 (char *, 4);
827 g_print ("Calling (wrapped) many_uppercase\n");
828 if (!org_freedesktop_DBus_Tests_MyObject_many_uppercase (proxy, strs, &strs_ret, &error))
829 lose_gerror ("Failed to complete (wrapped) ManyUppercase call", error);
830 g_assert (strs_ret != NULL);
831 if (strcmp ("HELLO", strs_ret[0]) != 0)
832 lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[0]);
833 if (strcmp ("HELLO", strs_ret[1]) != 0)
834 lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[1]);
835 if (strcmp ("HELLO", strs_ret[2]) != 0)
836 lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[2]);
839 g_strfreev (strs_ret);
846 table = g_hash_table_new (g_str_hash, g_str_equal);
847 g_hash_table_insert (table, "moooo", "b");
848 g_hash_table_insert (table, "xxx", "cow!");
851 g_print ("Calling (wrapped) str_hash_len\n");
852 if (!org_freedesktop_DBus_Tests_MyObject_str_hash_len (proxy, table, &len, &error))
853 lose_gerror ("(wrapped) StrHashLen call failed", error);
855 lose ("(wrapped) StrHashLen returned unexpected length %u", len);
856 g_hash_table_destroy (table);
863 g_print ("Calling (wrapped) get_hash\n");
864 if (!org_freedesktop_DBus_Tests_MyObject_get_hash (proxy, &table, &error))
865 lose_gerror ("(wrapped) GetHash call failed", error);
866 val = g_hash_table_lookup (table, "foo");
867 if (val == NULL || strcmp ("bar", val))
868 lose ("(wrapped) StrHashLen returned invalid value %s for key \"foo\"",
869 val ? val : "(null)");
870 val = g_hash_table_lookup (table, "baz");
871 if (val == NULL || strcmp ("whee", val))
872 lose ("(wrapped) StrHashLen returned invalid value %s for key \"whee\"",
873 val ? val : "(null)");
874 val = g_hash_table_lookup (table, "cow");
875 if (val == NULL || strcmp ("crack", val))
876 lose ("(wrapped) StrHashLen returned invalid value %s for key \"cow\"",
877 val ? val : "(null)");
878 if (g_hash_table_size (table) != 3)
879 lose ("(wrapped) StrHashLen returned unexpected hash size %u",
880 g_hash_table_size (table));
882 g_hash_table_destroy (table);
889 GValueArray *vals_ret;
892 vals = g_value_array_new (3);
894 g_value_array_append (vals, NULL);
895 g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_STRING);
896 g_value_set_string (g_value_array_get_nth (vals, 0), "foo");
898 g_value_array_append (vals, NULL);
899 g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_UINT);
900 g_value_set_uint (g_value_array_get_nth (vals, vals->n_values - 1), 42);
902 g_value_array_append (vals, NULL);
903 g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_VALUE);
904 val = g_new0 (GValue, 1);
905 g_value_init (val, G_TYPE_UCHAR);
906 g_value_set_uchar (val, '!');
907 g_value_set_boxed (g_value_array_get_nth (vals, vals->n_values - 1), val);
910 g_print ("Calling SendCar\n");
911 if (!dbus_g_proxy_call (proxy, "SendCar", &error,
912 G_TYPE_VALUE_ARRAY, vals,
914 G_TYPE_VALUE_ARRAY, &vals_ret,
916 lose_gerror ("Failed to complete SendCar call", error);
918 g_assert (vals_ret != NULL);
919 g_assert (vals_ret->n_values == 2);
921 g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0)));
922 g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
924 g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH);
925 g_assert (!strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
926 g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))));
928 g_value_array_free (vals);
929 g_value_array_free (vals_ret);
935 GHashTable *ret_table;
937 table = g_hash_table_new_full (g_str_hash, g_str_equal,
938 g_free, unset_and_free_gvalue);
940 val = g_new0 (GValue, 1);
941 g_value_init (val, G_TYPE_UINT);
942 g_value_set_uint (val, 42);
943 g_hash_table_insert (table, g_strdup ("foo"), val);
945 val = g_new0 (GValue, 1);
946 g_value_init (val, G_TYPE_STRING);
947 g_value_set_string (val, "hello");
948 g_hash_table_insert (table, g_strdup ("bar"), val);
951 g_print ("Calling ManyStringify\n");
952 if (!dbus_g_proxy_call (proxy, "ManyStringify", &error,
953 dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), table,
955 dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &ret_table,
957 lose_gerror ("Failed to complete ManyStringify call", error);
959 g_assert (ret_table != NULL);
960 g_assert (g_hash_table_size (ret_table) == 2);
962 val = g_hash_table_lookup (ret_table, "foo");
963 g_assert (val != NULL);
964 g_assert (G_VALUE_HOLDS_STRING (val));
965 g_assert (!strcmp ("42", g_value_get_string (val)));
967 val = g_hash_table_lookup (ret_table, "bar");
968 g_assert (val != NULL);
969 g_assert (G_VALUE_HOLDS_STRING (val));
970 g_assert (!strcmp ("hello", g_value_get_string (val)));
972 g_hash_table_destroy (table);
973 g_hash_table_destroy (ret_table);
979 DBusGProxy *ret_proxy;
981 g_print ("Calling (wrapped) objpath\n");
982 if (!dbus_g_proxy_call (proxy, "Objpath", &error,
983 DBUS_TYPE_G_PROXY, proxy, G_TYPE_INVALID,
984 DBUS_TYPE_G_PROXY, &ret_proxy, G_TYPE_INVALID))
985 lose_gerror ("Failed to complete Objpath call", error);
986 if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
987 dbus_g_proxy_get_path (ret_proxy)) != 0)
988 lose ("(wrapped) objpath call returned unexpected proxy %s",
989 dbus_g_proxy_get_path (ret_proxy));
991 g_print ("Doing get/increment val tests\n");
993 if (!org_freedesktop_DBus_Tests_MyObject_get_val (ret_proxy, &val, &error))
994 lose_gerror ("Failed to complete (wrapped) GetVal call", error);
996 lose ("(wrapped) GetVal returned invalid value %d", val);
998 if (!org_freedesktop_DBus_Tests_MyObject_increment_val (ret_proxy, &error))
999 lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
1001 if (!org_freedesktop_DBus_Tests_MyObject_increment_val (ret_proxy, &error))
1002 lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
1004 if (!org_freedesktop_DBus_Tests_MyObject_increment_val (ret_proxy, &error))
1005 lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
1007 if (!org_freedesktop_DBus_Tests_MyObject_get_val (ret_proxy, &val, &error))
1008 lose_gerror ("Failed to complete (wrapped) GetVal call", error);
1010 lose ("(wrapped) GetVal returned invalid value %d", val);
1012 if (!org_freedesktop_DBus_Tests_MyObject_get_val (proxy, &val, &error))
1013 lose_gerror ("Failed to complete (wrapped) GetVal call", error);
1015 lose ("(wrapped) GetVal returned invalid value %d", val);
1017 if (!org_freedesktop_DBus_Tests_MyObject_increment_val (proxy, &error))
1018 lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
1020 if (!org_freedesktop_DBus_Tests_MyObject_get_val (proxy, &val, &error))
1021 lose_gerror ("Failed to complete (wrapped) GetVal call", error);
1023 lose ("(wrapped) GetVal returned invalid value %d", val);
1025 if (!org_freedesktop_DBus_Tests_MyObject_get_val (ret_proxy, &val, &error))
1026 lose_gerror ("Failed to complete (wrapped) GetVal call", error);
1028 lose ("(wrapped) GetVal returned invalid value %d", val);
1030 g_object_unref (G_OBJECT (ret_proxy));
1032 g_print ("Calling objpath again\n");
1035 if (!dbus_g_proxy_call (proxy, "Objpath", &error,
1036 DBUS_TYPE_G_OBJECT_PATH,
1037 dbus_g_proxy_get_path (proxy),
1039 DBUS_TYPE_G_OBJECT_PATH,
1042 lose_gerror ("Failed to complete Objpath call 2", error);
1043 if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2", ret_path) != 0)
1044 lose ("Objpath call 2 returned unexpected path %s",
1047 ret_proxy = dbus_g_proxy_new_for_name_owner (connection,
1048 "org.freedesktop.DBus.TestSuiteGLibService",
1050 "org.freedesktop.DBus.Tests.FooObject",
1055 if (!org_freedesktop_DBus_Tests_FooObject_get_value (ret_proxy, &val, &error))
1056 lose_gerror ("Failed to complete (wrapped) GetValue call", error);
1058 lose ("(wrapped) GetValue returned invalid value %d", val);
1067 g_print ("Calling GetObjs\n");
1069 if (!dbus_g_proxy_call (proxy, "GetObjs", &error, G_TYPE_INVALID,
1070 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
1073 lose_gerror ("Failed to complete GetObjs call", error);
1075 lose ("GetObjs call returned unexpected number of objects %d, expected 2",
1078 if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject",
1079 g_ptr_array_index (objs, 0)) != 0)
1080 lose ("GetObjs call returned unexpected path \"%s\" in position 0; expected /org/freedesktop/DBus/Tests/MyTestObject", (char*) g_ptr_array_index (objs, 0));
1082 if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
1083 g_ptr_array_index (objs, 1)) != 0)
1084 lose ("GetObjs call returned unexpected path \"%s\" in position 1; expected /org/freedesktop/DBus/Tests/MyTestObject2", (char*) g_ptr_array_index (objs, 1));
1086 for (i = 0; i < objs->len; i++)
1087 g_free (g_ptr_array_index (objs, i));
1088 g_ptr_array_free (objs, TRUE);
1091 /* Signal handling tests */
1093 g_print ("Testing signal handling\n");
1094 dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
1096 dbus_g_proxy_connect_signal (proxy, "Frobnicate",
1097 G_CALLBACK (frobnicate_signal_handler),
1100 g_print ("Calling EmitFrobnicate\n");
1101 if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
1102 G_TYPE_INVALID, G_TYPE_INVALID))
1103 lose_gerror ("Failed to complete EmitFrobnicate call", error);
1106 dbus_g_connection_flush (connection);
1107 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1108 g_main_loop_run (loop);
1110 if (n_times_frobnicate_received != 1)
1111 lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
1113 g_print ("Calling EmitFrobnicate again\n");
1114 if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
1115 G_TYPE_INVALID, G_TYPE_INVALID))
1116 lose_gerror ("Failed to complete EmitFrobnicate call", error);
1118 dbus_g_connection_flush (connection);
1119 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1120 g_main_loop_run (loop);
1122 if (n_times_frobnicate_received != 2)
1123 lose ("Frobnicate signal received %d times, should have been 2", n_times_frobnicate_received);
1125 g_object_unref (G_OBJECT (proxy));
1129 g_print ("Creating proxy for FooObject interface\n");
1130 proxy = dbus_g_proxy_new_for_name_owner (connection,
1131 "org.freedesktop.DBus.TestSuiteGLibService",
1132 "/org/freedesktop/DBus/Tests/MyTestObject",
1133 "org.freedesktop.DBus.Tests.FooObject",
1137 lose_gerror ("Failed to create proxy for name owner", error);
1139 dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_INT_STRING,
1140 G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID);
1142 dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_BOXED,
1143 G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
1145 dbus_g_proxy_add_signal (proxy, "Sig0", G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID);
1146 dbus_g_proxy_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
1147 dbus_g_proxy_add_signal (proxy, "Sig2", DBUS_TYPE_G_STRING_STRING_HASHTABLE, G_TYPE_INVALID);
1149 dbus_g_proxy_connect_signal (proxy, "Sig0",
1150 G_CALLBACK (sig0_signal_handler),
1152 dbus_g_proxy_connect_signal (proxy, "Sig1",
1153 G_CALLBACK (sig1_signal_handler),
1155 dbus_g_proxy_connect_signal (proxy, "Sig2",
1156 G_CALLBACK (sig2_signal_handler),
1159 g_print ("Calling FooObject EmitSignals\n");
1160 dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
1162 dbus_g_connection_flush (connection);
1163 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1164 g_main_loop_run (loop);
1165 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1166 g_main_loop_run (loop);
1168 if (n_times_sig0_received != 1)
1169 lose ("Sig0 signal received %d times, should have been 1", n_times_sig0_received);
1170 if (n_times_sig1_received != 1)
1171 lose ("Sig1 signal received %d times, should have been 1", n_times_sig1_received);
1173 g_print ("Calling FooObject EmitSignals and EmitSignal2\n");
1174 dbus_g_proxy_call_no_reply (proxy, "EmitSignal2", G_TYPE_INVALID);
1175 dbus_g_connection_flush (connection);
1177 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1178 g_main_loop_run (loop);
1180 if (n_times_sig2_received != 1)
1181 lose ("Sig2 signal received %d times, should have been 1", n_times_sig2_received);
1183 g_print ("Calling FooObject EmitSignals two more times\n");
1184 dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
1185 dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
1187 dbus_g_connection_flush (connection);
1188 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1189 g_main_loop_run (loop);
1190 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1191 g_main_loop_run (loop);
1192 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1193 g_main_loop_run (loop);
1194 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1195 g_main_loop_run (loop);
1197 if (n_times_sig0_received != 3)
1198 lose ("Sig0 signal received %d times, should have been 3", n_times_sig0_received);
1199 if (n_times_sig1_received != 3)
1200 lose ("Sig1 signal received %d times, should have been 3", n_times_sig1_received);
1202 /* Terminate again */
1203 g_print ("Terminating service\n");
1204 await_terminating_service = "org.freedesktop.DBus.TestSuiteGLibService";
1205 dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID);
1207 proxy_destroyed = FALSE;
1208 proxy_destroy_and_nameowner = TRUE;
1209 proxy_destroy_and_nameowner_complete = FALSE;
1211 g_signal_connect (G_OBJECT (proxy),
1213 G_CALLBACK (proxy_destroyed_cb),
1216 dbus_g_connection_flush (connection);
1217 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1218 g_main_loop_run (loop);
1220 if (await_terminating_service != NULL)
1221 lose ("Didn't see name loss for \"org.freedesktop.DBus.TestSuiteGLibService\"");
1222 if (!proxy_destroyed)
1223 lose ("Didn't get proxy_destroyed");
1224 g_print ("Proxy destroyed successfully\n");
1226 /* Don't need to unref, proxy was destroyed */
1230 /* Create a new proxy for the name; should not be associated */
1231 proxy = dbus_g_proxy_new_for_name (connection,
1232 "org.freedesktop.DBus.TestSuiteGLibService",
1233 "/org/freedesktop/DBus/Tests/MyTestObject",
1234 "org.freedesktop.DBus.Tests.MyObject");
1235 g_assert (proxy != NULL);
1237 proxy_destroyed = FALSE;
1238 proxy_destroy_and_nameowner = FALSE;
1239 proxy_destroy_and_nameowner_complete = FALSE;
1241 g_signal_connect (G_OBJECT (proxy),
1243 G_CALLBACK (proxy_destroyed_cb),
1246 if (!dbus_g_proxy_call (driver, "GetNameOwner", &error,
1248 "org.freedesktop.DBus.TestSuiteGLibService",
1253 if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NAME_HAS_NO_OWNER)
1254 g_print ("Got expected error \"org.freedesktop.DBus.Error.NameHasNoOwner\"\n");
1256 lose_gerror ("Unexpected error from GetNameOwner", error);
1258 lose ("GetNameOwner unexpectedly succeeded!");
1259 g_clear_error (&error);
1261 /* This will have the side-effect of activating the service, thus
1262 * causing a NameOwnerChanged, which should let our name proxy
1265 g_print ("Calling Uppercase for name proxy\n");
1266 if (!dbus_g_proxy_call (proxy, "Uppercase", &error,
1267 G_TYPE_STRING, "bazwhee",
1269 G_TYPE_STRING, &v_STRING_2,
1271 lose_gerror ("Failed to complete Uppercase call", error);
1272 g_free (v_STRING_2);
1274 if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION1"))
1275 g_usleep (8 * G_USEC_PER_SEC);
1277 dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
1279 dbus_g_proxy_connect_signal (proxy, "Frobnicate",
1280 G_CALLBACK (frobnicate_signal_handler),
1283 g_print ("Calling EmitFrobnicate\n");
1284 if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
1285 G_TYPE_INVALID, G_TYPE_INVALID))
1286 lose_gerror ("Failed to complete EmitFrobnicate call", error);
1288 n_times_frobnicate_received = 0;
1290 dbus_g_connection_flush (connection);
1291 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1292 g_main_loop_run (loop);
1294 if (n_times_frobnicate_received != 1)
1295 lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
1297 /* Now terminate the service, then start it again (implicitly) and wait for signals */
1298 g_print ("Terminating service (2)\n");
1299 await_terminating_service = "org.freedesktop.DBus.TestSuiteGLibService";
1300 dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID);
1301 dbus_g_connection_flush (connection);
1302 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1303 g_main_loop_run (loop);
1304 if (await_terminating_service != NULL)
1305 lose ("Didn't see name loss for \"org.freedesktop.DBus.TestSuiteGLibService\"");
1307 if (proxy_destroyed)
1308 lose ("Unexpectedly got proxy_destroyed!");
1310 n_times_frobnicate_received = 0;
1312 g_print ("Calling EmitFrobnicate (2)\n");
1313 if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
1314 G_TYPE_INVALID, G_TYPE_INVALID))
1315 lose_gerror ("Failed to complete EmitFrobnicate call", error);
1317 if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION2"))
1318 g_usleep (8 * G_USEC_PER_SEC);
1320 dbus_g_connection_flush (connection);
1321 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1322 g_main_loop_run (loop);
1324 if (n_times_frobnicate_received != 1)
1325 lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
1327 if (proxy_destroyed)
1328 lose ("Unexpectedly got proxy_destroyed!");
1330 /* Create another proxy for the name; should be associated immediately */
1331 proxy2 = dbus_g_proxy_new_for_name (connection,
1332 "org.freedesktop.DBus.TestSuiteGLibService",
1333 "/org/freedesktop/DBus/Tests/MyTestObject",
1334 "org.freedesktop.DBus.Tests.MyObject");
1335 g_assert (proxy2 != NULL);
1337 dbus_g_proxy_add_signal (proxy2, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
1339 dbus_g_proxy_connect_signal (proxy2, "Frobnicate",
1340 G_CALLBACK (frobnicate_signal_handler_2),
1343 g_print ("Calling EmitFrobnicate (3)\n");
1344 if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
1345 G_TYPE_INVALID, G_TYPE_INVALID))
1346 lose_gerror ("Failed to complete EmitFrobnicate call", error);
1348 dbus_g_connection_flush (connection);
1349 exit_timeout = g_timeout_add (5000, timed_exit, loop);
1350 g_main_loop_run (loop);
1352 if (n_times_frobnicate_received != 2)
1353 lose ("Frobnicate signal received %d times for 1st proxy, should have been 2", n_times_frobnicate_received);
1354 if (n_times_frobnicate_received_2 != 1)
1355 lose ("Frobnicate signal received %d times for 2nd proxy, should have been 1", n_times_frobnicate_received_2);
1357 g_object_unref (G_OBJECT (proxy));
1358 g_object_unref (G_OBJECT (proxy2));
1362 /* Test introspection */
1363 proxy = dbus_g_proxy_new_for_name_owner (connection,
1364 "org.freedesktop.DBus.TestSuiteGLibService",
1365 "/org/freedesktop/DBus/Tests/MyTestObject",
1366 "org.freedesktop.DBus.Introspectable",
1369 lose_gerror ("Failed to create proxy for name owner", error);
1371 g_print ("Testing introspect\n");
1372 if (!dbus_g_proxy_call (proxy, "Introspect", &error,
1374 G_TYPE_STRING, &v_STRING_2,
1376 lose_gerror ("Failed to complete Introspect call", error);
1378 /* Could just do strcmp(), but that seems more fragile */
1382 gboolean found_introspectable;
1383 gboolean found_properties;
1384 gboolean found_myobject;
1385 gboolean found_fooobject;
1387 node = description_load_from_string (v_STRING_2, strlen (v_STRING_2), &error);
1389 lose_gerror ("Failed to parse introspection data: %s", error);
1391 found_introspectable = FALSE;
1392 found_properties = FALSE;
1393 found_myobject = FALSE;
1394 found_fooobject = FALSE;
1395 for (elt = node_info_get_interfaces (node); elt ; elt = elt->next)
1397 InterfaceInfo *iface = elt->data;
1399 if (!found_introspectable && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Introspectable") == 0)
1400 found_introspectable = TRUE;
1401 else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0)
1402 found_properties = TRUE;
1403 else if (!found_myobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Tests.MyObject") == 0)
1406 gboolean found_manyargs;
1408 found_myobject = TRUE;
1410 found_manyargs = FALSE;
1411 for (elt = interface_info_get_methods (iface); elt; elt = elt->next)
1416 if (strcmp (method_info_get_name (method), "ManyArgs") == 0)
1418 found_manyargs = TRUE;
1422 if (!found_manyargs)
1423 lose ("Missing method org.freedesktop.DBus.Tests.MyObject.ManyArgs");
1425 else if (!found_fooobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Tests.FooObject") == 0)
1426 found_fooobject = TRUE;
1428 lose ("Unexpected or duplicate interface %s", interface_info_get_name (iface));
1431 if (!(found_introspectable && found_myobject && found_properties))
1432 lose ("Missing interface");
1434 g_free (v_STRING_2);
1436 g_object_unref (G_OBJECT (driver));
1438 g_print ("Successfully completed %s\n", argv[0]);