dbus/test/glib test-dbus-glib.c,1.26,1.27

Ross Burton ross at freedesktop.org
Sat Jul 9 03:02:45 EST 2005


Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv7523/test/glib

Modified Files:
	test-dbus-glib.c 
Log Message:
Make async bindings work again

Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- test-dbus-glib.c	8 Jul 2005 16:25:30 -0000	1.26
+++ test-dbus-glib.c	8 Jul 2005 17:02:42 -0000	1.27
@@ -194,7 +194,7 @@
 			      G_TYPE_INVALID))
     lose_gerror ("Failed to complete async Echo", error);
   g_assert (echo_data != NULL);
-  g_print ("Async echo gave \"%s\"", echo_data); 
+  g_print ("Async echo gave \"%s\"\n", echo_data); 
   g_free (echo_data);
   g_main_loop_quit (loop);
   g_source_remove (exit_timeout);
@@ -221,11 +221,28 @@
   if (val != 43)
     lose ("Increment call returned %d, should be 43", val);
   
-  g_print ("Async increment gave \"%d\"", val); 
+  g_print ("Async increment gave \"%d\"\n", val); 
+  g_main_loop_quit (loop);
+  g_source_remove (exit_timeout);
+}
+
+static void
+increment_async_cb (DBusGProxy *proxy, guint val, GError *error, gpointer data)
+{
+  if (error)
+    lose_gerror ("Failed to complete (wrapped async) Increment call", error);
+
+  if (data != NULL)
+    lose ("(wrapped async) Increment call gave unexpected data");
+  if (val != 43)
+    lose ("(wrapped async) Increment call returned %d, should be 43", val);
+
+  g_print ("(wrapped async) increment gave \"%d\"\n", val); 
   g_main_loop_quit (loop);
   g_source_remove (exit_timeout);
 }
 
+
 static void
 lose (const char *str, ...)
 {
@@ -543,6 +560,13 @@
   if (v_UINT32_2 != 43)
     lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2);
 
+  g_print ("Calling (wrapped async) increment\n");
+  if (!org_freedesktop_DBus_Tests_MyObject_increment_async (proxy, 42, increment_async_cb, NULL))
+    lose_gerror ("Failed to complete (wrapped) Increment call", error);
+  dbus_g_connection_flush (connection);
+  exit_timeout = g_timeout_add (5000, timed_exit, loop);
+  g_main_loop_run (loop);
+
   v_UINT32_2 = 0;
   if (!org_freedesktop_DBus_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error))
     lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error);



More information about the dbus-commit mailing list