summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-09-19 18:21:39 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-09-28 11:32:19 +0100
commitdc460ae72ec2c29f42cf375e7e3366105998d132 (patch)
tree706622240ee8c124b5ff24f755d49c79ab80b1ca
parentd29269cb97cc9d804ca55999487e530c38a12ec6 (diff)
test service: add a “process idle queue” method
-rw-r--r--tests/twisted/mc-debug-server.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/twisted/mc-debug-server.c b/tests/twisted/mc-debug-server.c
index 3bcbc4d0..c1a485fe 100644
--- a/tests/twisted/mc-debug-server.c
+++ b/tests/twisted/mc-debug-server.c
@@ -42,6 +42,7 @@
#include "mcd-service.h"
+TpDBusDaemon *bus_daemon = NULL;
static McdService *mcd = NULL;
static gboolean
@@ -68,6 +69,19 @@ delayed_abort (gpointer data G_GNUC_UNUSED)
return FALSE;
}
+static gboolean
+billy_idle (gpointer user_data)
+{
+ DBusMessage *reply = user_data;
+ DBusConnection *connection = dbus_g_connection_get_connection (
+ ((TpProxy *) bus_daemon)->dbus_connection);
+
+ if (!dbus_connection_send (connection, reply, NULL))
+ g_error ("Out of memory");
+
+ return FALSE;
+}
+
#define MCD_SYSTEM_MEMORY_CONSERVED (1 << 1)
#define MCD_SYSTEM_IDLE (1 << 5)
@@ -156,6 +170,24 @@ dbus_filter_function (DBusConnection *connection,
return DBUS_HANDLER_RESULT_HANDLED;
}
+ else if (dbus_message_is_method_call (message,
+ "org.freedesktop.Telepathy.MissionControl5.RegressionTests",
+ "BillyIdle"))
+ {
+ /* Used to drive a souped-up version of sync_dbus(), where we need to
+ * ensure that all idles have fired, on top of the D-Bus queue being
+ * drained.
+ */
+ DBusMessage *reply = dbus_message_new_method_return (message);
+
+ if (reply == NULL)
+ g_error ("Out of memory");
+
+ g_idle_add_full (G_PRIORITY_LOW, billy_idle, reply,
+ (GDestroyNotify) dbus_message_unref);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -163,7 +195,6 @@ dbus_filter_function (DBusConnection *connection,
int
main (int argc, char **argv)
{
- TpDBusDaemon *bus_daemon = NULL;
GError *error = NULL;
DBusConnection *connection = NULL;
int ret = 1;