From 24cf83a38684597b0fb740d537dced208e53c76b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 24 Apr 2012 13:12:09 +0100 Subject: [PATCH 06/11] test_run_until_round_trip: add --- test/lib/util.c | 25 +++++++++++++++++++++++++ test/lib/util.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/test/lib/util.c b/test/lib/util.c index d0482fa..064bfda 100644 --- a/test/lib/util.c +++ b/test/lib/util.c @@ -77,3 +77,28 @@ _test_assert_no_error (const DBusError *e, g_error ("%s:%d: expected success but got error: %s: %s", file, line, e->name, e->message); } + +void test_run_until_round_trip (DBusGConnection *connection, + GMainContext *context) +{ + DBusConnection *libdbus; + gboolean mem; + DBusMessage *call; + DBusPendingCall *pc; + + /* To avoid side-effects, we make the call directly with libdbus. */ + libdbus = dbus_g_connection_get_connection (connection); + + call = dbus_message_new_method_call (dbus_bus_get_unique_name (libdbus), + "/", "org.freedesktop.DBus.Peer", "Ping"); + g_assert (call != NULL); + mem = dbus_connection_send_with_reply (libdbus, call, &pc, -1); + dbus_message_unref (call); + g_assert (mem); + g_assert (pc != NULL); + + while (!dbus_pending_call_get_completed (pc)) + g_main_context_iteration (context, TRUE); + + dbus_pending_call_unref (pc); +} diff --git a/test/lib/util.h b/test/lib/util.h index bafa01c..281c7ae 100644 --- a/test/lib/util.h +++ b/test/lib/util.h @@ -34,4 +34,7 @@ void _test_assert_no_error (const DBusError *e, const char *file, int line); +void test_run_until_round_trip (DBusGConnection *connection, + GMainContext *context); + #endif -- 1.8.4.rc3