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.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
This commit is contained in:
Carlos Garnacho 2019-11-18 23:12:19 +01:00 committed by Jonas Ådahl
parent 87a06c63ad
commit 21994bb00d
4 changed files with 20 additions and 0 deletions

View File

@ -343,6 +343,8 @@ create_monitor_test_clients (void)
{ {
GError *error = NULL; GError *error = NULL;
test_wait_for_x11_display ();
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display, meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
monitor_tests_alarm_filter, NULL); monitor_tests_alarm_filter, NULL);

View File

@ -66,6 +66,8 @@ test_case_new (void)
{ {
TestCase *test = g_new0 (TestCase, 1); TestCase *test = g_new0 (TestCase, 1);
test_wait_for_x11_display ();
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display, meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
test_case_alarm_filter, test); test_case_alarm_filter, test);

View File

@ -533,3 +533,17 @@ test_get_plugin_name (void)
else else
return "libdefault"; return "libdefault";
} }
void
test_wait_for_x11_display (void)
{
MetaDisplay *display;
display = meta_get_display ();
g_assert_nonnull (display);
while (!display->x11_display)
g_main_context_iteration (NULL, TRUE);
g_assert_nonnull (display->x11_display);
}

View File

@ -84,4 +84,6 @@ void test_client_destroy (TestClient *client);
const char * test_get_plugin_name (void); const char * test_get_plugin_name (void);
void test_wait_for_x11_display (void);
#endif /* TEST_UTILS_H */ #endif /* TEST_UTILS_H */