From 9d8d7e242c3e6edb3e8ceef5fd21e493420615ea Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 19 Sep 2013 19:41:27 +0100 Subject: [PATCH 5/5] connectivity test: make sure we've caught up on GDBus messages Otherwise, the message from the FakeNetworkMonitor saying we've gone offline might not be received until after the message from the fake NM saying we've gone online - which would be a problem. There's no side-effect we can wait for here, so we just have to make sure the GDBus queue has been processed. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69585 --- tests/twisted/account-manager/connectivity.py | 1 + tests/twisted/mc-debug-server.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/twisted/account-manager/connectivity.py b/tests/twisted/account-manager/connectivity.py index a8b6514..8d80c1d 100644 --- a/tests/twisted/account-manager/connectivity.py +++ b/tests/twisted/account-manager/connectivity.py @@ -96,6 +96,7 @@ def test(q, bus, mc): q.expect('dbus-method-call', method='Disconnect') mc.connectivity.go_offline() + sync_connectivity_state(mc) # When we turn the network back on, MC should try to sign us back on. # In the process, our RequestedPresence should not have been diff --git a/tests/twisted/mc-debug-server.c b/tests/twisted/mc-debug-server.c index edbce4b..48f0248 100644 --- a/tests/twisted/mc-debug-server.c +++ b/tests/twisted/mc-debug-server.c @@ -122,10 +122,24 @@ dbus_filter_function (DBusConnection *connection, * drained. */ DBusMessage *reply = dbus_message_new_method_return (message); + GVariant *variant; + GDBusConnection *system_bus; if (reply == NULL) g_error ("Out of memory"); + /* Sync GDBus, too, to make sure we have received any pending + * FakeNetworkMonitor messages. */ + system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); + g_assert (system_bus != NULL); + variant = g_dbus_connection_call_sync (system_bus, + "org.freedesktop.DBus", "/org/freedesktop/DBus", + "org.freedesktop.DBus", "ListNames", + NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + g_assert (variant != NULL); + g_variant_unref (variant); + g_object_unref (system_bus); + g_idle_add_full (G_PRIORITY_LOW, billy_idle, reply, (GDestroyNotify) dbus_message_unref); -- 1.8.4.rc3