[Pkg-telepathy-commits] [telepathy-glib-1] 25/212: tests: use GDBus for private connections
Simon McVittie
smcv at debian.org
Wed May 14 12:08:47 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 85ffe5de404a21587f3b3ded12a820ccebee1759
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Mar 11 18:29:18 2014 +0000
tests: use GDBus for private connections
---
tests/dbus/call-cancellation.c | 25 +++++++------------------
tests/dbus/channel-dispatch-operation.c | 28 ++++++----------------------
tests/dbus/channel-request.c | 28 ++++++----------------------
tests/dbus/connection-aliasing.c | 18 +++++-------------
tests/dbus/connection-balance.c | 18 +++++-------------
tests/dbus/connection-interests.c | 27 ++++++++++++---------------
tests/dbus/disconnection.c | 25 +++++++------------------
tests/lib/util.c | 15 +++++++++++++++
tests/lib/util.h | 1 +
9 files changed, 64 insertions(+), 121 deletions(-)
diff --git a/tests/dbus/call-cancellation.c b/tests/dbus/call-cancellation.c
index 3faeb0a..82363d7 100644
--- a/tests/dbus/call-cancellation.c
+++ b/tests/dbus/call-cancellation.c
@@ -1,8 +1,5 @@
#include "config.h"
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <telepathy-glib/cli-misc.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/debug.h>
@@ -52,8 +49,7 @@ typedef struct {
TpProxy *proxies[N_PROXIES];
GObject *cd_service;
- DBusConnection *private_libdbus;
- DBusGConnection *private_dbusglib;
+ GDBusConnection *private_gdbus;
TpDBusDaemon *private_dbus_daemon;
gboolean had_last_reply;
@@ -200,25 +196,18 @@ setup (Fixture *f,
NULL);
tp_dbus_daemon_register_object (f->dbus_daemon, "/", f->cd_service);
- f->private_libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (f->private_libdbus != NULL);
- dbus_connection_setup_with_g_main (f->private_libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (f->private_libdbus, FALSE);
- f->private_dbusglib = dbus_connection_get_g_connection (
- f->private_libdbus);
- dbus_g_connection_ref (f->private_dbusglib);
- f->private_dbus_daemon = tp_dbus_daemon_new (f->private_dbusglib);
+ 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);
}
static void
drop_private_connection (Fixture *f)
{
- dbus_g_connection_unref (f->private_dbusglib);
- f->private_dbusglib = NULL;
- dbus_connection_close (f->private_libdbus);
- dbus_connection_unref (f->private_libdbus);
- f->private_libdbus = NULL;
+ g_dbus_connection_flush_sync (f->private_gdbus, NULL, NULL);
+ g_dbus_connection_close_sync (f->private_gdbus, NULL, NULL);
+ g_clear_object (&f->private_gdbus);
}
static void
diff --git a/tests/dbus/channel-dispatch-operation.c b/tests/dbus/channel-dispatch-operation.c
index 6541e07..e32c3c1 100644
--- a/tests/dbus/channel-dispatch-operation.c
+++ b/tests/dbus/channel-dispatch-operation.c
@@ -35,7 +35,7 @@ typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
- DBusGConnection *private_conn;
+ GDBusConnection *private_conn;
TpDBusDaemon *private_dbus;
TpTestsSimpleChannelDispatchOperation *cdo_service;
TpTestsEchoChannel *text_chan_service;
@@ -54,22 +54,12 @@ static void
setup (Test *test,
gconstpointer data)
{
- DBusConnection *libdbus;
-
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
test->dbus = tp_tests_dbus_daemon_dup_or_die ();
- libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (libdbus != NULL);
- dbus_connection_setup_with_g_main (libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (libdbus, FALSE);
- test->private_conn = dbus_connection_get_g_connection (libdbus);
- /* transfer ref */
- dbus_g_connection_ref (test->private_conn);
- dbus_connection_unref (libdbus);
- g_assert (test->private_conn != NULL);
+ test->private_conn = tp_tests_get_private_bus ();
test->private_dbus = tp_dbus_daemon_new (test->private_conn);
g_assert (test->private_dbus != NULL);
@@ -162,13 +152,9 @@ teardown (Test *test,
test->cdo_service = NULL;
if (test->private_conn != NULL)
- {
- dbus_connection_close (dbus_g_connection_get_connection (
- test->private_conn));
+ g_dbus_connection_close_sync (test->private_conn, NULL, NULL);
- dbus_g_connection_unref (test->private_conn);
- test->private_conn = NULL;
- }
+ g_clear_object (&test->private_conn);
/* make sure any pending things have happened */
tp_tests_proxy_run_until_dbus_queue_processed (test->dbus);
@@ -268,10 +254,8 @@ test_crash (Test *test,
g_assert (tp_proxy_get_invalidated (test->cdo) == NULL);
- dbus_connection_close (dbus_g_connection_get_connection (
- test->private_conn));
- dbus_g_connection_unref (test->private_conn);
- test->private_conn = NULL;
+ g_dbus_connection_close_sync (test->private_conn, NULL, NULL);
+ g_clear_object (&test->private_conn);
while (tp_proxy_get_invalidated (test->cdo) == NULL)
g_main_context_iteration (NULL, TRUE);
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index 762f079..95f1272 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -55,7 +55,7 @@ typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
- DBusGConnection *private_conn;
+ GDBusConnection *private_conn;
TpDBusDaemon *private_dbus;
GObject *cr_service;
@@ -76,23 +76,13 @@ static void
setup (Test *test,
gconstpointer data)
{
- DBusConnection *libdbus;
-
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
test->dbus = tp_tests_dbus_daemon_dup_or_die ();
g_assert (test->dbus != NULL);
- libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (libdbus != NULL);
- dbus_connection_setup_with_g_main (libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (libdbus, FALSE);
- test->private_conn = dbus_connection_get_g_connection (libdbus);
- /* transfer ref */
- dbus_g_connection_ref (test->private_conn);
- dbus_connection_unref (libdbus);
- g_assert (test->private_conn != NULL);
+ test->private_conn = tp_tests_get_private_bus ();
test->private_dbus = tp_dbus_daemon_new (test->private_conn);
g_assert (test->private_dbus != NULL);
@@ -134,13 +124,9 @@ teardown (Test *test,
test->cr_service = NULL;
if (test->private_conn != NULL)
- {
- dbus_connection_close (dbus_g_connection_get_connection (
- test->private_conn));
+ g_dbus_connection_close_sync (test->private_conn, NULL, NULL);
- dbus_g_connection_unref (test->private_conn);
- test->private_conn = NULL;
- }
+ g_clear_object (&test->private_conn);
/* make sure any pending things have happened */
tp_tests_proxy_run_until_dbus_queue_processed (test->dbus);
@@ -223,10 +209,8 @@ test_crash (Test *test,
g_assert (tp_proxy_get_invalidated (test->cr) == NULL);
- dbus_connection_close (dbus_g_connection_get_connection (
- test->private_conn));
- dbus_g_connection_unref (test->private_conn);
- test->private_conn = NULL;
+ g_dbus_connection_close_sync (test->private_conn, NULL, NULL);
+ g_clear_object (&test->private_conn);
while (tp_proxy_get_invalidated (test->cr) == NULL)
g_main_context_iteration (NULL, TRUE);
diff --git a/tests/dbus/connection-aliasing.c b/tests/dbus/connection-aliasing.c
index 0fef4a7..6b51ea6 100644
--- a/tests/dbus/connection-aliasing.c
+++ b/tests/dbus/connection-aliasing.c
@@ -26,8 +26,7 @@
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
- DBusConnection *client_libdbus;
- DBusGConnection *client_dbusglib;
+ GDBusConnection *client_gdbus;
TpDBusDaemon *client_bus;
ExampleContactListConnection *service_conn;
TpBaseConnection *service_conn_as_base;
@@ -55,14 +54,8 @@ setup (Test *test,
test->mainloop = g_main_loop_new (NULL, FALSE);
test->error = NULL;
- test->client_libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (test->client_libdbus != NULL);
- dbus_connection_setup_with_g_main (test->client_libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (test->client_libdbus, FALSE);
- test->client_dbusglib = dbus_connection_get_g_connection (
- test->client_libdbus);
- dbus_g_connection_ref (test->client_dbusglib);
- test->client_bus = tp_dbus_daemon_new (test->client_dbusglib);
+ test->client_gdbus = tp_tests_get_private_bus ();
+ test->client_bus = tp_dbus_daemon_new (test->client_gdbus);
g_assert (test->client_bus != NULL);
test->service_conn = tp_tests_object_new_static_class (
@@ -128,9 +121,8 @@ teardown (Test *test,
g_object_unref (test->client_bus);
test->client_bus = NULL;
- dbus_g_connection_unref (test->client_dbusglib);
- dbus_connection_close (test->client_libdbus);
- dbus_connection_unref (test->client_libdbus);
+ g_dbus_connection_close_sync (test->client_gdbus, NULL, NULL);
+ g_object_unref (test->client_gdbus);
}
static void
diff --git a/tests/dbus/connection-balance.c b/tests/dbus/connection-balance.c
index bf39782..2104af5 100644
--- a/tests/dbus/connection-balance.c
+++ b/tests/dbus/connection-balance.c
@@ -181,8 +181,7 @@ unbalanced_connection_class_init (UnbalancedConnectionClass *cls)
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
- DBusConnection *client_libdbus;
- DBusGConnection *client_dbusglib;
+ GDBusConnection *client_gdbus;
TpDBusDaemon *client_bus;
TpTestsSimpleConnection *service_conn;
TpBaseConnection *service_conn_as_base;
@@ -211,14 +210,8 @@ setup (Test *test,
test->mainloop = g_main_loop_new (NULL, FALSE);
test->error = NULL;
- test->client_libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (test->client_libdbus != NULL);
- dbus_connection_setup_with_g_main (test->client_libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (test->client_libdbus, FALSE);
- test->client_dbusglib = dbus_connection_get_g_connection (
- test->client_libdbus);
- dbus_g_connection_ref (test->client_dbusglib);
- test->client_bus = tp_dbus_daemon_new (test->client_dbusglib);
+ test->client_gdbus = tp_tests_get_private_bus ();
+ test->client_bus = tp_dbus_daemon_new (test->client_gdbus);
g_assert (test->client_bus != NULL);
test->service_conn = tp_tests_object_new_static_class (
@@ -284,9 +277,8 @@ teardown (Test *test,
g_object_unref (test->client_bus);
test->client_bus = NULL;
- dbus_g_connection_unref (test->client_dbusglib);
- dbus_connection_close (test->client_libdbus);
- dbus_connection_unref (test->client_libdbus);
+ g_dbus_connection_close_sync (test->client_gdbus, NULL, NULL);
+ g_object_unref (test->client_gdbus);
}
static void
diff --git a/tests/dbus/connection-interests.c b/tests/dbus/connection-interests.c
index f0dbaa1..3b96674 100644
--- a/tests/dbus/connection-interests.c
+++ b/tests/dbus/connection-interests.c
@@ -79,8 +79,7 @@ interested_connection_class_init (InterestedConnectionClass *cls)
typedef struct {
TpDBusDaemon *dbus;
- DBusConnection *client_libdbus;
- DBusGConnection *client_dbusglib;
+ GDBusConnection *client_gdbus;
TpDBusDaemon *client_bus;
TpTestsSimpleConnection *service_conn;
TpBaseConnection *service_conn_as_base;
@@ -154,14 +153,8 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->dbus = tp_tests_dbus_daemon_dup_or_die ();
- test->client_libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (test->client_libdbus != NULL);
- dbus_connection_setup_with_g_main (test->client_libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (test->client_libdbus, FALSE);
- test->client_dbusglib = dbus_connection_get_g_connection (
- test->client_libdbus);
- dbus_g_connection_ref (test->client_dbusglib);
- test->client_bus = tp_dbus_daemon_new (test->client_dbusglib);
+ test->client_gdbus = tp_tests_get_private_bus ();
+ test->client_bus = tp_dbus_daemon_new (test->client_gdbus);
g_assert (test->client_bus != NULL);
test->service_conn = tp_tests_object_new_static_class (
@@ -252,9 +245,11 @@ teardown (Test *test,
g_object_unref (test->client_bus);
test->client_bus = NULL;
- dbus_g_connection_unref (test->client_dbusglib);
- dbus_connection_close (test->client_libdbus);
- dbus_connection_unref (test->client_libdbus);
+ if (test->client_gdbus != NULL)
+ {
+ g_dbus_connection_close_sync (test->client_gdbus, NULL, NULL);
+ g_object_unref (test->client_gdbus);
+ }
g_ptr_array_unref (test->log);
}
@@ -348,8 +343,10 @@ test_interest (Test *test,
/* we auto-release the Location client interest by dropping the client
* connection */
- dbus_connection_flush (test->client_libdbus);
- dbus_connection_close (test->client_libdbus);
+ g_dbus_connection_flush_sync (test->client_gdbus, NULL, NULL);
+ g_dbus_connection_close_sync (test->client_gdbus, NULL, NULL);
+ g_object_unref (test->client_gdbus);
+ test->client_gdbus = NULL;
while (test->log->len < 6)
g_main_context_iteration (NULL, TRUE);
diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c
index 9dc3db0..143ce85 100644
--- a/tests/dbus/disconnection.c
+++ b/tests/dbus/disconnection.c
@@ -1,8 +1,5 @@
#include "config.h"
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <telepathy-glib/cli-misc.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/debug.h>
@@ -44,8 +41,7 @@ typedef struct {
TpProxy *proxies[N_PROXIES];
GObject *cd_service;
- DBusConnection *private_libdbus;
- DBusGConnection *private_dbusglib;
+ GDBusConnection *private_gdbus;
TpDBusDaemon *private_dbus_daemon;
} Fixture;
@@ -158,25 +154,18 @@ setup (Fixture *f,
NULL);
tp_dbus_daemon_register_object (f->dbus_daemon, "/", f->cd_service);
- f->private_libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
- g_assert (f->private_libdbus != NULL);
- dbus_connection_setup_with_g_main (f->private_libdbus, NULL);
- dbus_connection_set_exit_on_disconnect (f->private_libdbus, FALSE);
- f->private_dbusglib = dbus_connection_get_g_connection (
- f->private_libdbus);
- dbus_g_connection_ref (f->private_dbusglib);
- f->private_dbus_daemon = tp_dbus_daemon_new (f->private_dbusglib);
+ 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);
}
static void
drop_private_connection (Fixture *f)
{
- dbus_g_connection_unref (f->private_dbusglib);
- f->private_dbusglib = NULL;
- dbus_connection_close (f->private_libdbus);
- dbus_connection_unref (f->private_libdbus);
- f->private_libdbus = NULL;
+ g_dbus_connection_flush_sync (f->private_gdbus, NULL, NULL);
+ g_dbus_connection_close_sync (f->private_gdbus, NULL, NULL);
+ g_clear_object (&f->private_gdbus);
}
static void
diff --git a/tests/lib/util.c b/tests/lib/util.c
index f0ac870..b8fd1dc 100644
--- a/tests/lib/util.c
+++ b/tests/lib/util.c
@@ -801,3 +801,18 @@ _tp_tests_await_last_unref (gpointer obj,
obj = g_weak_ref_get (&weak);
}
}
+
+GDBusConnection *
+tp_tests_get_private_bus (void)
+{
+ GDBusConnection *ret;
+ GError *error = NULL;
+
+ ret = g_dbus_connection_new_for_address_sync (
+ g_getenv ("DBUS_SESSION_BUS_ADDRESS"),
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+ G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+ NULL, NULL, &error);
+ g_assert_no_error (error);
+ return ret;
+}
diff --git a/tests/lib/util.h b/tests/lib/util.h
index fbfb8f8..304c3a5 100644
--- a/tests/lib/util.h
+++ b/tests/lib/util.h
@@ -138,5 +138,6 @@ void _tp_tests_assert_last_unref (gpointer obj,
const gchar *file,
int line);
+GDBusConnection *tp_tests_get_private_bus (void);
#endif /* #ifndef __TP_TESTS_LIB_UTIL_H__ */
--
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