From 7ac982d0d28b669cfc61e9c2cb85d86e2665fe54 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sat, 9 Jul 2022 12:30:23 +0200 Subject: [PATCH] tests/stacking: Test always-on-top stacking and focus Adds the command make_above to set and unset always-on-top behavior of a window and tests stacking and focus when activating other windows and switching workspaces. Part-of: --- src/tests/meson.build | 1 + src/tests/stacking/always-on-top.metatest | 51 +++++++++++++++++++++++ src/tests/test-runner.c | 23 ++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/tests/stacking/always-on-top.metatest diff --git a/src/tests/meson.build b/src/tests/meson.build index 9c26e3348..bc0d535c5 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -442,6 +442,7 @@ stacking_tests = [ 'map-on-hotplug', 'workspace-basic', 'workspace-test', + 'always-on-top', ] foreach stacking_test: stacking_tests diff --git a/src/tests/stacking/always-on-top.metatest b/src/tests/stacking/always-on-top.metatest new file mode 100644 index 000000000..12a04dddb --- /dev/null +++ b/src/tests/stacking/always-on-top.metatest @@ -0,0 +1,51 @@ +num_workspaces 2 + +new_client 1 wayland +create 1/1 +show 1/1 +create 1/2 +show 1/2 +create 1/3 +show 1/3 +wait + +assert_stacking_workspace 0 1/1 1/2 1/3 +assert_stacking_workspace 1 +assert_focused 1/3 + +local_activate 1/1 + +assert_stacking_workspace 0 1/2 1/3 1/1 +assert_stacking_workspace 1 +assert_focused 1/1 + +make_above 1/3 true + +assert_stacking_workspace 0 1/2 1/1 1/3 +assert_stacking_workspace 1 +assert_focused 1/1 + +local_activate 1/2 + +assert_stacking_workspace 0 1/1 1/2 1/3 +assert_stacking_workspace 1 +assert_focused 1/2 + +activate_workspace 1 + +assert_stacking_workspace 0 1/1 1/2 1/3 +assert_stacking_workspace 1 +assert_focused none + +activate_workspace 0 + +assert_stacking_workspace 0 1/1 1/2 1/3 +assert_stacking_workspace 1 +assert_focused 1/2 + +make_above 1/3 false +local_activate 1/1 + +assert_stacking_workspace 0 1/2 1/3 1/1 +assert_stacking_workspace 1 +assert_focused 1/1 diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index 0553e251d..845a5441a 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -1148,6 +1148,29 @@ test_case_do (TestCase *test, meta_window_change_workspace (window, workspace); } + else if (strcmp (argv[0], "make_above") == 0) + { + if (argc != 3 || + (g_ascii_strcasecmp (argv[2], "true") != 0 && + g_ascii_strcasecmp (argv[2], "false") != 0)) + BAD_COMMAND("usage: %s / [true|false]", + argv[0]); + + MetaTestClient *client; + const char *window_id; + if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error)) + return FALSE; + + MetaWindow *window; + window = meta_test_client_find_window (client, window_id, error); + if (!window) + return FALSE; + + if (g_ascii_strcasecmp (argv[2], "true") == 0) + meta_window_make_above (window); + else + meta_window_unmake_above (window); + } else { BAD_COMMAND("Unknown command %s", argv[0]);