Make the tests not fall over every other time

This commit is contained in:
Matthias Clasen
2010-06-11 23:21:49 -04:00
parent 32f2e9a85b
commit 330cdfbdf1

View File

@@ -290,6 +290,34 @@ on_name_disappeared_quit (GDBusConnection *connection,
g_main_loop_quit (loop);
}
static gboolean
call_quit (gpointer data)
{
GDBusConnection *connection;
GError *error = NULL;
GVariant *res;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
res = g_dbus_connection_call_sync (connection,
"org.gtk.test.app",
"/org/gtk/test/app",
"org.gtk.Application",
"Quit",
g_variant_new ("(u)", 0),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
g_assert_no_error (error);
if (res)
g_variant_unref (res);
return FALSE;
}
/* This test starts an application, checks that its name appears on
* the bus, then calls Quit, and verifies that the name disappears and
* the application exits.
@@ -299,7 +327,6 @@ test_quit_on_app_appeared (void)
{
GMainLoop *loop;
int quit_disappeared_watch;
GDBusConnection *connection;
loop = g_main_loop_new (NULL, FALSE);
quit_disappeared_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
@@ -310,18 +337,11 @@ test_quit_on_app_appeared (void)
loop,
NULL);
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
g_dbus_connection_call (connection,
"org.gtk.test.app",
"/org/gtk/test/app",
"org.gtk.Application",
"Quit",
g_variant_new ("(u)", 0),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
NULL, NULL);
/* We need a timeout here, since we may otherwise end up calling
* Quit after the application took the name, but before it registered
* the object.
*/
g_timeout_add (500, call_quit, NULL);
g_main_loop_run (loop);