From 2eda6d0a7c7fcd674d242ea57eb53ea83a223d4d Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Fri, 29 Oct 2021 21:26:51 +0200 Subject: [PATCH] tests/test-runner: Add commands to set and remove struts This will be useful for tests that require strut changes to reproduce an issue. Part-of: --- src/tests/test-runner.c | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index bdf2ef109..34cae67e4 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -28,6 +28,7 @@ #include "meta-test/meta-context-test.h" #include "meta/util.h" #include "meta/window.h" +#include "meta/meta-workspace-manager.h" #include "tests/meta-test-utils.h" #include "ui/ui.h" #include "wayland/meta-wayland.h" @@ -810,6 +811,64 @@ test_case_do (TestCase *test, if (!test_case_sleep (test, (guint32) interval, error)) return FALSE; } + else if (strcmp (argv[0], "set_strut") == 0) + { + if (argc != 6) + BAD_COMMAND("usage: %s ", argv[0]); + + int x = atoi (argv[1]); + int y = atoi (argv[2]); + int width = atoi (argv[3]); + int height = atoi (argv[4]); + + MetaSide side; + if (strcmp (argv[5], "left") == 0) + side = META_SIDE_LEFT; + else if (strcmp (argv[5], "right") == 0) + side = META_SIDE_RIGHT; + else if (strcmp (argv[5], "top") == 0) + side = META_SIDE_TOP; + else if (strcmp (argv[5], "bottom") == 0) + side = META_SIDE_BOTTOM; + else + return FALSE; + + MetaDisplay *display = meta_get_display (); + MetaWorkspaceManager *workspace_manager = + meta_display_get_workspace_manager (display); + MetaRectangle rect = { x, y, width, height }; + MetaStrut strut = { rect, side }; + GSList *struts = g_slist_append (NULL, &strut); + GList *workspaces = + meta_workspace_manager_get_workspaces (workspace_manager); + GList *l; + + for (l = workspaces; l; l = l->next) + { + MetaWorkspace *workspace = l->data; + meta_workspace_set_builtin_struts (workspace, struts); + } + + g_slist_free (struts); + } + else if (strcmp (argv[0], "clear_struts") == 0) + { + if (argc != 1) + BAD_COMMAND("usage: %s", argv[0]); + + MetaDisplay *display = meta_get_display (); + MetaWorkspaceManager *workspace_manager = + meta_display_get_workspace_manager (display); + GList *workspaces = + meta_workspace_manager_get_workspaces (workspace_manager); + GList *l; + + for (l = workspaces; l; l = l->next) + { + MetaWorkspace *workspace = l->data; + meta_workspace_set_builtin_struts (workspace, NULL); + } + } else if (strcmp (argv[0], "assert_stacking") == 0) { if (!test_case_assert_stacking (test, argv + 1, argc - 1, error))