From f3f4e29b53f60a725263f0794e6db3e419eca5cb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 5 Mar 2012 20:00:08 +0000 Subject: [PATCH 07/10] Test listing CMs the new way Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46358 Signed-off-by: Simon McVittie --- tests/dbus/cm.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c index ae6bb97..31f4143 100644 --- a/tests/dbus/cm.c +++ b/tests/dbus/cm.c @@ -17,7 +17,8 @@ typedef enum { ACTIVATE_CM = (1 << 0), - USE_CWR = (1 << 1) + USE_CWR = (1 << 1), + USE_OLD_LIST = (1 << 2) } TestFlags; typedef struct { @@ -1060,11 +1061,43 @@ on_listed_connection_managers (TpConnectionManager * const * cms, static void test_list (Test *test, - gconstpointer data G_GNUC_UNUSED) + gconstpointer data) { - tp_list_connection_managers (test->dbus, on_listed_connection_managers, - test, NULL, NULL); - g_main_loop_run (test->mainloop); + TestFlags flags = GPOINTER_TO_INT (data); + + if (flags & USE_OLD_LIST) + { + tp_list_connection_managers (test->dbus, on_listed_connection_managers, + test, NULL, NULL); + g_main_loop_run (test->mainloop); + } + else + { + GAsyncResult *res = NULL; + GList *cms; + + tp_list_connection_managers_async (test->dbus, tp_tests_result_ready_cb, + &res); + tp_tests_run_until_result (&res); + cms = tp_list_connection_managers_finish (res, &test->error); + g_assert_no_error (test->error); + g_assert_cmpuint (g_list_length (cms), ==, 2); + + /* transfer ownership */ + if (tp_connection_manager_is_running (cms->data)) + { + test->echo = cms->data; + test->spurious = cms->next->data; + } + else + { + test->spurious = cms->data; + test->echo = cms->next->data; + } + + g_object_unref (res); + g_list_free (cms); + } g_assert (tp_connection_manager_is_running (test->echo)); g_assert (!tp_connection_manager_is_running (test->spurious)); @@ -1139,7 +1172,10 @@ main (int argc, GINT_TO_POINTER (ACTIVATE_CM | USE_CWR), setup, test_dbus_fallback, teardown); - g_test_add ("/cm/list", Test, NULL, setup, test_list, teardown); + g_test_add ("/cm/list", Test, GINT_TO_POINTER (0), + setup, test_list, teardown); + g_test_add ("/cm/list", Test, GINT_TO_POINTER (USE_OLD_LIST), + setup, test_list, teardown); return g_test_run (); } -- 1.7.9.1