* dbus/dbus-auth.c, dbus/dbus-connection.c, dbus/dbus-keyring.c,
[platform/upstream/dbus.git] / test / glib / test-dbus-glib.c
index 178d819..03a1a73 100644 (file)
@@ -23,6 +23,16 @@ static gboolean proxy_destroyed = FALSE;
 static gboolean proxy_destroy_and_nameowner = FALSE;
 static gboolean proxy_destroy_and_nameowner_complete = FALSE;
 
+static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
+static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
+
+static void
+unset_and_free_gvalue (gpointer val)
+{
+  g_value_unset (val);
+  g_free (val);
+}
+
 static gboolean
 timed_exit (gpointer loop)
 {
@@ -37,6 +47,7 @@ proxy_destroyed_cb (DBusGProxy *proxy, gpointer user_data)
   proxy_destroyed = TRUE;
   if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL)
     {
+      g_source_remove (exit_timeout);
       g_main_loop_quit (loop);
       proxy_destroy_and_nameowner_complete = TRUE;
     } 
@@ -59,11 +70,13 @@ name_owner_changed (DBusGProxy *proxy,
       await_terminating_service = NULL;
       if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && proxy_destroyed)
        {
+         g_source_remove (exit_timeout);
          g_main_loop_quit (loop);
          proxy_destroy_and_nameowner_complete = TRUE;
        } 
       else if (!proxy_destroy_and_nameowner)
        {
+         g_source_remove (exit_timeout);
          g_main_loop_quit (loop);
        }
     }
@@ -168,8 +181,75 @@ sig2_signal_handler (DBusGProxy  *proxy,
   g_source_remove (exit_timeout);
 }
 
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
+static DBusGProxyCall *echo_call;
+static guint n_times_echo_cb_entered;
+static void
+echo_received_cb (DBusGProxy *proxy,
+                 DBusGProxyCall *call,
+                 gpointer data)
+{
+  GError *error;
+  char *echo_data;
+
+  g_assert (call == echo_call);
+  g_assert (data == NULL);
+
+  error = NULL;
+  echo_data = NULL;
+  n_times_echo_cb_entered++;
+
+  if (!dbus_g_proxy_end_call (proxy, call, &error,
+                             G_TYPE_STRING,
+                             &echo_data,
+                             G_TYPE_INVALID))
+    lose_gerror ("Failed to complete async Echo", error);
+  g_assert (echo_data != NULL);
+  g_print ("Async echo gave \"%s\"\n", echo_data); 
+  g_free (echo_data);
+  g_main_loop_quit (loop);
+  g_source_remove (exit_timeout);
+}
+
+static void
+increment_received_cb (DBusGProxy *proxy,
+                      DBusGProxyCall *call,
+                      gpointer data)
+{
+  GError *error;
+  guint val;
+
+  g_assert (!strcmp (data, "moo"));
+
+  error = NULL;
+  if (!dbus_g_proxy_end_call (proxy, call, &error,
+                             G_TYPE_UINT, &val,
+                             G_TYPE_INVALID))
+    lose_gerror ("Failed to complete (async) Increment call", error);
+
+  if (val != 43)
+    lose ("Increment call returned %d, should be 43", 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, ...)
@@ -215,10 +295,10 @@ main (int argc, char **argv)
   DBusGProxy *driver;
   DBusGProxy *proxy;
   DBusGProxy *proxy2;
-  DBusGPendingCall *call;
   char **name_list;
   guint name_list_len;
   guint i;
+  DBusGProxyCall *call;
   guint32 result;
   char *v_STRING_2;
   guint32 v_UINT32_2;
@@ -262,12 +342,11 @@ main (int argc, char **argv)
                               NULL);
   /* Call ListNames method */
   
-  call = dbus_g_proxy_begin_call (driver, "ListNames", G_TYPE_INVALID);
-
   error = NULL;
