From 337ade622ce859ec7a7618365ba91ae356153109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 27 Jan 2023 20:49:40 +0100 Subject: [PATCH] tests/wayland-test-utils: Add helper to wait for window Part-of: --- src/tests/meta-wayland-test-utils.c | 16 ++++++++++++++++ src/tests/meta-wayland-test-utils.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/tests/meta-wayland-test-utils.c b/src/tests/meta-wayland-test-utils.c index 860372986..0c1f4bf02 100644 --- a/src/tests/meta-wayland-test-utils.c +++ b/src/tests/meta-wayland-test-utils.c @@ -135,3 +135,19 @@ meta_find_client_window (MetaContext *context, return NULL; } + +MetaWindow * +meta_wait_for_client_window (MetaContext *context, + const char *title) +{ + while (TRUE) + { + MetaWindow *window; + + window = meta_find_client_window (context, title); + if (window) + return window; + + g_main_context_iteration (NULL, TRUE); + } +} diff --git a/src/tests/meta-wayland-test-utils.h b/src/tests/meta-wayland-test-utils.h index 4983ab01d..3422b5d21 100644 --- a/src/tests/meta-wayland-test-utils.h +++ b/src/tests/meta-wayland-test-utils.h @@ -30,4 +30,7 @@ void meta_wayland_test_client_finish (MetaWaylandTestClient *wayland_test_client MetaWindow * meta_find_client_window (MetaContext *context, const char *title); +MetaWindow * meta_wait_for_client_window (MetaContext *context, + const char *title); + #endif /* META_WAYLAND_TEST_UTILS_H */