diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2020-12-16 23:27:19 +0100 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2020-12-18 17:17:50 +0000 |
commit | c94d929332d9371646fde15668097c4ea136147c (patch) | |
tree | 6537bd7e01d01fb9781f3f3418e3368e8e8c460e | |
parent | 76d1a64204181f4da82d9614fe59daf350d5dfda (diff) | |
download | mutter-c94d929332d9371646fde15668097c4ea136147c.tar.gz |
tests/stacking: Add test hiding a modal with a not shown parent
This adds a test case for
https://gitlab.gnome.org/GNOME/mutter/-/issues/862 that checks that
hiding a dialog where its parent is not yet shown doesn't trigger any
asserts or crashes.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1643>
-rw-r--r-- | src/tests/meson.build | 1 | ||||
-rw-r--r-- | src/tests/stacking/modals.metatest | 32 | ||||
-rw-r--r-- | src/tests/test-client.c | 28 | ||||
-rw-r--r-- | src/tests/test-runner.c | 14 |
4 files changed, 72 insertions, 3 deletions
diff --git a/src/tests/meson.build b/src/tests/meson.build index 351d8c245..f63e28952 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -179,6 +179,7 @@ stacking_tests = [ 'fullscreen-maximize', 'restore-position', 'default-size', + 'modals', ] foreach stacking_test: stacking_tests diff --git a/src/tests/stacking/modals.metatest b/src/tests/stacking/modals.metatest new file mode 100644 index 000000000..6c76eadf8 --- /dev/null +++ b/src/tests/stacking/modals.metatest @@ -0,0 +1,32 @@ +new_client w wayland + +# Create two Wayland windows, and make the second a transient of the +# first. Then make the parent not actually ever show, but show the +# transient. + +# Then make sure that hiding the transient can hide without causing +# issues. + +# https://gitlab.gnome.org/GNOME/mutter/-/issues/862 + +create w/1 csd +create w/2 csd + +set_parent w/2 1 + +freeze w/1 + +show w/1 async +show w/2 + +wait + +assert_stacking w/1 w/2 + +hide w/2 +wait + +assert_stacking w/1 + +hide w/2 +wait diff --git a/src/tests/test-client.c b/src/tests/test-client.c index 81ce51ab6..9c2f17863 100644 --- a/src/tests/test-client.c +++ b/src/tests/test-client.c @@ -766,6 +766,34 @@ process_line (const char *line) gtk_window_unfullscreen (GTK_WINDOW (window)); } + else if (strcmp (argv[0], "freeze") == 0) + { + if (argc != 2) + { + g_print ("usage: freeze <id>\n"); + goto out; + } + + GtkWidget *window = lookup_window (argv[1]); + if (!window) + goto out; + + gdk_window_freeze_updates (gtk_widget_get_window (window)); + } + else if (strcmp (argv[0], "thaw") == 0) + { + if (argc != 2) + { + g_print ("usage: thaw <id>\n"); + goto out; + } + + GtkWidget *window = lookup_window (argv[1]); + if (!window) + goto out; + + gdk_window_thaw_updates (gtk_widget_get_window (window)); + } else if (strcmp (argv[0], "assert_size") == 0) { int expected_width; diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index 1a5ccd944..65fa54682 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -561,8 +561,13 @@ test_case_do (TestCase *test, } else if (strcmp (argv[0], "show") == 0) { - if (argc != 2) - BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]); + gboolean show_async = FALSE; + + if (argc != 2 && argc != 3) + BAD_COMMAND("usage: %s <client-id>/<window-id> [async]", argv[0]); + + if (argc == 3 && strcmp (argv[2], "async") == 0) + show_async = TRUE; TestClient *client; const char *window_id; @@ -579,7 +584,8 @@ test_case_do (TestCase *test, if (!window) return FALSE; - test_client_wait_for_window_shown (client, window); + if (!show_async) + test_client_wait_for_window_shown (client, window); } else if (strcmp (argv[0], "resize") == 0) { @@ -671,6 +677,8 @@ test_case_do (TestCase *test, strcmp (argv[0], "unmaximize") == 0 || strcmp (argv[0], "fullscreen") == 0 || strcmp (argv[0], "unfullscreen") == 0 || + strcmp (argv[0], "freeze") == 0 || + strcmp (argv[0], "thaw") == 0 || strcmp (argv[0], "destroy") == 0) { if (argc != 2) |