-  if (!dbus_g_proxy_end_call (driver, call, &error,
-                              G_TYPE_STRV, &name_list,
-                              G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (driver, "ListNames", &error,
+                         G_TYPE_INVALID,
+                         G_TYPE_STRV, &name_list,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete ListNames call", error);
 
   g_print ("Names on the message bus:\n");
@@ -285,53 +364,42 @@ main (int argc, char **argv)
 
   g_print ("calling ThisMethodDoesNotExist\n");
   /* Test handling of unknown method */
-  call = dbus_g_proxy_begin_call (driver, "ThisMethodDoesNotExist",
-                                  G_TYPE_STRING,
-                                  "blah blah blah blah blah",
-                                  G_TYPE_INT,
-                                  10,
-                                  G_TYPE_INVALID);
-
-  error = NULL;
-  if (dbus_g_proxy_end_call (driver, call, &error,
-                            G_TYPE_INVALID))
+  if (dbus_g_proxy_call (driver, "ThisMethodDoesNotExist", &error,
+                        G_TYPE_STRING,
+                        "blah blah blah blah blah",
+                        G_TYPE_INT,
+                        10,
+                        G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
     lose ("Calling nonexistent method succeeded!");
 
   g_print ("Got EXPECTED error from calling unknown method: %s\n", error->message);
-  g_error_free (error);
+  g_clear_error (&error);
 
   run_mainloop ();
   
   /* Activate a service */
   g_print ("Activating echo service\n");
-  call = dbus_g_proxy_begin_call (driver, "StartServiceByName",
-                                  G_TYPE_STRING,
-                                  "org.freedesktop.DBus.TestSuiteEchoService",
-                                  G_TYPE_UINT,
-                                  0,
-                                  G_TYPE_INVALID);
-
-  error = NULL;
-  if (!dbus_g_proxy_end_call (driver, call, &error,
-                              G_TYPE_UINT, &result,
-                              G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
+                         G_TYPE_STRING,
+                         "org.freedesktop.DBus.TestSuiteEchoService",
+                         G_TYPE_UINT, 0,
+                         G_TYPE_INVALID,
+                         G_TYPE_UINT, &result,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete Activate call", error);
 
   g_print ("Starting echo service result = 0x%x\n", result);
 
   /* Activate a service again */
   g_print ("Activating echo service again\n");
-  call = dbus_g_proxy_begin_call (driver, "StartServiceByName",
-                                  G_TYPE_STRING,
-                                  "org.freedesktop.DBus.TestSuiteEchoService",
-                                  G_TYPE_UINT,
-                                  0,
-                                  DBUS_TYPE_INVALID);
-
-  error = NULL;
-  if (!dbus_g_proxy_end_call (driver, call, &error,
-                             G_TYPE_UINT, &result,
-                             G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
+                         G_TYPE_STRING,
+                         "org.freedesktop.DBus.TestSuiteEchoService",
+                         G_TYPE_UINT,
+                         0,
+                         G_TYPE_INVALID,
+                         G_TYPE_UINT, &result,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete Activate call", error);
 
   g_print ("Duplicate start of echo service = 0x%x\n", result);
@@ -351,20 +419,25 @@ main (int argc, char **argv)
   run_mainloop ();
 
   g_print ("Calling Echo\n");
-  call = dbus_g_proxy_begin_call (proxy, "Echo",
-                                  G_TYPE_STRING,
-                                  "my string hello",
-                                  G_TYPE_INVALID);
-
-  error = NULL;
-  if (!dbus_g_proxy_end_call (proxy, call, &error,
-                              G_TYPE_STRING, &v_STRING_2,
-                              G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (proxy, "Echo", &error,
+                         G_TYPE_STRING, "my string hello",
+                         G_TYPE_INVALID,
+                         G_TYPE_STRING, &v_STRING_2,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete Echo call", error);
 
   g_print ("String echoed = \"%s\"\n", v_STRING_2);
   g_free (v_STRING_2);
 
+  g_print ("Calling Echo (async)\n");
+  echo_call = dbus_g_proxy_begin_call (proxy, "Echo",
+                                      echo_received_cb, NULL, NULL,
+                                      G_TYPE_STRING, "my string hello",
+                                      G_TYPE_INVALID);
+  dbus_g_connection_flush (connection);
+  exit_timeout = g_timeout_add (5000, timed_exit, loop);
+  g_main_loop_run (loop);
+
   /* Test oneway call and signal handling */
 
   g_print ("Testing Foo emission\n");
@@ -417,10 +490,8 @@ main (int argc, char **argv)
     lose_gerror ("Failed to create proxy for name owner", error);
 
   g_print ("Calling DoNothing\n");
-  call = dbus_g_proxy_begin_call (proxy, "DoNothing",
-                                  G_TYPE_INVALID);
-  error = NULL;
-  if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (proxy, "DoNothing", &error,
+                         G_TYPE_INVALID, G_TYPE_INVALID))
     lose_gerror ("Failed to complete DoNothing call", error);
 
   g_print ("Calling Increment\n");
@@ -431,29 +502,75 @@ main (int argc, char **argv)
                          G_TYPE_UINT, &v_UINT32_2,
                          G_TYPE_INVALID))
     lose_gerror ("Failed to complete Increment call", error);
-
   if (v_UINT32_2 != 43)
     lose ("Increment call returned %d, should be 43", v_UINT32_2);
 
-  g_print ("Calling ThrowError\n");
-  call = dbus_g_proxy_begin_call (proxy, "ThrowError", G_TYPE_INVALID);
+  v_UINT32_2 = 0;
+  g_print ("Calling Increment (async)\n");
+  call = dbus_g_proxy_begin_call (proxy, "Increment",
+                                 increment_received_cb, g_strdup ("moo"), g_free,
+                                 G_TYPE_UINT, 42,
+                                 G_TYPE_INVALID);
+  dbus_g_connection_flush (connection);
+  exit_timeout = g_timeout_add (5000, timed_exit, loop);
+  g_main_loop_run (loop);
+
+  g_print ("Calling IncrementRetval\n");
+  error = NULL;
+  v_UINT32_2 = 0;
+  if (!dbus_g_proxy_call (proxy, "IncrementRetval", &error,
+                         G_TYPE_UINT, 42,
+                         G_TYPE_INVALID,
+                         G_TYPE_UINT, &v_UINT32_2,
+                         G_TYPE_INVALID))
+    lose_gerror ("Failed to complete Increment call", error);
+  if (v_UINT32_2 != 43)
+    lose ("IncrementRetval call returned %d, should be 43", v_UINT32_2);
+
+  g_print ("Calling IncrementRetvalError\n");
   error = NULL;
-  if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID) != FALSE)
+  v_UINT32_2 = 0;
+  if (!dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
+                         G_TYPE_UINT, 5,
+                         G_TYPE_INVALID,
+                         G_TYPE_UINT, &v_UINT32_2,
+                         G_TYPE_INVALID))
+    lose_gerror ("Failed to complete Increment call", error);
+  if (v_UINT32_2 != 6)
+    lose ("IncrementRetval call returned %d, should be 6", v_UINT32_2);
+
+  g_print ("Calling ThrowError\n");
+  if (dbus_g_proxy_call (proxy, "ThrowError", &error,
+                        G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
     lose ("ThrowError call unexpectedly succeeded!");
+
   if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.Tests.MyObject.Foo"))
-    lose ("ThrowError call returned unexpected error %s", dbus_g_error_get_name (error));
+    lose ("ThrowError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error),
+         error->message);
 
   g_print ("ThrowError failed (as expected) returned error: %s\n", error->message);
   g_clear_error (&error);
 
-  g_print ("Calling Uppercase\n");
-  call = dbus_g_proxy_begin_call (proxy, "Uppercase",
-                                 G_TYPE_STRING, "foobar",
-                                 G_TYPE_INVALID);
+  g_print ("Calling IncrementRetvalError (for error)\n");
   error = NULL;
-  if (!dbus_g_proxy_end_call (proxy, call, &error,
-                             G_TYPE_STRING, &v_STRING_2,
-                             G_TYPE_INVALID))
+  v_UINT32_2 = 0;
+  if (dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
+                        G_TYPE_UINT, 20,
+                        G_TYPE_INVALID,
+                        G_TYPE_UINT, &v_UINT32_2,
+                        G_TYPE_INVALID) != FALSE)
+    lose ("IncrementRetvalError call unexpectedly succeeded!");
+  if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.Tests.MyObject.Foo"))
+    lose ("IncrementRetvalError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error), error->message);
+  g_clear_error (&error);
+
+  error = NULL;
+  g_print ("Calling Uppercase\n");
+  if (!dbus_g_proxy_call (proxy, "Uppercase", &error,
+                         G_TYPE_STRING, "foobar",
+                         G_TYPE_INVALID,
+                         G_TYPE_STRING, &v_STRING_2,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete Uppercase call", error);
   if (strcmp ("FOOBAR", v_STRING_2) != 0)
     lose ("Uppercase call returned unexpected string %s", v_STRING_2);
@@ -462,16 +579,14 @@ main (int argc, char **argv)
   run_mainloop ();
 
   g_print ("Calling ManyArgs\n");
-  call = dbus_g_proxy_begin_call (proxy, "ManyArgs",
-                                 G_TYPE_UINT, 26,
-                                 G_TYPE_STRING, "bazwhee",
-                                 G_TYPE_DOUBLE, G_PI,
-                                 G_TYPE_INVALID);
-  error = NULL;
-  if (!dbus_g_proxy_end_call (proxy, call, &error,
-                             G_TYPE_DOUBLE, &v_DOUBLE_2,
-                             G_TYPE_STRING, &v_STRING_2,
-                             G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (proxy, "ManyArgs", &error,
+                         G_TYPE_UINT, 26,
+                         G_TYPE_STRING, "bazwhee",
+                         G_TYPE_DOUBLE, G_PI,
+                         G_TYPE_INVALID,
+                         G_TYPE_DOUBLE, &v_DOUBLE_2,
+                         G_TYPE_STRING, &v_STRING_2,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete ManyArgs call", error);
   if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56)
     lose ("ManyArgs call returned unexpected double value %f", v_DOUBLE_2);
@@ -490,6 +605,20 @@ main (int argc, char **argv)
   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);
+
+  if (v_UINT32_2 != 43)
+    lose ("(wrapped) async increment call returned %d, should be 43", v_UINT32_2);
+
   g_print ("Calling (wrapped) throw_error\n");
   if (org_freedesktop_DBus_Tests_MyObject_throw_error (proxy, &error) != FALSE)
     lose ("(wrapped) ThrowError call unexpectedly succeeded!");
@@ -497,6 +626,12 @@ main (int argc, char **argv)
   g_print ("(wrapped) ThrowError failed (as expected) returned error: %s\n", error->message);
   g_clear_error (&error);
 
+  if (org_freedesktop_DBus_Tests_MyObject_async_throw_error (proxy, &error) != FALSE)
+    lose ("(wrapped) AsyncThrowError call unexpectedly succeeded!");
+
+  g_print ("(wrapped) AsyncThrowError failed (as expected) returned error: %s\n", error->message);
+  g_clear_error (&error);
+
   g_print ("Calling (wrapped) uppercase\n");
   if (!org_freedesktop_DBus_Tests_MyObject_uppercase (proxy, "foobar", &v_STRING_2, &error)) 
     lose_gerror ("Failed to complete (wrapped) Uppercase call", error);
@@ -748,12 +883,155 @@ main (int argc, char **argv)
   run_mainloop ();
 
   {
+    GValueArray *vals;
+    GValueArray *vals_ret;
+    GValue *val;
+
+    vals = g_value_array_new (3);
+
+    g_value_array_append (vals, NULL);
+    g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_STRING);
+    g_value_set_string (g_value_array_get_nth (vals, 0), "foo");
+
+    g_value_array_append (vals, NULL);
+    g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_UINT);
+    g_value_set_uint (g_value_array_get_nth (vals, vals->n_values - 1), 42);
+
+    g_value_array_append (vals, NULL);
+    g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_VALUE);
+    val = g_new0 (GValue, 1);
+    g_value_init (val, G_TYPE_UCHAR);
+    g_value_set_uchar (val, '!');
+    g_value_set_boxed (g_value_array_get_nth (vals, vals->n_values - 1), val);
+
+    vals_ret = NULL;
+    g_print ("Calling SendCar\n");
+    if (!dbus_g_proxy_call (proxy, "SendCar", &error,
+                           G_TYPE_VALUE_ARRAY, vals,
+                           G_TYPE_INVALID,
+                           G_TYPE_VALUE_ARRAY, &vals_ret,
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to complete SendCar call", error);
+
+    g_assert (vals_ret != NULL);
+    g_assert (vals_ret->n_values == 2);
+
+    g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0)));
+    g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
+    
+    g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH);
+    g_assert (!strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
+                      g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))));
+
+    g_value_array_free (vals);
+    g_value_array_free (vals_ret);
+  }
+
+  {
+    GValue *val;
+    GHashTable *table;
+    GHashTable *ret_table;
+
+    table = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                  g_free, unset_and_free_gvalue);
+    
+    val = g_new0 (GValue, 1);
+    g_value_init (val, G_TYPE_UINT);
+    g_value_set_uint (val, 42);
+    g_hash_table_insert (table, g_strdup ("foo"), val);
+
+    val = g_new0 (GValue, 1);
+    g_value_init (val, G_TYPE_STRING);
+    g_value_set_string (val, "hello");
+    g_hash_table_insert (table, g_strdup ("bar"), val);
+
+    ret_table = NULL;
+    g_print ("Calling ManyStringify\n");
+    if (!dbus_g_proxy_call (proxy, "ManyStringify", &error,
+                           dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), table,
+                           G_TYPE_INVALID,
+                           dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &ret_table,
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to complete ManyStringify call", error);
+
+    g_assert (ret_table != NULL);
+    g_assert (g_hash_table_size (ret_table) == 2);
+
+    val = g_hash_table_lookup (ret_table, "foo");
+    g_assert (val != NULL);
+    g_assert (G_VALUE_HOLDS_STRING (val));
+    g_assert (!strcmp ("42", g_value_get_string (val)));
+
+    val = g_hash_table_lookup (ret_table, "bar");
+    g_assert (val != NULL);
+    g_assert (G_VALUE_HOLDS_STRING (val));
+    g_assert (!strcmp ("hello", g_value_get_string (val)));
+
+    g_hash_table_destroy (table);
+    g_hash_table_destroy (ret_table);
+  }
+
+  {
+    GPtrArray *in_array;
+    GPtrArray *out_array;
+    char **strs;
+    GArray *uints;
+
+    in_array = g_ptr_array_new ();
+
+    strs = g_new0 (char *, 3);
+    strs[0] = "foo";
+    strs[1] = "bar";
+    strs[2] = NULL;
+    g_ptr_array_add (in_array, strs);
+
+    strs = g_new0 (char *, 4);
+    strs[0] = "baz";
+    strs[1] = "whee";
+    strs[2] = "moo";
+    strs[3] = NULL;
+    g_ptr_array_add (in_array, strs);
+
+    out_array = NULL;
+    g_print ("Calling RecArrays\n");
+    if (!dbus_g_proxy_call (proxy, "RecArrays", &error,
+                           dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), in_array,
+                           G_TYPE_INVALID,
+                           dbus_g_type_get_collection ("GPtrArray",
+                                                       dbus_g_type_get_collection ("GPtrArray",
+                                                                                   G_TYPE_UINT)), &out_array, 
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to complete RecArrays call", error);
+    g_free (g_ptr_array_index (in_array, 0));
+    g_free (g_ptr_array_index (in_array, 1));
+
+    g_assert (out_array);
+    g_assert (out_array->len == 2);
+    uints = g_ptr_array_index (out_array, 0);
+    g_assert (uints);
+    g_assert (uints->len == 3);
+    g_assert (g_array_index (uints, guint, 0) == 10);
+    g_assert (g_array_index (uints, guint, 1) == 42);
+    g_assert (g_array_index (uints, guint, 2) == 27);
+    g_array_free (uints, TRUE);
+    uints = g_ptr_array_index (out_array, 1);
+    g_assert (uints);
+    g_assert (uints->len == 1);
+    g_assert (g_array_index (uints, guint, 0) == 30);
+    g_array_free (uints, TRUE);
+    g_ptr_array_free (out_array, TRUE);
+  }
+
+  {
     guint val;
+    char *ret_path;
     DBusGProxy *ret_proxy;
 
     g_print ("Calling (wrapped) objpath\n");
-    if (!org_freedesktop_DBus_Tests_MyObject_objpath (proxy, proxy, &ret_proxy, &error))
-      lose_gerror ("Failed to complete (wrapped) Objpath call", error);
+    if (!dbus_g_proxy_call (proxy, "Objpath", &error,
+                           DBUS_TYPE_G_PROXY, proxy, G_TYPE_INVALID,
+                           DBUS_TYPE_G_PROXY, &ret_proxy, G_TYPE_INVALID))
+      lose_gerror ("Failed to complete Objpath call", error);
     if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
                dbus_g_proxy_get_path (ret_proxy)) != 0)
       lose ("(wrapped) objpath call returned unexpected proxy %s",
@@ -802,20 +1080,26 @@ main (int argc, char **argv)
 
     g_print ("Calling objpath again\n");
     ret_proxy = NULL;
-    if (!org_freedesktop_DBus_Tests_MyObject_objpath (proxy, proxy, &ret_proxy, &error))
-      lose_gerror ("Failed to complete (wrapped) Objpath call 2", error);
-    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
-               dbus_g_proxy_get_path (ret_proxy)) != 0)
-      lose ("(wrapped) objpath call 2 returned unexpected proxy %s",
-           dbus_g_proxy_get_path (ret_proxy));
-    {
-      const char *iface = dbus_g_proxy_get_interface (ret_proxy);
-      g_print ("returned proxy has interface \"%s\"\n",
-              iface ? iface : "(NULL)");
-    }
-
-    dbus_g_proxy_set_interface (ret_proxy, "org.freedesktop.DBus.Tests.FooObject");
 
+    if (!dbus_g_proxy_call (proxy, "Objpath", &error,
+                           DBUS_TYPE_G_OBJECT_PATH,
+                           dbus_g_proxy_get_path (proxy),
+                           G_TYPE_INVALID,
+                           DBUS_TYPE_G_OBJECT_PATH,
+                           &ret_path,
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to complete Objpath call 2", error);
+    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2", ret_path) != 0)
+      lose ("Objpath call 2 returned unexpected path %s",
+           ret_path);
+
+    ret_proxy = dbus_g_proxy_new_for_name_owner (connection,
+                                                "org.freedesktop.DBus.TestSuiteGLibService",
+                                                ret_path,
+                                                "org.freedesktop.DBus.Tests.FooObject",
+                                                &error);
+    g_free (ret_path);
+    
     val = 0;
     if (!org_freedesktop_DBus_Tests_FooObject_get_value (ret_proxy, &val, &error))
       lose_gerror ("Failed to complete (wrapped) GetValue call", error);
@@ -825,6 +1109,61 @@ main (int argc, char **argv)
 
   run_mainloop ();
 
+  {
+    GPtrArray *objs;
+    guint i;
+
+    g_print ("Calling GetObjs\n");
+
+    if (!dbus_g_proxy_call (proxy, "GetObjs", &error, G_TYPE_INVALID,
+                           dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+                           &objs,
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to complete GetObjs call", error);
+    if (objs->len != 2)
+      lose ("GetObjs call returned unexpected number of objects %d, expected 2",
+           objs->len);
+
+    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject",
+               g_ptr_array_index (objs, 0)) != 0)
+      lose ("GetObjs call returned unexpected path \"%s\" in position 0; expected /org/freedesktop/DBus/Tests/MyTestObject", (char*) g_ptr_array_index (objs, 0));
+
+    if (strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
+               g_ptr_array_index (objs, 1)) != 0)
+      lose ("GetObjs call returned unexpected path \"%s\" in position 1; expected /org/freedesktop/DBus/Tests/MyTestObject2", (char*) g_ptr_array_index (objs, 1));
+
+    for (i = 0; i < objs->len; i++)
+      g_free (g_ptr_array_index (objs, i));
+    g_ptr_array_free (objs, TRUE);
+  }
+  
+  {
+    GValue *variant;
+    GArray *array;
+    gint i;
+
+    g_print ("Calling ProcessVariantOfArrayOfInts123\n");
+
+    array = g_array_sized_new (FALSE, FALSE, sizeof(gint), 3);
+    i = 1;
+    g_array_append_val (array, i);
+    i++;
+    g_array_append_val (array, i);
+    i++;
+    g_array_append_val (array, i);
+
+    variant = g_new0 (GValue, 1);
+    g_value_init (variant, dbus_g_type_get_collection ("GArray", G_TYPE_INT));
+    g_value_set_boxed_take_ownership (variant, array);
+
+    if (!dbus_g_proxy_call (proxy, "ProcessVariantOfArrayOfInts123", &error,
+                            G_TYPE_VALUE, variant,
+                            G_TYPE_INVALID,
+                           G_TYPE_INVALID))
+      lose_gerror ("Failed to send a vairant of array of ints 1, 2 and 3!", error);
+
+    g_value_unset (variant);
+  }
   /* Signal handling tests */
   
   g_print ("Testing signal handling\n");
@@ -960,7 +1299,7 @@ main (int argc, char **argv)
     lose ("Didn't get proxy_destroyed");
   g_print ("Proxy destroyed successfully\n");
 
-  g_object_unref (G_OBJECT (proxy));
+  /* Don't need to unref, proxy was destroyed */
 
   run_mainloop ();
 
@@ -1008,6 +1347,9 @@ main (int argc, char **argv)
     lose_gerror ("Failed to complete Uppercase call", error);
   g_free (v_STRING_2);
 
+  if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION1"))
+    g_usleep (8 * G_USEC_PER_SEC);
+
   dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
   
   dbus_g_proxy_connect_signal (proxy, "Frobnicate",
@@ -1048,6 +1390,9 @@ main (int argc, char **argv)
                          G_TYPE_INVALID, G_TYPE_INVALID))
     lose_gerror ("Failed to complete EmitFrobnicate call", error);
 
+  if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION2"))
+    g_usleep (8 * G_USEC_PER_SEC);
+
   dbus_g_connection_flush (connection);
   exit_timeout = g_timeout_add (5000, timed_exit, loop);
   g_main_loop_run (loop);
@@ -1100,12 +1445,10 @@ main (int argc, char **argv)
     lose_gerror ("Failed to create proxy for name owner", error);
 
   g_print ("Testing introspect\n");
-  call = dbus_g_proxy_begin_call (proxy, "Introspect",
-                                 G_TYPE_INVALID);
-  error = NULL;
-  if (!dbus_g_proxy_end_call (proxy, call, &error,
-                             G_TYPE_STRING, &v_STRING_2,
-                             G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (proxy, "Introspect", &error,
+                         G_TYPE_INVALID,
+                         G_TYPE_STRING, &v_STRING_2,
+                         G_TYPE_INVALID))
     lose_gerror ("Failed to complete Introspect call", error);
 
   /* Could just do strcmp(), but that seems more fragile */