From 9856dac5935796fb5976b4028d209a07b7228290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 27 Jan 2023 20:49:11 +0100 Subject: [PATCH] tests/wayland: Move out window finder helper to helper file Part-of: --- src/tests/meta-wayland-test-utils.c | 21 +++++++++++++++++++++ src/tests/meta-wayland-test-utils.h | 3 +++ src/tests/wayland-unit-tests.c | 15 +-------------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/tests/meta-wayland-test-utils.c b/src/tests/meta-wayland-test-utils.c index 61250a5cc..860372986 100644 --- a/src/tests/meta-wayland-test-utils.c +++ b/src/tests/meta-wayland-test-utils.c @@ -21,6 +21,7 @@ #include +#include "core/display-private.h" #include "wayland/meta-wayland.h" struct _MetaWaylandTestClient @@ -114,3 +115,23 @@ meta_wayland_test_client_finish (MetaWaylandTestClient *wayland_test_client) g_object_unref (wayland_test_client->subprocess); g_free (wayland_test_client); } + +MetaWindow * +meta_find_client_window (MetaContext *context, + const char *title) +{ + MetaDisplay *display = meta_context_get_display (context); + g_autoptr (GSList) windows = NULL; + GSList *l; + + windows = meta_display_list_windows (display, META_LIST_DEFAULT); + for (l = windows; l; l = l->next) + { + MetaWindow *window = l->data; + + if (g_strcmp0 (meta_window_get_title (window), title) == 0) + return window; + } + + return NULL; +} diff --git a/src/tests/meta-wayland-test-utils.h b/src/tests/meta-wayland-test-utils.h index 791384011..4983ab01d 100644 --- a/src/tests/meta-wayland-test-utils.h +++ b/src/tests/meta-wayland-test-utils.h @@ -27,4 +27,7 @@ MetaWaylandTestClient * meta_wayland_test_client_new (MetaContext *context, void meta_wayland_test_client_finish (MetaWaylandTestClient *wayland_test_client); +MetaWindow * meta_find_client_window (MetaContext *context, + const char *title); + #endif /* META_WAYLAND_TEST_UTILS_H */ diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c index 89c39e5e7..ab5b8a54f 100644 --- a/src/tests/wayland-unit-tests.c +++ b/src/tests/wayland-unit-tests.c @@ -44,20 +44,7 @@ static ClutterVirtualInputDevice *virtual_pointer; static MetaWindow * find_client_window (const char *title) { - MetaDisplay *display = meta_context_get_display (test_context); - g_autoptr (GSList) windows = NULL; - GSList *l; - - windows = meta_display_list_windows (display, META_LIST_DEFAULT); - for (l = windows; l; l = l->next) - { - MetaWindow *window = l->data; - - if (g_strcmp0 (meta_window_get_title (window), title) == 0) - return window; - } - - return NULL; + return meta_find_client_window (test_context, title); } static void