[mutter/wip/carlosg/xwayland-startup-side-channel: 1/7] tests: Ensure MetaX11Display is initialized before running tests
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/xwayland-startup-side-channel: 1/7] tests: Ensure MetaX11Display is initialized before running tests
- Date: Tue, 19 Nov 2019 19:07:19 +0000 (UTC)
commit 85e775b73784cb19425c9a717693055fad6d5b8d
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Nov 18 23:12:19 2019 +0100
tests: Ensure MetaX11Display is initialized before running tests
It might not be available right on initialization time if X11 is started
asynchronously. As this is a requirement for our tests, ensure it is there
before proceeding with the test.
src/tests/monitor-unit-tests.c | 2 ++
src/tests/test-runner.c | 9 +++++++++
src/tests/test-utils.c | 17 +++++++++++++++++
src/tests/test-utils.h | 2 ++
4 files changed, 30 insertions(+)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index b498d899f..7a0c4b1b6 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -342,6 +342,8 @@ create_monitor_test_clients (void)
{
GError *error = NULL;
+ test_wait_for_x11_display ();
+
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
monitor_tests_alarm_filter, NULL);
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 7560c957e..d09d0abe6 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -61,11 +61,20 @@ test_case_alarm_filter (MetaX11Display *x11_display,
return FALSE;
}
+static void
+wait_for_x11_display (MetaDisplay *display)
+{
+ while (!display->x11_display)
+ g_main_context_iteration (NULL, TRUE);
+}
+
static TestCase *
test_case_new (void)
{
TestCase *test = g_new0 (TestCase, 1);
+ wait_for_x11_display (meta_get_display ());
+
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
test_case_alarm_filter, test);
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index c16ccf8b2..4cf0beff1 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -534,3 +534,20 @@ test_get_plugin_name (void)
else
return "libdefault";
}
+
+void
+test_wait_for_x11_display (void)
+{
+ MetaDisplay *display;
+
+ display = meta_get_display ();
+ g_assert_nonnull (display);
+
+ if (display->x11_display)
+ return;
+
+ while (!display->x11_display)
+ g_main_context_iteration (NULL, TRUE);
+
+ g_assert_nonnull (display->x11_display);
+}
diff --git a/src/tests/test-utils.h b/src/tests/test-utils.h
index 2f1a73116..1710b98e0 100644
--- a/src/tests/test-utils.h
+++ b/src/tests/test-utils.h
@@ -84,4 +84,6 @@ void test_client_destroy (TestClient *client);
const char * test_get_plugin_name (void);
+void test_wait_for_x11_display (void);
+
#endif /* TEST_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]