1
0
Fork 0

tests/runner: Make 'wait_reconfigure' actually wait for a reconfigure

We just made an half assed attempt to wait, but e.g. when clients were
waiting for a frame event, the attempt was not enough, as the clients
would not ack any configure until the time they were scheduled to paint
again.

Fix this by actually tracking newly pending configurations, and waiting
for them to return.

On X11, still be lazy and hope for the best, as there is no similar
configuration tracking there.

Some tests were updated to use just 'wait' when there was no actual need
for any extra waiting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
This commit is contained in:
Jonas Ådahl 2024-04-14 22:06:59 +02:00 committed by Marge Bot
parent 0ab5ff6eed
commit 5e6aee6367
14 changed files with 164 additions and 73 deletions

View file

@ -12,12 +12,12 @@ create w/2 csd
resize w/2 100 100
show w/2
wait_reconfigure
wait_reconfigure w/1 w/2
move w/1 0 0
move w/2 100 0
wait_reconfigure
wait_reconfigure w/1 w/2
assert_stacking w/1 w/2
assert_focused w/2
@ -55,7 +55,7 @@ create w/3 csd
resize w/3 100 100
show w/3
wait_reconfigure
wait_reconfigure w/3
activate_workspace 0
wait

View file

@ -8,7 +8,7 @@ wait
assert_size x/1 300 400
resize x/1 200 300
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 200 300
hide x/1
@ -27,10 +27,10 @@ wait
assert_size w/1 300 400
resize w/1 200 300
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 200 300
hide w/1
show w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 200 300

View file

@ -16,27 +16,27 @@ wait
assert_size w/1 500 400
maximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
fullscreen w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unfullscreen w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 500 400
fullscreen w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unfullscreen w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 500 400
new_client x x11
@ -49,25 +49,25 @@ wait
assert_size x/1 500 400
maximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
fullscreen x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
unfullscreen x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 500 400
fullscreen x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
unfullscreen x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 500 400

View file

@ -8,19 +8,19 @@ move x/1 100 100
assert_position x/1 100 100
maximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 0 0
unmaximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 100 100
tile x/1 left
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 0 0
untile x/1
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 100 100
tile x/1 left
@ -28,11 +28,11 @@ wait
assert_position x/1 0 0
maximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 0 0
unmaximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_position x/1 100 100
# Wayland
@ -45,29 +45,29 @@ move w/1 100 100
assert_position w/1 100 100
maximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 0 0
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 100 100
tile w/1 left
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 0 0
untile w/1
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 100 100
tile w/1 left
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 0 0
maximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 0 0
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_position w/1 100 100

View file

@ -20,30 +20,30 @@ assert_size x/1 500 400
resize x/1 300 200
wait_size x/1 300 200
maximize x/1
wait_reconfigure
wait_reconfigure x/1
unmaximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 300 200
tile x/1 right
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
untile x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 300 200
tile x/1 left
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
maximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 300 200
# Check that Wayland clients restore to their right size after unmaximize
@ -61,35 +61,35 @@ wait
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 150 300
resize w/1 300 200
wait
maximize w/1
wait_reconfigure
wait_reconfigure w/1
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 300 200
tile w/1 right
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
untile w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 300 200
tile w/1 left
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
maximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 300 200

View file

@ -17,12 +17,12 @@ create w/1 csd
resize w/1 100 100
show w/1
wait_reconfigure
wait_reconfigure w/1
move w/0 0 0
move w/1 100 0
wait_reconfigure
wait
assert_stacking w/0 w/1
assert_focused w/1
@ -45,4 +45,4 @@ assert_focused w/0
sleep 50
assert_stacking w/1 w/0
assert_focused w/0
assert_focused w/0

View file

@ -19,13 +19,13 @@ create w/2 csd
resize w/2 100 100
show w/2
wait_reconfigure
wait_reconfigure w/0 w/1 w/2
move w/0 0 0
move w/1 100 0
move w/2 200 0
wait_reconfigure
wait
assert_stacking w/0 w/1 w/2
assert_focused w/2
@ -56,4 +56,4 @@ assert_focused w/0
sleep 50
assert_stacking w/0 w/1 w/2
assert_focused w/2
assert_focused w/2

View file

@ -15,12 +15,12 @@ create w/1 csd
resize w/1 100 100
show w/1
wait_reconfigure
wait_reconfigure w/0 w/1
move w/0 0 0
move w/1 100 0
wait_reconfigure
wait
assert_stacking w/0 w/1
assert_focused w/1
@ -59,4 +59,4 @@ assert_focused w/0
move_cursor_to 150 50
assert_stacking w/1 w/0
assert_focused w/1
assert_focused w/1

View file

@ -13,7 +13,7 @@ wait
assert_size w/1 500 400
fullscreen w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
stop_after_next w
@ -21,7 +21,7 @@ unfullscreen w/1
wait
set_strut 0 0 1 1 top
continue w
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 500 400
clear_struts
@ -37,7 +37,7 @@ wait
assert_size x/1 500 400
fullscreen x/1
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
stop_after_next x
@ -45,5 +45,5 @@ unfullscreen x/1
wait
set_strut 0 0 1 1 top
continue x
wait_reconfigure
wait_reconfigure x/1
assert_size x/1 500 400

