[mutter/gnome-3-34] tests/runner: Move window shown synchronization to helper
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-34] tests/runner: Move window shown synchronization to helper
- Date: Tue, 5 Nov 2019 11:57:16 +0000 (UTC)
commit 8cb0646b62546a37f3a12a9bac2157361fa99686
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Nov 1 13:37:22 2019 +0100
tests/runner: Move window shown synchronization to helper
https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
src/tests/test-runner.c | 46 +-------------------------------------------
src/tests/test-utils.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
src/tests/test-utils.h | 3 +++
3 files changed, 55 insertions(+), 45 deletions(-)
---
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 377b256c2..7560c957e 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -342,39 +342,6 @@ test_case_check_xserver_stacking (TestCase *test,
return *error == NULL;
}
-typedef struct _WaitForShownData
-{
- GMainLoop *loop;
- MetaWindow *window;
- guint shown_handler_id;
-} WaitForShownData;
-
-static void
-on_window_shown (MetaWindow *window,
- WaitForShownData *data)
-{
- g_main_loop_quit (data->loop);
-}
-
-static gboolean
-test_case_wait_for_showing_before_redraw (gpointer user_data)
-{
- WaitForShownData *data = user_data;
-
- if (meta_window_is_hidden (data->window))
- {
- data->shown_handler_id = g_signal_connect (data->window, "shown",
- G_CALLBACK (on_window_shown),
- data);
- }
- else
- {
- g_main_loop_quit (data->loop);
- }
-
- return FALSE;
-}
-
static gboolean
test_case_do (TestCase *test,
int argc,
@@ -533,18 +500,7 @@ test_case_do (TestCase *test,
if (!window)
return FALSE;
- WaitForShownData data = {
- .loop = g_main_loop_new (NULL, FALSE),
- .window = window,
- };
- meta_later_add (META_LATER_BEFORE_REDRAW,
- test_case_wait_for_showing_before_redraw,
- &data,
- NULL);
- g_main_loop_run (data.loop);
- if (data.shown_handler_id)
- g_signal_handler_disconnect (window, data.shown_handler_id);
- g_main_loop_unref (data.loop);
+ test_client_wait_for_window_shown (client, window);
}
else if (strcmp (argv[0], "hide") == 0 ||
strcmp (argv[0], "activate") == 0 ||
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index a42005451..c16ccf8b2 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -359,6 +359,57 @@ test_client_find_window (TestClient *client,
return result;
}
+typedef struct _WaitForShownData
+{
+ GMainLoop *loop;
+ MetaWindow *window;
+ guint shown_handler_id;
+} WaitForShownData;
+
+static void
+on_window_shown (MetaWindow *window,
+ WaitForShownData *data)
+{
+ g_main_loop_quit (data->loop);
+}
+
+static gboolean
+wait_for_showing_before_redraw (gpointer user_data)
+{
+ WaitForShownData *data = user_data;
+
+ if (meta_window_is_hidden (data->window))
+ {
+ data->shown_handler_id = g_signal_connect (data->window, "shown",
+ G_CALLBACK (on_window_shown),
+ data);
+ }
+ else
+ {
+ g_main_loop_quit (data->loop);
+ }
+
+ return FALSE;
+}
+
+void
+test_client_wait_for_window_shown (TestClient *client,
+ MetaWindow *window)
+{
+ WaitForShownData data = {
+ .loop = g_main_loop_new (NULL, FALSE),
+ .window = window,
+ };
+ meta_later_add (META_LATER_BEFORE_REDRAW,
+ wait_for_showing_before_redraw,
+ &data,
+ NULL);
+ g_main_loop_run (data.loop);
+ if (data.shown_handler_id)
+ g_signal_handler_disconnect (window, data.shown_handler_id);
+ g_main_loop_unref (data.loop);
+}
+
gboolean
test_client_alarm_filter (MetaX11Display *x11_display,
XSyncAlarmNotifyEvent *event,
diff --git a/src/tests/test-utils.h b/src/tests/test-utils.h
index e11f25353..2f1a73116 100644
--- a/src/tests/test-utils.h
+++ b/src/tests/test-utils.h
@@ -70,6 +70,9 @@ MetaWindow * test_client_find_window (TestClient *client,
const char *window_id,
GError **error);
+void test_client_wait_for_window_shown (TestClient *client,
+ MetaWindow *window);
+
gboolean test_client_quit (TestClient *client,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]