[Pkg-telepathy-commits] [telepathy-glib-1] 78/212: Tests: Pass a factory to all TpProxy instances

Simon McVittie smcv at debian.org
Wed May 14 12:08:53 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib-1.

commit ede7492b3f7a4c88b6745599ec1ff37969c8354c
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date:   Sun Mar 30 09:28:42 2014 -0400

    Tests: Pass a factory to all TpProxy instances
    
    Lots of tests creates plain TpProxy instances, they need
    a factory as well because TpProxy::constructed will soon start
    to assert that it got a factory.
---
 tests/dbus/account-channel-request.c |  1 +
 tests/dbus/base-client.c             |  1 +
 tests/dbus/call-cancellation.c       | 34 +++++++++++++++++++++++-----------
 tests/dbus/call-channel.c            |  1 +
 tests/dbus/client.c                  | 14 +++++++++-----
 tests/dbus/disconnection.c           | 34 +++++++++++++++++++++++-----------
 tests/dbus/properties.c              |  4 ++++
 tests/dbus/simple-approver.c         |  4 ++++
 tests/dbus/simple-handler.c          |  4 ++++
 tests/dbus/simple-observer.c         |  4 ++++
 tests/lib/simple-channel-request.c   | 11 ++++++-----
 11 files changed, 80 insertions(+), 32 deletions(-)

diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index ebdf276..abca8fa 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -856,6 +856,7 @@ test_handle_delegated (Test *test,
       "dbus-daemon", tp_base_client_get_dbus_daemon (base_client),
       "bus-name", tp_base_client_get_bus_name (base_client),
       "object-path",  tp_base_client_get_object_path (base_client),
+      "factory", tp_proxy_get_factory (test->account),
       NULL);
 
   tp_proxy_add_interface_by_id (TP_PROXY (client),
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index 08f6883..915657b 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -111,6 +111,7 @@ setup (Test *test,
           "dbus-daemon", test->dbus,
           "bus-name", tp_base_client_get_bus_name (test->base_client),
           "object-path", tp_base_client_get_object_path (test->base_client),
+          "factory", test->factory,
           NULL);
 
   g_assert (test->client != NULL);
diff --git a/tests/dbus/call-cancellation.c b/tests/dbus/call-cancellation.c
index 82363d7..3cd1073 100644
--- a/tests/dbus/call-cancellation.c
+++ b/tests/dbus/call-cancellation.c
@@ -45,12 +45,12 @@ enum {
 typedef struct {
     GTestDBus *test_dbus;
 
-    TpDBusDaemon *dbus_daemon;
+    TpClientFactory *factory;
     TpProxy *proxies[N_PROXIES];
     GObject *cd_service;
 
     GDBusConnection *private_gdbus;
-    TpDBusDaemon *private_dbus_daemon;
+    TpClientFactory *private_factory;
 
     gboolean had_last_reply;
 } Fixture;
@@ -173,6 +173,9 @@ static void
 setup (Fixture *f,
     gconstpointer data)
 {
+  TpDBusDaemon *dbus_daemon;
+  GError *error = NULL;
+
   global_fixture = f;
 
   tp_tests_abort_after (10);
@@ -186,7 +189,9 @@ setup (Fixture *f,
   f->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
   g_test_dbus_up (f->test_dbus);
 
-  f->dbus_daemon = tp_tests_dbus_daemon_dup_or_die ();
+  f->factory = tp_client_factory_dup (&error);
+  g_assert_no_error (error);
+  dbus_daemon = tp_client_factory_get_dbus_daemon (f->factory);
 
   /* Any random object with an interface: what matters is that it can
    * accept a method call and emit a signal. We use the Properties
@@ -194,12 +199,14 @@ setup (Fixture *f,
   f->cd_service = tp_tests_object_new_static_class (
       TP_TESTS_TYPE_SIMPLE_CHANNEL_DISPATCHER,
       NULL);
-  tp_dbus_daemon_register_object (f->dbus_daemon, "/", f->cd_service);
+  tp_dbus_daemon_register_object (dbus_daemon, "/", f->cd_service);
 
   f->private_gdbus = tp_tests_get_private_bus ();
   g_assert (f->private_gdbus != NULL);
-  f->private_dbus_daemon = tp_dbus_daemon_new (f->private_gdbus);
-  g_assert (f->private_dbus_daemon != NULL);
+  dbus_daemon = tp_dbus_daemon_new (f->private_gdbus);
+  g_assert (dbus_daemon != NULL);
+  f->private_factory = tp_client_factory_new (dbus_daemon);
+  g_object_unref (dbus_daemon);
 }
 
 static void
@@ -215,9 +222,9 @@ teardown (Fixture *f,
     gconstpointer data)
 {
   tp_tests_assert_last_unref (&f->cd_service);
-  tp_tests_assert_last_unref (&f->dbus_daemon);
+  tp_tests_assert_last_unref (&f->factory);
 
-  tp_tests_assert_last_unref (&f->private_dbus_daemon);
+  tp_tests_assert_last_unref (&f->private_factory);
 
   g_test_dbus_down (f->test_dbus);
   tp_tests_assert_last_unref (&f->test_dbus);
@@ -233,17 +240,22 @@ static TpProxy *
 new_proxy (Fixture *f,
     int which)
 {
+  TpClientFactory *local_factory;
   TpDBusDaemon *local_dbus_daemon;
 
   if (which == TEST_F)
-    local_dbus_daemon = f->private_dbus_daemon;
+    local_factory = f->private_factory;
   else
-    local_dbus_daemon = f->dbus_daemon;
+    local_factory = f->factory;
+
+  local_dbus_daemon = tp_client_factory_get_dbus_daemon (local_factory);
 
   return tp_tests_object_new_static_class (TP_TYPE_PROXY,
       "dbus-daemon", local_dbus_daemon,
-      "bus-name", tp_dbus_daemon_get_unique_name (f->dbus_daemon),
+      "bus-name", tp_dbus_daemon_get_unique_name (
+          tp_client_factory_get_dbus_daemon (f->factory)),
       "object-path", "/",
+      "factory", local_factory,
       NULL);
 }
 
diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c
index 94071df..9af965f 100644
--- a/tests/dbus/call-channel.c
+++ b/tests/dbus/call-channel.c
@@ -390,6 +390,7 @@ run_until_active_get_all_cb (TpProxy *proxy,
           "dbus-daemon", tp_proxy_get_dbus_daemon (proxy),
           "bus-name", tp_proxy_get_bus_name (proxy),
           "object-path", object_path,
+          "factory", tp_proxy_get_factory (proxy),
           NULL);
       tp_proxy_add_interface_by_id (endpoint,
           TP_IFACE_QUARK_CALL1_STREAM_ENDPOINT);
diff --git a/tests/dbus/client.c b/tests/dbus/client.c
index 0351700..4b4b4aa 100644
--- a/tests/dbus/client.c
+++ b/tests/dbus/client.c
@@ -17,7 +17,7 @@
 
 typedef struct {
     GMainLoop *mainloop;
-    TpDBusDaemon *dbus;
+    TpClientFactory *factory;
 
     TpClient *client;
     GError *error /* initialized where needed */;
@@ -27,10 +27,13 @@ static void
 setup (Test *test,
        gconstpointer data)
 {
+  GError *error = NULL;
+
   tp_debug_set_flags ("all");
 
   test->mainloop = g_main_loop_new (NULL, FALSE);
-  test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+  test->factory = tp_client_factory_dup (&error);
+  g_assert_no_error (error);
 
   test->client = NULL;
 }
@@ -45,8 +48,8 @@ teardown (Test *test,
       test->client = NULL;
     }
 
-  g_object_unref (test->dbus);
-  test->dbus = NULL;
+  g_object_unref (test->factory);
+  test->factory = NULL;
   g_main_loop_unref (test->mainloop);
   test->mainloop = NULL;
 }
@@ -56,9 +59,10 @@ test_new (Test *test,
           gconstpointer data G_GNUC_UNUSED)
 {
   test->client = tp_tests_object_new_static_class (TP_TYPE_CLIENT,
-      "dbus-daemon", test->dbus,
+      "dbus-daemon", tp_client_factory_get_dbus_daemon (test->factory),
       "object-path", "/im/telepathy/v1/Client/whatever",
       "bus-name", "im.telepathy.v1.Client.whatever",
+      "factory", test->factory,
       NULL);
   g_assert (test->client != NULL);
 }
diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c
index a5ad8f6..ce1fcba 100644
--- a/tests/dbus/disconnection.c
+++ b/tests/dbus/disconnection.c
@@ -37,12 +37,12 @@ enum {
 
 typedef struct {
     GTestDBus *test_dbus;
-    TpDBusDaemon *dbus_daemon;
+    TpClientFactory *factory;
     TpProxy *proxies[N_PROXIES];
     GObject *cd_service;
 
     GDBusConnection *private_gdbus;
-    TpDBusDaemon *private_dbus_daemon;
+    TpClientFactory *private_factory;
 } Fixture;
 
 /* FIXME: it would be better not to need this */
@@ -132,6 +132,9 @@ static void
 setup (Fixture *f,
     gconstpointer user_data)
 {
+  TpDBusDaemon *dbus_daemon;
+  GError *error = NULL;
+
   global_fixture = f;
 
   tp_tests_abort_after (10);
@@ -144,7 +147,9 @@ setup (Fixture *f,
   f->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
   g_test_dbus_up (f->test_dbus);
 
-  f->dbus_daemon = tp_tests_dbus_daemon_dup_or_die ();
+  f->factory = tp_client_factory_dup (&error);
+  g_assert_no_error (error);
+  dbus_daemon = tp_client_factory_get_dbus_daemon (f->factory);
 
   /* Any random object with an interface: what matters is that it can
    * accept a method call and emit a signal. We use the Properties
@@ -152,12 +157,14 @@ setup (Fixture *f,
   f->cd_service = tp_tests_object_new_static_class (
       TP_TESTS_TYPE_SIMPLE_CHANNEL_DISPATCHER,
       NULL);
-  tp_dbus_daemon_register_object (f->dbus_daemon, "/", f->cd_service);
+  tp_dbus_daemon_register_object (dbus_daemon, "/", f->cd_service);
 
   f->private_gdbus = tp_tests_get_private_bus ();
   g_assert (f->private_gdbus != NULL);
-  f->private_dbus_daemon = tp_dbus_daemon_new (f->private_gdbus);
-  g_assert (f->private_dbus_daemon != NULL);
+  dbus_daemon = tp_dbus_daemon_new (f->private_gdbus);
+  g_assert (dbus_daemon != NULL);
+  f->private_factory = tp_client_factory_new (dbus_daemon);
+  g_object_unref (dbus_daemon);
 }
 
 static void
@@ -173,9 +180,9 @@ teardown (Fixture *f,
     gconstpointer data)
 {
   tp_tests_assert_last_unref (&f->cd_service);
-  tp_tests_assert_last_unref (&f->dbus_daemon);
+  tp_tests_assert_last_unref (&f->factory);
 
-  tp_tests_assert_last_unref (&f->private_dbus_daemon);
+  tp_tests_assert_last_unref (&f->private_factory);
 
   g_test_dbus_down (f->test_dbus);
   tp_tests_assert_last_unref (&f->test_dbus);
@@ -190,17 +197,22 @@ static TpProxy *
 new_proxy (Fixture *f,
     int which)
 {
+  TpClientFactory *local_factory;
   TpDBusDaemon *local_dbus_daemon;
 
   if (which == TEST_F)
-    local_dbus_daemon = f->private_dbus_daemon;
+    local_factory = f->private_factory;
   else
-    local_dbus_daemon = f->dbus_daemon;
+    local_factory = f->factory;
+
+  local_dbus_daemon = tp_client_factory_get_dbus_daemon (local_factory);
 
   return tp_tests_object_new_static_class (TP_TYPE_PROXY,
       "dbus-daemon", local_dbus_daemon,
-      "bus-name", tp_dbus_daemon_get_unique_name (f->dbus_daemon),
+      "bus-name", tp_dbus_daemon_get_unique_name (
+          tp_client_factory_get_dbus_daemon (f->factory)),
       "object-path", "/",
+      "factory", local_factory,
       NULL);
 }
 
diff --git a/tests/dbus/properties.c b/tests/dbus/properties.c
index bff1064..d055bee 100644
--- a/tests/dbus/properties.c
+++ b/tests/dbus/properties.c
@@ -224,6 +224,7 @@ main (int argc, char **argv)
 {
   Context ctx;
   TpDBusDaemon *dbus_daemon;
+  TpClientFactory *factory;
   GTestDBus *test_dbus;
   int ret;
 
@@ -234,6 +235,7 @@ main (int argc, char **argv)
   g_test_dbus_up (test_dbus);
 
   dbus_daemon = tp_tests_dbus_daemon_dup_or_die ();
+  factory = tp_client_factory_dup (NULL);
   ctx.obj = tp_tests_object_new_static_class (TEST_TYPE_PROPERTIES, NULL);
   tp_dbus_daemon_register_object (dbus_daemon, "/", ctx.obj);
 
@@ -242,6 +244,7 @@ main (int argc, char **argv)
       "dbus-daemon", dbus_daemon,
       "bus-name", tp_dbus_daemon_get_unique_name (dbus_daemon),
       "object-path", "/",
+      "factory", factory,
       NULL));
 
   g_assert (tp_proxy_has_interface (ctx.proxy, "org.freedesktop.DBus.Properties"));
@@ -257,6 +260,7 @@ main (int argc, char **argv)
   g_object_unref (ctx.obj);
   g_object_unref (ctx.proxy);
   g_object_unref (dbus_daemon);
+  g_object_unref (factory);
 
   g_test_dbus_down (test_dbus);
   tp_tests_assert_last_unref (&test_dbus);
diff --git a/tests/dbus/simple-approver.c b/tests/dbus/simple-approver.c
index 714b62a..1125a10 100644
--- a/tests/dbus/simple-approver.c
+++ b/tests/dbus/simple-approver.c
@@ -29,6 +29,7 @@
 typedef struct {
     GMainLoop *mainloop;
     TpDBusDaemon *dbus;
+    TpClientFactory *factory;
 
     /* Service side objects */
     TpBaseClient *simple_approver;
@@ -60,6 +61,7 @@ setup (Test *test,
 
   test->mainloop = g_main_loop_new (NULL, FALSE);
   test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+  test->factory = tp_client_factory_dup (NULL);
 
   test->error = NULL;
 
@@ -153,6 +155,7 @@ teardown (Test *test,
       &test->error);
   g_assert_no_error (test->error);
 
+  g_object_unref (test->factory);
   g_object_unref (test->dbus);
   test->dbus = NULL;
   g_main_loop_unref (test->mainloop);
@@ -184,6 +187,7 @@ create_simple_approver (Test *test,
           "dbus-daemon", test->dbus,
           "bus-name", tp_base_client_get_bus_name (test->simple_approver),
           "object-path", tp_base_client_get_object_path (test->simple_approver),
+          "factory", test->factory,
           NULL);
 
   g_assert (test->client != NULL);
diff --git a/tests/dbus/simple-handler.c b/tests/dbus/simple-handler.c
index 5ac4439..66daaaa 100644
--- a/tests/dbus/simple-handler.c
+++ b/tests/dbus/simple-handler.c
@@ -27,6 +27,7 @@
 typedef struct {
     GMainLoop *mainloop;
     TpDBusDaemon *dbus;
+    TpClientFactory *factory;
 
     /* Service side objects */
     TpBaseClient *simple_handler;
@@ -55,6 +56,7 @@ setup (Test *test,
 
   test->mainloop = g_main_loop_new (NULL, FALSE);
   test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+  test->factory = tp_client_factory_dup (NULL);
 
   test->error = NULL;
 
@@ -145,6 +147,7 @@ teardown (Test *test,
       &test->error);
   g_assert_no_error (test->error);
 
+  g_object_unref (test->factory);
   g_object_unref (test->dbus);
   test->dbus = NULL;
   g_main_loop_unref (test->mainloop);
@@ -185,6 +188,7 @@ create_simple_handler (Test *test,
           "dbus-daemon", test->dbus,
           "bus-name", tp_base_client_get_bus_name (test->simple_handler),
           "object-path", tp_base_client_get_object_path (test->simple_handler),
+          "factory", test->factory,
           NULL);
 
   g_assert (test->client != NULL);
diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c
index 83e045c..f9251e4 100644
--- a/tests/dbus/simple-observer.c
+++ b/tests/dbus/simple-observer.c
@@ -26,6 +26,7 @@
 typedef struct {
     GMainLoop *mainloop;
     TpDBusDaemon *dbus;
+    TpClientFactory *factory;
 
     /* Service side objects */
     TpBaseClient *simple_observer;
@@ -54,6 +55,7 @@ setup (Test *test,
 
   test->mainloop = g_main_loop_new (NULL, FALSE);
   test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+  test->factory = tp_client_factory_dup (NULL);
 
   test->error = NULL;
 
@@ -120,6 +122,7 @@ teardown (Test *test,
       &test->error);
   g_assert_no_error (test->error);
 
+  g_object_unref (test->factory);
   g_object_unref (test->dbus);
   test->dbus = NULL;
   g_main_loop_unref (test->mainloop);
@@ -158,6 +161,7 @@ create_simple_observer (Test *test,
           "dbus-daemon", test->dbus,
           "bus-name", tp_base_client_get_bus_name (test->simple_observer),
           "object-path", tp_base_client_get_object_path (test->simple_observer),
+          "factory", test->factory,
           NULL);
 
   g_assert (test->client != NULL);
diff --git a/tests/lib/simple-channel-request.c b/tests/lib/simple-channel-request.c
index 61be33e..71c0d8f 100644
--- a/tests/lib/simple-channel-request.c
+++ b/tests/lib/simple-channel-request.c
@@ -145,7 +145,7 @@ tp_tests_simple_channel_request_proceed (TpSvcChannelRequest *request,
 {
   TpTestsSimpleChannelRequest *self = SIMPLE_CHANNEL_REQUEST (request);
   TpClient *client;
-  TpDBusDaemon *dbus;
+  TpClientFactory *factory;
   gchar *client_path;
   GHashTable *satisfied, *info;
   TpBaseConnection *base_conn = (TpBaseConnection *) self->priv->conn;
@@ -202,13 +202,14 @@ tp_tests_simple_channel_request_proceed (TpSvcChannelRequest *request,
   client_path = g_strdelimit (g_strdup_printf ("/%s",
         self->priv->preferred_handler), ".", '/');
 
-  dbus = tp_dbus_daemon_dup (NULL);
-  g_assert (dbus != NULL);
+  factory = tp_client_factory_dup (NULL);
+  g_assert (factory != NULL);
 
   client = tp_tests_object_new_static_class (TP_TYPE_CLIENT,
-          "dbus-daemon", dbus,
+          "dbus-daemon", tp_client_factory_get_dbus_daemon (factory),
           "bus-name", self->priv->preferred_handler,
           "object-path", client_path,
+          "factory", factory,
           NULL);
 
   tp_proxy_add_interface_by_id (TP_PROXY (client), TP_IFACE_QUARK_CLIENT);
@@ -237,7 +238,7 @@ tp_tests_simple_channel_request_proceed (TpSvcChannelRequest *request,
   g_hash_table_unref (satisfied);
   g_hash_table_unref (info);
   g_hash_table_unref (chan_props);
-  g_object_unref (dbus);
+  g_object_unref (factory);
   g_object_unref (client);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git



More information about the Pkg-telepathy-commits mailing list