From ed637f63c1d12e9664c7d6df5cfd0c4ee418ade5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 3 May 2024 14:30:14 +0200 Subject: [PATCH] tests/wayland: Add test for mapping clone of obstructed window Part-of: (cherry picked from commit 52d5758f1b91b0130c9df24253c8ef128f57aeb8) --- .../xdg-toplevel-suspended.c | 36 +++++++++++++++++++ src/tests/wayland-unit-tests.c | 22 ++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/tests/wayland-test-clients/xdg-toplevel-suspended.c b/src/tests/wayland-test-clients/xdg-toplevel-suspended.c index 4e58d2674..59f57e3d4 100644 --- a/src/tests/wayland-test-clients/xdg-toplevel-suspended.c +++ b/src/tests/wayland-test-clients/xdg-toplevel-suspended.c @@ -27,6 +27,7 @@ enum XDG_TOPLEVEL_SUSPENDED_COMMAND_NEXT_WORKSPACE = 0, XDG_TOPLEVEL_SUSPENDED_COMMAND_PREV_WORKSPACE = 1, XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW = 2, + XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE = 3, }; static void @@ -155,6 +156,40 @@ test_obstructed (WaylandDisplay *display) wait_for_no_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED); } +static void +test_obstructed_clone (WaylandDisplay *display) +{ + g_autoptr (WaylandSurface) surface = NULL; + g_autoptr (WaylandSurface) cover_surface = NULL; + + g_debug ("Testing suspended state when mapping a clone of an obstructed " + "window"); + + surface = wayland_surface_new (display, __func__, 100, 100, 0xffffffff); + wl_surface_commit (surface->wl_surface); + + wait_for_window_shown (display, surface->wl_surface); + g_assert_false (wayland_surface_has_state (surface, + XDG_TOPLEVEL_STATE_SUSPENDED)); + + cover_surface = wayland_surface_new (display, "obstruction", + 100, 100, 0xffffffff); + xdg_toplevel_set_maximized (cover_surface->xdg_toplevel); + wl_surface_commit (cover_surface->wl_surface); + + wait_for_window_shown (display, cover_surface->wl_surface); + test_driver_sync_point (display->test_driver, + XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW, + cover_surface->wl_surface); + + wait_for_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED); + + test_driver_sync_point (display->test_driver, + XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE, + surface->wl_surface); + wait_for_no_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED); +} + int main (int argc, char **argv) @@ -170,6 +205,7 @@ main (int argc, test_minimized (display); test_workspace_changes (display); test_obstructed (display); + test_obstructed_clone (display); return EXIT_SUCCESS; } diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c index 681968da2..f9ba97149 100644 --- a/src/tests/wayland-unit-tests.c +++ b/src/tests/wayland-unit-tests.c @@ -873,6 +873,7 @@ enum XDG_TOPLEVEL_SUSPENDED_COMMAND_NEXT_WORKSPACE = 0, XDG_TOPLEVEL_SUSPENDED_COMMAND_PREV_WORKSPACE = 1, XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW = 2, + XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE = 3, }; static void @@ -914,6 +915,27 @@ on_toplevel_suspended_sync_point (MetaWaylandTestDriver *test_driver, now_ms = meta_display_get_current_time_roundtrip (display); meta_window_activate (meta_wayland_surface_get_window (surface), now_ms); break; + case XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE: + { + MetaBackend *backend = meta_context_get_backend (test_context); + ClutterActor *stage = meta_backend_get_stage (backend); + MetaWindow *window; + MetaWindowActor *window_actor; + ClutterActor *clone; + + surface = wl_resource_get_user_data (surface_resource); + window = meta_wayland_surface_get_window (surface); + window_actor = meta_window_actor_from_window (window); + + clone = clutter_clone_new (CLUTTER_ACTOR (window_actor)); + clutter_actor_show (clone); + clutter_actor_add_child (stage, clone); + + g_object_set_data_full (G_OBJECT (window), "suspend-test-clone", + clone, (GDestroyNotify) clutter_actor_destroy); + + break; + } } }