mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
Make the tests not fall over every other time
This commit is contained in:
@@ -94,8 +94,8 @@ typedef struct {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
on_child_termination_exited (GPid pid,
|
on_child_termination_exited (GPid pid,
|
||||||
gint status,
|
gint status,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
AwaitChildTerminationData *data = user_data;
|
AwaitChildTerminationData *data = user_data;
|
||||||
data->child_exited = TRUE;
|
data->child_exited = TRUE;
|
||||||
@@ -113,8 +113,8 @@ on_child_termination_timeout (gpointer user_data)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
await_child_termination_init (AwaitChildTerminationData *data,
|
await_child_termination_init (AwaitChildTerminationData *data,
|
||||||
GPid pid,
|
GPid pid,
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
data->context = g_main_context_get_thread_default ();
|
data->context = g_main_context_get_thread_default ();
|
||||||
data->child_exited = FALSE;
|
data->child_exited = FALSE;
|
||||||
@@ -179,9 +179,9 @@ typedef struct {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
on_run_with_application_name_appeared (GDBusConnection *connection,
|
on_run_with_application_name_appeared (GDBusConnection *connection,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *name_owner,
|
const gchar *name_owner,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
RunWithAppNameAppearedData *data = user_data;
|
RunWithAppNameAppearedData *data = user_data;
|
||||||
|
|
||||||
@@ -282,14 +282,42 @@ test_unique (void)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
on_name_disappeared_quit (GDBusConnection *connection,
|
on_name_disappeared_quit (GDBusConnection *connection,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GMainLoop *loop = user_data;
|
GMainLoop *loop = user_data;
|
||||||
|
|
||||||
g_main_loop_quit (loop);
|
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
|
/* This test starts an application, checks that its name appears on
|
||||||
* the bus, then calls Quit, and verifies that the name disappears and
|
* the bus, then calls Quit, and verifies that the name disappears and
|
||||||
* the application exits.
|
* the application exits.
|
||||||
@@ -299,7 +327,6 @@ test_quit_on_app_appeared (void)
|
|||||||
{
|
{
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
int quit_disappeared_watch;
|
int quit_disappeared_watch;
|
||||||
GDBusConnection *connection;
|
|
||||||
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
quit_disappeared_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
|
quit_disappeared_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
|
||||||
@@ -310,18 +337,11 @@ test_quit_on_app_appeared (void)
|
|||||||
loop,
|
loop,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
/* We need a timeout here, since we may otherwise end up calling
|
||||||
g_dbus_connection_call (connection,
|
* Quit after the application took the name, but before it registered
|
||||||
"org.gtk.test.app",
|
* the object.
|
||||||
"/org/gtk/test/app",
|
*/
|
||||||
"org.gtk.Application",
|
g_timeout_add (500, call_quit, NULL);
|
||||||
"Quit",
|
|
||||||
g_variant_new ("(u)", 0),
|
|
||||||
NULL,
|
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
|
||||||
-1,
|
|
||||||
NULL,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
@@ -367,7 +387,7 @@ list_actions (void)
|
|||||||
"org.gtk.Application",
|
"org.gtk.Application",
|
||||||
"ListActions",
|
"ListActions",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -432,7 +452,7 @@ invoke_action (gpointer user_data)
|
|||||||
g_variant_new ("(su)",
|
g_variant_new ("(su)",
|
||||||
action,
|
action,
|
||||||
0),
|
0),
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -457,12 +477,12 @@ test_invoke (void)
|
|||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
quit_disappeared_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
|
quit_disappeared_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
|
||||||
"org.gtk.test.app",
|
"org.gtk.test.app",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
on_name_disappeared_quit,
|
on_name_disappeared_quit,
|
||||||
loop,
|
loop,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_timeout_add (0, invoke_action, "action1");
|
g_timeout_add (0, invoke_action, "action1");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user