tests/wayland-unit-tests: Make toplevel_apply_limits easier to follow
Use the wait_for_sync_point method instead of the convoluted callback and state handling. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3348>
This commit is contained in:
parent
8c3c29d0c0
commit
c645b6c6fa
@ -298,92 +298,47 @@ subsurface_parent_unmapped (void)
|
|||||||
g_signal_handler_disconnect (display->stack, window_added_id);
|
g_signal_handler_disconnect (display->stack, window_added_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum _ApplyLimitState
|
|
||||||
{
|
|
||||||
APPLY_LIMIT_STATE_INIT,
|
|
||||||
APPLY_LIMIT_STATE_RESET,
|
|
||||||
APPLY_LIMIT_STATE_FINISH,
|
|
||||||
} ApplyLimitState;
|
|
||||||
|
|
||||||
typedef struct _ApplyLimitData
|
|
||||||
{
|
|
||||||
GMainLoop *loop;
|
|
||||||
MetaWaylandTestClient *wayland_test_client;
|
|
||||||
ApplyLimitState state;
|
|
||||||
} ApplyLimitData;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_apply_limits_sync_point (MetaWaylandTestDriver *test_driver,
|
wait_for_sync_point (unsigned int sync_point)
|
||||||
unsigned int sequence,
|
|
||||||
struct wl_resource *surface_resource,
|
|
||||||
struct wl_client *wl_client,
|
|
||||||
ApplyLimitData *data)
|
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
meta_wayland_test_driver_wait_for_sync_point (test_driver, sync_point);
|
||||||
|
|
||||||
if (sequence == 0)
|
|
||||||
g_assert (data->state == APPLY_LIMIT_STATE_INIT);
|
|
||||||
else if (sequence == 1)
|
|
||||||
g_assert (data->state == APPLY_LIMIT_STATE_RESET);
|
|
||||||
|
|
||||||
window = find_client_window ("toplevel-limits-test");
|
|
||||||
|
|
||||||
if (sequence == 0)
|
|
||||||
{
|
|
||||||
g_assert_nonnull (window);
|
|
||||||
g_assert_cmpint (window->size_hints.max_width, ==, 700);
|
|
||||||
g_assert_cmpint (window->size_hints.max_height, ==, 500);
|
|
||||||
g_assert_cmpint (window->size_hints.min_width, ==, 700);
|
|
||||||
g_assert_cmpint (window->size_hints.min_height, ==, 500);
|
|
||||||
|
|
||||||
data->state = APPLY_LIMIT_STATE_RESET;
|
|
||||||
}
|
|
||||||
else if (sequence == 1)
|
|
||||||
{
|
|
||||||
g_assert_null (window);
|
|
||||||
data->state = APPLY_LIMIT_STATE_FINISH;
|
|
||||||
g_main_loop_quit (data->loop);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toplevel_apply_limits (void)
|
toplevel_apply_limits (void)
|
||||||
{
|
{
|
||||||
ApplyLimitData data = {};
|
MetaWaylandTestClient *wayland_test_client;
|
||||||
gulong handler_id;
|
MetaWindow *window;
|
||||||
|
|
||||||
data.loop = g_main_loop_new (NULL, FALSE);
|
wayland_test_client =
|
||||||
data.wayland_test_client =
|
|
||||||
meta_wayland_test_client_new (test_context, "xdg-apply-limits");
|
meta_wayland_test_client_new (test_context, "xdg-apply-limits");
|
||||||
handler_id = g_signal_connect (test_driver, "sync-point",
|
|
||||||
G_CALLBACK (on_apply_limits_sync_point),
|
wait_for_sync_point (0);
|
||||||
&data);
|
|
||||||
g_main_loop_run (data.loop);
|
window = find_client_window ("toplevel-limits-test");
|
||||||
g_assert_cmpint (data.state, ==, APPLY_LIMIT_STATE_FINISH);
|
g_assert_nonnull (window);
|
||||||
meta_wayland_test_client_finish (data.wayland_test_client);
|
g_assert_cmpint (window->size_hints.max_width, ==, 700);
|
||||||
|
g_assert_cmpint (window->size_hints.max_height, ==, 500);
|
||||||
|
g_assert_cmpint (window->size_hints.min_width, ==, 700);
|
||||||
|
g_assert_cmpint (window->size_hints.min_height, ==, 500);
|
||||||
|
|
||||||
|
wait_for_sync_point (1);
|
||||||
|
|
||||||
|
window = find_client_window ("toplevel-limits-test");
|
||||||
|
g_assert_null (window);
|
||||||
|
|
||||||
|
meta_wayland_test_client_finish (wayland_test_client);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
g_signal_handler_disconnect (test_driver, handler_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toplevel_activation (void)
|
toplevel_activation (void)
|
||||||
{
|
{
|
||||||
ApplyLimitData data = {};
|
MetaWaylandTestClient *wayland_test_client;
|
||||||
|
|
||||||
data.loop = g_main_loop_new (NULL, FALSE);
|
wayland_test_client =
|
||||||
data.wayland_test_client =
|
|
||||||
meta_wayland_test_client_new (test_context, "xdg-activation");
|
meta_wayland_test_client_new (test_context, "xdg-activation");
|
||||||
meta_wayland_test_client_finish (data.wayland_test_client);
|
meta_wayland_test_client_finish (wayland_test_client);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
wait_for_sync_point (unsigned int sync_point)
|
|
||||||
{
|
|
||||||
meta_wayland_test_driver_wait_for_sync_point (test_driver, sync_point);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user