diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-02-02 14:45:40 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-02-02 14:45:40 +0000 |
commit | c7dd8c43243aaa0a10006838c7caa8d995805189 (patch) | |
tree | c4b65554ff48ccee7c08d5e98f1f89fb4fa719e9 | |
parent | 1d8fdd8e39ed535a8d8136c90c592c94b2ce09be (diff) |
Use tp_tests_proxy_run_until_prepared in simple caseswip-run-until-prepared
-rw-r--r-- | tests/dbus/account.c | 39 | ||||
-rw-r--r-- | tests/dbus/contact-list-client.c | 21 | ||||
-rw-r--r-- | tests/dbus/proxy-preparation.c | 80 | ||||
-rw-r--r-- | tests/dbus/text-channel.c | 42 |
4 files changed, 30 insertions, 152 deletions
diff --git a/tests/dbus/account.c b/tests/dbus/account.c index a475549c7..b7b92a062 100644 --- a/tests/dbus/account.c +++ b/tests/dbus/account.c @@ -290,20 +290,6 @@ test_reconnect (Test *test, tp_clear_object (&test->result); } -static void -account_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - Test *test = user_data; - GError *error = NULL; - - tp_proxy_prepare_finish (source, result, &error); - g_assert_no_error (error); - - g_main_loop_quit (test->mainloop); -} - #define assert_strprop(self, prop, val) \ {\ gchar *s; \ @@ -346,9 +332,7 @@ test_prepare_success (Test *test, test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL); g_assert (test->account != NULL); - tp_proxy_prepare_async (test->account, account_features, - account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, account_features); /* the obvious accessors */ g_assert (tp_account_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); @@ -469,8 +453,7 @@ test_storage (Test *test, if (g_str_equal (mode, "later")) { /* prepare the core feature first */ - tp_proxy_prepare_async (test->account, NULL, account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, NULL); /* storage stuff doesn't work yet */ g_assert_cmpstr (tp_account_get_storage_provider (test->account), ==, @@ -487,9 +470,7 @@ test_storage (Test *test, } /* prepare the storage feature */ - tp_proxy_prepare_async (test->account, account_features, - account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, account_features); g_assert_cmpstr (tp_account_get_storage_provider (test->account), ==, "org.freedesktop.Telepathy.glib.test"); @@ -541,8 +522,7 @@ test_addressing (Test *test, if (g_str_equal (mode, "later")) { /* prepare the core feature first */ - tp_proxy_prepare_async (test->account, NULL, account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, NULL); /* addressing stuff doesn't work yet */ g_assert (tp_account_get_uri_schemes (test->account) == NULL); @@ -555,9 +535,7 @@ test_addressing (Test *test, } /* prepare the addressing feature */ - tp_proxy_prepare_async (test->account, account_features, - account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, account_features); schemes = tp_account_get_uri_schemes (test->account); g_assert (schemes != NULL); @@ -584,8 +562,7 @@ test_avatar (Test *test, test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL); g_assert (test->account != NULL); - tp_proxy_prepare_async (test->account, NULL, account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, NULL); tp_account_get_avatar_async (test->account, tp_tests_result_ready_cb, &test->result); @@ -613,9 +590,7 @@ test_connection (Test *test, test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL); g_assert (test->account != NULL); - tp_proxy_prepare_async (test->account, account_features, - account_prepare_cb, test); - g_main_loop_run (test->mainloop); + tp_tests_proxy_run_until_prepared (test->account, account_features); g_assert (tp_account_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); diff --git a/tests/dbus/contact-list-client.c b/tests/dbus/contact-list-client.c index dcbe21226..75f022e02 100644 --- a/tests/dbus/contact-list-client.c +++ b/tests/dbus/contact-list-client.c @@ -238,12 +238,7 @@ test_can_report_abusive (Test *test, g_assert (!abuse); g_assert (!tp_connection_can_report_abusive (test->connection)); - tp_proxy_prepare_async (test->connection, features, - proxy_prepare_cb, test); - - test->wait = 1; - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->connection, features); g_assert (tp_proxy_is_prepared (test->connection, TP_CONNECTION_FEATURE_CONTACT_BLOCKING)); @@ -291,12 +286,7 @@ test_blocked_contacts (Test *test, g_assert_cmpuint (blocked->len, == , 0); /* Prepare the feature */ - tp_proxy_prepare_async (test->connection, features, - proxy_prepare_cb, test); - - test->wait = 1; - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->connection, features); /* 2 contacts are already blocked in the CM */ g_object_get (test->connection, "blocked-contacts", &blocked, NULL); @@ -526,12 +516,7 @@ test_contact_list_properties (Test *test, g_assert (!tp_connection_get_can_change_contact_list (test->connection)); g_assert (!tp_connection_get_request_uses_message (test->connection)); - tp_proxy_prepare_async (test->connection, conn_features, - proxy_prepare_cb, test); - - test->wait = 1; - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->connection, conn_features); g_assert (tp_proxy_is_prepared (test->connection, TP_CONNECTION_FEATURE_CONTACT_LIST) == !props_only); diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c index cf8828adf..7b12e36f5 100644 --- a/tests/dbus/proxy-preparation.c +++ b/tests/dbus/proxy-preparation.c @@ -26,7 +26,6 @@ typedef struct { TpTestsMyConnProxy *my_conn; GError *error /* initialized where needed */; - gint wait; } Test; static void @@ -75,20 +74,6 @@ teardown (Test *test, } static void -prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - Test *test = user_data; - - tp_proxy_prepare_finish (TP_PROXY (source), result, &test->error); - - test->wait--; - if (test->wait <= 0) - g_main_loop_quit (test->mainloop); -} - -static void test_prepare_capabilities (Test *test, gconstpointer data G_GNUC_UNUSED) { @@ -97,10 +82,7 @@ test_prepare_capabilities (Test *test, * tp_proxy_has_interface_by_id() can't work without CORE. */ GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_CONNECTION_FEATURE_CORE)); g_assert (tp_proxy_is_prepared (test->my_conn, @@ -115,10 +97,7 @@ test_prepare_core (Test *test, * features as well */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_CORE, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -135,10 +114,7 @@ test_depends (Test *test, /* Test if A is automatically prepared when preparing B */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_B, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -156,10 +132,7 @@ test_wrong_iface (Test *test, * interface */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_WRONG_IFACE, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -175,10 +148,7 @@ test_bad_dep (Test *test, * feature */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_BAD_DEP, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -195,10 +165,7 @@ test_fail (Test *test, /* Feature preparation fails */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_FAIL, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -213,10 +180,7 @@ test_fail_dep (Test *test, /* Feature can't be prepared because its deps can't be prepared */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_FAIL_DEP, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -233,10 +197,7 @@ test_retry (Test *test, /* We have the prepare the feature twice */ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_RETRY, 0 }; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -245,10 +206,7 @@ test_retry (Test *test, /* second attempt */ test->my_conn->retry_feature_success = TRUE; - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -266,10 +224,7 @@ test_retry_dep (Test *test, GQuark features_retry_dep[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_RETRY_DEP, 0 }; /* Try preparing TP_TESTS_MY_CONN_PROXY_FEATURE_RETRY, will fail */ - tp_proxy_prepare_async (test->my_conn, features_retry, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features_retry); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -281,10 +236,7 @@ test_retry_dep (Test *test, /* Try prepare TP_TESTS_MY_CONN_PROXY_FEATURE_RETRY_DEP, will re-prepare * TP_TESTS_MY_CONN_PROXY_FEATURE_RETRY */ test->my_conn->retry_feature_success = TRUE; - tp_proxy_prepare_async (test->my_conn, features_retry_dep, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features_retry_dep); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); @@ -342,10 +294,7 @@ test_before_connected (Test *test, BEFORE_CONNECTED_STATE_UNPREPARED); /* Connection is not yet connected, prepare the feature */ - tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, features); g_assert (tp_proxy_is_prepared (test->my_conn, TP_TESTS_MY_CONN_PROXY_FEATURE_BEFORE_CONNECTED)); @@ -356,10 +305,7 @@ test_before_connected (Test *test, tp_cli_connection_call_connect (test->connection, -1, NULL, NULL, NULL, NULL); /* Wait that CONNECTED is announced */ - tp_proxy_prepare_async (test->my_conn, connected, prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->my_conn, connected); /* state has been updated */ g_assert_cmpuint (test->my_conn->before_connected_state, ==, diff --git a/tests/dbus/text-channel.c b/tests/dbus/text-channel.c index 8b0f34f20..ec6dc397b 100644 --- a/tests/dbus/text-channel.c +++ b/tests/dbus/text-channel.c @@ -330,11 +330,7 @@ test_pending_messages (Test *test, g_assert_cmpuint (g_list_length (messages), ==, 0); g_list_free (messages); - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); g_assert (tp_proxy_is_prepared (test->channel, TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES)); @@ -393,11 +389,7 @@ test_message_received (Test *test, /* We have to prepare the pending messages feature to be notified about * incoming messages */ - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); g_signal_connect (test->channel, "message-received", G_CALLBACK (message_received_cb), test); @@ -468,11 +460,7 @@ test_ack_messages (Test *test, g_main_loop_run (test->mainloop); g_assert_no_error (test->error); - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); messages = tp_text_channel_get_pending_messages (test->channel); g_assert_cmpuint (g_list_length (messages), ==, 2); @@ -527,11 +515,7 @@ test_ack_message (Test *test, GList *messages; TpMessage *msg; - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); g_signal_connect (test->channel, "message-received", G_CALLBACK (message_received_cb), test); @@ -766,11 +750,7 @@ test_ack_all_pending_messages (Test *test, g_main_loop_run (test->mainloop); g_assert_no_error (test->error); - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); messages = tp_text_channel_get_pending_messages (test->channel); g_assert_cmpuint (g_list_length (messages), ==, 2); @@ -812,11 +792,7 @@ test_pending_messages_with_no_sender_id (Test *test, tp_asv_get_string (tp_message_peek (cm_message, 0), "message-sender-id")); tp_message_mixin_take_received (G_OBJECT (test->chan_service), cm_message); - test->wait = 1; - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); messages = tp_text_channel_get_pending_messages (test->channel); g_assert (messages != NULL); @@ -933,11 +909,7 @@ test_receive_muc_delivery (Test *test, /* We have to prepare the pending messages feature to be notified about * incoming messages */ - tp_proxy_prepare_async (test->channel, features, - proxy_prepare_cb, test); - - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); + tp_tests_proxy_run_until_prepared (test->channel, features); g_signal_connect (test->channel, "message-received", G_CALLBACK (message_received_cb), test); |