From 1920d55ef9a43c31413c903f04cd7feeb96dcc91 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 7 Dec 2022 23:05:29 +0100 Subject: [PATCH] tests/stacking: Test stacking order with raise-on-click = false Makes sure the focus changes but the stacking stays the same. Also checks that the stacking and focus on a workspace stays the same when changing between them. Part-of: --- src/tests/meta-context-test.c | 16 ++++++++++ .../click-to-focus-and-raise.metatest | 31 +++++++++++++++++++ src/tests/test-runner.c | 26 ++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c index 89a4d00f7..0387c5855 100644 --- a/src/tests/meta-context-test.c +++ b/src/tests/meta-context-test.c @@ -24,6 +24,8 @@ #include #include +#define G_SETTINGS_ENABLE_BACKEND +#include #include "core/meta-context-private.h" #include "tests/meta-backend-test.h" @@ -59,6 +61,18 @@ struct _MetaContextTestClass G_DEFINE_TYPE_WITH_PRIVATE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT) +static void +ensure_gsettings_memory_backend (void) +{ + g_autoptr (GSettingsBackend) memory_backend = NULL; + GSettingsBackend *default_backend; + + memory_backend = g_memory_settings_backend_new (); + default_backend = g_settings_backend_get_default (); + g_assert_true (G_TYPE_FROM_INSTANCE (memory_backend) == + G_TYPE_FROM_INSTANCE (default_backend)); +} + static gboolean meta_context_test_configure (MetaContext *context, int *argc, @@ -92,6 +106,8 @@ meta_context_test_configure (MetaContext *context, plugin_name = "libdefault"; meta_context_set_plugin_name (context, plugin_name); + ensure_gsettings_memory_backend (); + return TRUE; } diff --git a/src/tests/stacking/click-to-focus-and-raise.metatest b/src/tests/stacking/click-to-focus-and-raise.metatest index c6faeb552..f6b91f876 100644 --- a/src/tests/stacking/click-to-focus-and-raise.metatest +++ b/src/tests/stacking/click-to-focus-and-raise.metatest @@ -1,5 +1,7 @@ resize_monitor primary 800 600 +num_workspaces 2 + new_client w wayland create w/1 csd @@ -25,9 +27,38 @@ assert_size w/1 100 100 assert_position w/2 100 0 assert_size w/2 100 100 +# click on window w/1 and check that it gets focused and raised move_cursor_to 50 50 click wait assert_stacking w/2 w/1 assert_focused w/1 + +# click on window w/2 and check that it gets focused but not raised +# when raise-on-click false is false +set_pref raise-on-click false + +move_cursor_to 150 50 +click +wait + +assert_stacking w/2 w/1 +assert_focused w/2 + +# Change to another workspace, create a window with focus, change back to the +# original workspace and make sure the focus for that workspace didn't change +activate_workspace 1 +wait + +create w/3 csd +resize w/3 100 100 +show w/3 + +wait_reconfigure + +activate_workspace 0 +wait + +assert_stacking_workspace 0 w/2 w/1 +assert_focused w/2 diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index 94017fd1a..4bd882d12 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -1203,6 +1203,32 @@ test_case_do (TestCase *test, CLUTTER_BUTTON_STATE_RELEASED); meta_flush_input (test->context); } + else if (strcmp (argv[0], "set_pref") == 0) + { + GSettings *settings; + + if (argc != 3) + BAD_COMMAND("usage: %s ", argv[0]); + + settings = g_settings_new ("org.gnome.desktop.wm.preferences"); + g_assert_nonnull (settings); + + if (strcmp (argv[1], "raise-on-click") == 0) + { + gboolean value; + if (g_ascii_strcasecmp (argv[2], "true") == 0) + value = TRUE; + else if (g_ascii_strcasecmp (argv[2], "false") == 0) + value = FALSE; + else + BAD_COMMAND("usage: %s %s [true|false]", argv[0], argv[1]); + + g_assert_true (g_settings_set_boolean (settings, "raise-on-click", value)); + } + else { + BAD_COMMAND("Unknown preference %s", argv[1]); + } + } else { BAD_COMMAND("Unknown command %s", argv[0]);