View file

@ -10,13 +10,13 @@ wait
assert_size w/1 500 400
maximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
resize w/1 300 500
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
unmaximize w/1
wait_reconfigure
wait_reconfigure w/1
assert_size w/1 300 500

View file

@ -17,13 +17,13 @@ create w/2 csd
resize w/2 100 100
show w/2
wait_reconfigure
wait_reconfigure w/1 w/2
# make sure the windows are on the secondary monitor
move w/1 800 0
move w/2 900 0
wait_reconfigure
wait_reconfigure w/1 w/2
assert_stacking w/1 w/2
assert_focused w/2

View file

@ -33,6 +33,7 @@
#include "meta/window.h"
#include "tests/meta-test-utils.h"
#include "wayland/meta-wayland.h"
#include "wayland/meta-window-wayland.h"
#include "x11/meta-x11-display-private.h"
typedef struct {
@ -824,21 +825,90 @@ test_case_do (TestCase *test,
}
else if (strcmp (argv[0], "wait_reconfigure") == 0)
{
if (argc != 1)
BAD_COMMAND("usage: %s", argv[0]);
MetaTestClient *client;
const char *window_id;
g_autoptr (GPtrArray) windows = NULL;
g_autoptr (GArray) serials = NULL;
int i;
gboolean has_x11_window = FALSE;
gboolean has_unfinished_configurations;
if (argc < 2)
BAD_COMMAND("usage: %s [<client-id>/<window-id>..]", argv[0]);
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
return FALSE;
/*
* Wait twice, so that we
* 1) First wait for any requests to configure being made
* 2) Then wait until the new configuration has been applied
* 1. Wait once to reconfigure
* 2. Wait for window to receive back any pending configuration
*/
if (!test_case_wait (test, error))
return FALSE;
if (!test_case_dispatch (test, error))
return FALSE;
if (!test_case_wait (test, error))
return FALSE;
windows = g_ptr_array_new ();
serials = g_array_new (FALSE, FALSE, sizeof (uint32_t));
for (i = 1; i < argc; i++)
{
MetaWindow *window;
window = meta_test_client_find_window (client, window_id, error);
if (!window)
return FALSE;
if (META_IS_WINDOW_WAYLAND (window))
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
uint32_t serial;
if (meta_window_wayland_get_pending_serial (wl_window, &serial))
{
g_ptr_array_add (windows, window);
g_array_append_val (serials, serial);
}
}
else
{
has_x11_window = TRUE;
}
}
if (has_x11_window)
{
/* There is no reliable configure tracking on X11, just make a
* genuien attempt, by first making sure pending operations have
* reached us, that we have flushed any outgoing data, and that any
* new pending operation from that has reached us. */
if (!test_case_wait (test, error))
return FALSE;
if (!test_case_dispatch (test, error))
return FALSE;
if (!test_case_wait (test, error))
return FALSE;
}
while (TRUE)
{
has_unfinished_configurations = FALSE;
for (i = 0; i < windows->len; i++)
{
MetaWindowWayland *wl_window = g_ptr_array_index (windows, i);
uint32_t serial = g_array_index (serials, uint32_t, i);
if (meta_window_wayland_peek_configuration (wl_window, serial))
{
has_unfinished_configurations = TRUE;
break;
}
}
if (has_unfinished_configurations)
g_main_context_iteration (NULL, TRUE);
else
break;
}
}
else if (strcmp (argv[0], "wait_size") == 0)
{

View file

@ -1450,3 +1450,19 @@ meta_window_wayland_is_acked_fullscreen (MetaWindowWayland *wl_window)
return (wl_window->last_acked_configuration &&
wl_window->last_acked_configuration->is_fullscreen);
}
gboolean
meta_window_wayland_get_pending_serial (MetaWindowWayland *wl_window,
uint32_t *serial)
{
if (wl_window->pending_configurations)
{
MetaWaylandWindowConfiguration *configuration =
wl_window->pending_configurations->data;
*serial = configuration->serial;
return TRUE;
}
return FALSE;
}

View file

@ -49,6 +49,7 @@ void meta_window_place_with_placement_rule (MetaWindow *window,
void meta_window_update_placement_rule (MetaWindow *window,
MetaPlacementRule *placement_rule);
META_EXPORT_TEST
MetaWaylandWindowConfiguration *
meta_window_wayland_peek_configuration (MetaWindowWayland *wl_window,
uint32_t serial);
@ -76,3 +77,7 @@ gboolean meta_window_wayland_is_resize (MetaWindowWayland *wl_window,
META_EXPORT_TEST
gboolean meta_window_wayland_is_acked_fullscreen (MetaWindowWayland *wl_window);
META_EXPORT_TEST
gboolean meta_window_wayland_get_pending_serial (MetaWindowWayland *wl_window,
uint32_t *serial);