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>
This commit is contained in:
Jonas Ådahl 2020-12-16 23:27:19 +01:00 committed by Marge Bot
parent 76d1a64204
commit c94d929332
4 changed files with 72 additions and 3 deletions

View File

@ -179,6 +179,7 @@ stacking_tests = [
'fullscreen-maximize',
'restore-position',
'default-size',
'modals',
]
foreach stacking_test: stacking_tests

View File

@ -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

View File

@ -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;

View File

@ -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,6 +584,7 @@ test_case_do (TestCase *test,
if (!window)
return FALSE;
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)