telepathy-glib: tp_tests_connection_run_until_contact_by_id: add
Simon McVittie
smcv at kemper.freedesktop.org
Mon Apr 30 11:57:29 PDT 2012
Module: telepathy-glib
Branch: master
Commit: ca29a4de02541d24aff6813aa2ac838d5735aeb6
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=ca29a4de02541d24aff6813aa2ac838d5735aeb6
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Mon Apr 16 16:52:50 2012 +0100
tp_tests_connection_run_until_contact_by_id: add
Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48780
---
tests/lib/util.c | 38 ++++++++++++++++++++++++++++++++++++++
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 f758b4f..5cb6d23 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 d0428ac..3fccc4c 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__ */
More information about the telepathy-commits
mailing list