[mutter] tests/test-runner: Hook up async waiter on demand
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/test-runner: Hook up async waiter on demand
- Date: Mon, 25 Jan 2021 15:35:37 +0000 (UTC)
commit 02859221eab2e911ac6d7ce72555f8bba313db36
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Jan 21 18:58:28 2021 +0100
tests/test-runner: Hook up async waiter on demand
Not all tests will spawn Xwayland; so don't expect it to be there.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
src/core/main-private.h | 1 +
src/tests/test-runner.c | 45 ++++++++++++++++++++++++++++++++++++---------
2 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/src/core/main-private.h b/src/core/main-private.h
index 210fe6289d..d6d28facb3 100644
--- a/src/core/main-private.h
+++ b/src/core/main-private.h
@@ -49,6 +49,7 @@ META_EXPORT_TEST
void meta_override_compositor_configuration (MetaCompositorType compositor_type,
GType backend_gtype);
+META_EXPORT_TEST
MetaDisplayPolicy meta_get_x11_display_policy (void);
META_EXPORT_TEST
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 65fa546825..d85beab050 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -25,6 +25,7 @@
#include <string.h>
#include "compositor/meta-plugin-manager.h"
+#include "core/main-private.h"
#include "core/window-private.h"
#include "meta/main.h"
#include "meta/util.h"
@@ -61,18 +62,37 @@ test_case_alarm_filter (MetaX11Display *x11_display,
return FALSE;
}
+static void
+on_x11_display_opened (MetaDisplay *display,
+ TestCase *test)
+{
+ meta_x11_display_set_alarm_filter (display->x11_display,
+ test_case_alarm_filter, test);
+ test->waiter = async_waiter_new ();
+}
+
static TestCase *
test_case_new (void)
{
TestCase *test = g_new0 (TestCase, 1);
+ MetaDisplay *display = meta_get_display ();
- test_wait_for_x11_display ();
-
- meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
- test_case_alarm_filter, test);
+ if (meta_get_x11_display_policy () == META_DISPLAY_POLICY_MANDATORY)
+ {
+ test_wait_for_x11_display ();
+ on_x11_display_opened (display, test);
+ }
+ else
+ {
+ if (display->x11_display)
+ on_x11_display_opened (display, test);
+ else
+ g_signal_connect (meta_get_display (), "x11-display-opened",
+ G_CALLBACK (on_x11_display_opened),
+ test);
+ }
test->clients = g_hash_table_new (g_str_hash, g_str_equal);
- test->waiter = async_waiter_new ();
test->loop = g_main_loop_new (NULL, FALSE);
return test;
@@ -129,7 +149,8 @@ test_case_wait (TestCase *test,
* we receive the resulting event - this makes sure that we've
* received back any X events we generated.
*/
- async_waiter_set_and_wait (test->waiter);
+ if (test->waiter)
+ async_waiter_set_and_wait (test->waiter);
return TRUE;
}
@@ -324,6 +345,9 @@ test_case_check_xserver_stacking (TestCase *test,
GString *x11_string = g_string_new (NULL);
int i;
+ if (!display->x11_display)
+ return TRUE;
+
guint64 *windows;
int n_windows;
meta_stack_tracker_get_stack (display->stack_tracker, &windows, &n_windows);
@@ -880,10 +904,13 @@ test_case_destroy (TestCase *test,
while (g_hash_table_iter_next (&iter, &key, &value))
test_client_destroy (value);
- async_waiter_destroy (test->waiter);
+ g_clear_pointer (&test->waiter, async_waiter_destroy);
- meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
- NULL, NULL);
+ if (meta_get_display ()->x11_display)
+ {
+ meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
+ NULL, NULL);
+ }
g_hash_table_destroy (test->clients);
g_free (test);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]