[mutter/gtk3-ci: 16/18] tests/test-runner: Add 'move' and 'assert_position'
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gtk3-ci: 16/18] tests/test-runner: Add 'move' and 'assert_position'
- Date: Wed, 15 Apr 2020 14:00:59 +0000 (UTC)
commit 42fecdb60ba6d77363ce397a0d93271919a8dca6
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Apr 2 19:12:39 2020 +0200
tests/test-runner: Add 'move' and 'assert_position'
Make it possible for tests to move the windows, and check their
positions.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
src/tests/test-runner.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
---
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 8f2cda16b..7c942b56c 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -591,6 +591,22 @@ test_case_do (TestCase *test,
argv[2], argv[3], NULL))
return FALSE;
}
+ else if (strcmp (argv[0], "move") == 0)
+ {
+ if (argc != 4)
+ BAD_COMMAND("usage: %s <client-id>/<window-id> x y", 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_move_frame (window, TRUE, atoi (argv[2]), atoi (argv[3]));
+ }
else if (strcmp (argv[0], "tile") == 0)
{
if (argc != 3)
@@ -784,6 +800,37 @@ test_case_do (TestCase *test,
error))
return FALSE;
}
+ else if (strcmp (argv[0], "assert_position") == 0)
+ {
+ if (argc != 4)
+ {
+ BAD_COMMAND("usage: %s <client-id>/<window-id> <x> <y>",
+ 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;
+
+ MetaRectangle frame_rect;
+ meta_window_get_frame_rect (window, &frame_rect);
+ int x = atoi (argv[2]);
+ int y = atoi (argv[3]);
+ if (frame_rect.x != x || frame_rect.y != y)
+ {
+ g_set_error (error,
+ TEST_RUNNER_ERROR,
+ TEST_RUNNER_ERROR_ASSERTION_FAILED,
+ "Expected window position (%d, %d) doesn't match (%d, %d)",
+ x, y, frame_rect.x, frame_rect.y);
+ return FALSE;
+ }
+ }
else
{
BAD_COMMAND("Unknown command %s", argv[0]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]