diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-04-16 16:52:50 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-04-30 19:19:34 +0100 |
commit | ca29a4de02541d24aff6813aa2ac838d5735aeb6 (patch) | |
tree | 994cf1cc7cfe5a03e54e30dfe0c3dbe4660a0263 | |
parent | 3708aa6276e9b8cd398f55875a83851f92a184e5 (diff) |
tp_tests_connection_run_until_contact_by_id: add
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48780
-rw-r--r-- | tests/lib/util.c | 38 | ||||
-rw-r--r-- | tests/lib/util.h | 6 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/lib/util.c b/tests/lib/util.c index f758b4f33..5cb6d2303 100644 --- a/tests/lib/util.c +++ b/tests/lib/util.c @@ -471,3 +471,41 @@ tp_tests_connection_assert_disconnect_succeeds (TpConnection *connection) g_assert (ok); g_object_unref (result); } + +static void +one_contact_cb (TpConnection *connection, + guint n_contacts, + TpContact * const *contacts, + const gchar * const *good_ids, + GHashTable *bad_ids, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + TpContact **contact_loc = user_data; + + g_assert_no_error (error); + g_assert_cmpuint (g_hash_table_size (bad_ids), ==, 0); + g_assert_cmpuint (n_contacts, ==, 1); + g_assert_cmpstr (good_ids[0], !=, NULL); + g_assert (contacts[0] != NULL); + + *contact_loc = g_object_ref (contacts[0]); +} + +TpContact * +tp_tests_connection_run_until_contact_by_id (TpConnection *connection, + const gchar *id, + guint n_features, + const TpContactFeature *features) +{ + TpContact *contact = NULL; + + tp_connection_get_contacts_by_id (connection, 1, &id, n_features, features, + one_contact_cb, &contact, NULL, NULL); + + while (contact == NULL) + g_main_context_iteration (NULL, TRUE); + + return contact; +} diff --git a/tests/lib/util.h b/tests/lib/util.h index d0428ac87..3fccc4c5b 100644 --- a/tests/lib/util.h +++ b/tests/lib/util.h @@ -73,4 +73,10 @@ void _tp_destroy_socket_control_list (gpointer data); void tp_tests_connection_assert_disconnect_succeeds (TpConnection *connection); +TpContact *tp_tests_connection_run_until_contact_by_id ( + TpConnection *connection, + const gchar *id, + guint n_features, + const TpContactFeature *features); + #endif /* #ifndef __TP_TESTS_LIB_UTIL_H__ */ |