[mutter] tests/test-runner: Add tile and untile commands



commit e09e62d5859cf6c9c18ce1642feadb36a711fcd3
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Apr 2 19:09:14 2020 +0200

    tests/test-runner: Add tile and untile commands
    
    This allows test cases to tile windows to the right or left, and untile,
    just as the keyboard shortcuts does.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171

 src/tests/test-runner.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
---
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 6f3d24bbf..7d7c3f6e5 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -592,6 +592,56 @@ test_case_do (TestCase *test,
                            argv[2], argv[3], NULL))
         return FALSE;
     }
+  else if (strcmp (argv[0], "tile") == 0)
+    {
+      if (argc != 3)
+        BAD_COMMAND("usage: %s <client-id>/<window-id> [right|left]", argv[0]);
+
+      TestClient *client;
+      const char *window_id;
+      if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
+        return FALSE;
+
+      MetaWindow *window = test_client_find_window (client, window_id, error);
+      if (!window)
+        return FALSE;
+
+      MetaTileMode tile_mode;
+      if (strcmp (argv[2], "right") == 0)
+        {
+          tile_mode = META_TILE_RIGHT;
+        }
+      else if (strcmp (argv[2], "left") == 0)
+        {
+          tile_mode = META_TILE_LEFT;
+        }
+      else
+        {
+          g_set_error (error,
+                       TEST_RUNNER_ERROR,
+                       TEST_RUNNER_ERROR_ASSERTION_FAILED,
+                       "Invalid tile mode '%s'", argv[2]);
+          return FALSE;
+        }
+
+      meta_window_tile (window, tile_mode);
+    }
+  else if (strcmp (argv[0], "untile") == 0)
+    {
+      if (argc != 2)
+        BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]);
+
+      TestClient *client;
+      const char *window_id;
+      if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
+        return FALSE;
+
+      MetaWindow *window = test_client_find_window (client, window_id, error);
+      if (!window)
+        return FALSE;
+
+      meta_window_untile (window);
+    }
   else if (strcmp (argv[0], "hide") == 0 ||
            strcmp (argv[0], "activate") == 0 ||
            strcmp (argv[0], "raise") == 0 ||


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]