From 41f488a65ca67ee7e83a952c02af2fae60cc7583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 14 Sep 2022 23:12:00 +0200 Subject: [PATCH] tests/wayland-unit: Move out sync point wait helper Part-of: --- src/tests/meta-wayland-test-driver.c | 25 +++++++++++++++++++++++++ src/tests/meta-wayland-test-driver.h | 3 +++ src/tests/wayland-unit-tests.c | 20 +------------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/tests/meta-wayland-test-driver.c b/src/tests/meta-wayland-test-driver.c index d418fa14f..a9bb25123 100644 --- a/src/tests/meta-wayland-test-driver.c +++ b/src/tests/meta-wayland-test-driver.c @@ -331,3 +331,28 @@ meta_wayland_test_driver_set_property (MetaWaylandTestDriver *test_driver, g_strdup (name), g_strdup (value)); } + +static void +on_sync_point (MetaWaylandTestDriver *test_driver, + unsigned int sequence, + struct wl_resource *surface_resource, + struct wl_client *wl_client, + unsigned int *latest_sequence) +{ + *latest_sequence = sequence; +} + +void +meta_wayland_test_driver_wait_for_sync_point (MetaWaylandTestDriver *test_driver, + unsigned int sync_point) +{ + gulong handler_id; + unsigned int latest_sequence = sync_point - 1; + + handler_id = g_signal_connect (test_driver, "sync-point", + G_CALLBACK (on_sync_point), + &latest_sequence); + while (latest_sequence != sync_point) + g_main_context_iteration (NULL, TRUE); + g_signal_handler_disconnect (test_driver, handler_id); +} diff --git a/src/tests/meta-wayland-test-driver.h b/src/tests/meta-wayland-test-driver.h index b20af7449..dbd6ab82b 100644 --- a/src/tests/meta-wayland-test-driver.h +++ b/src/tests/meta-wayland-test-driver.h @@ -34,4 +34,7 @@ void meta_wayland_test_driver_set_property (MetaWaylandTestDriver *test_driver, const char *name, const char *value); +void meta_wayland_test_driver_wait_for_sync_point (MetaWaylandTestDriver *test_driver, + unsigned int sync_point); + #endif /* META_WAYLAND_TEST_DRIVER_H */ diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c index 12dc6d8d3..2dc2f4381 100644 --- a/src/tests/wayland-unit-tests.c +++ b/src/tests/wayland-unit-tests.c @@ -385,28 +385,10 @@ toplevel_activation (void) meta_wayland_test_client_finish (data.wayland_test_client); } -static void -on_sync_point (MetaWaylandTestDriver *test_driver, - unsigned int sequence, - struct wl_resource *surface_resource, - struct wl_client *wl_client, - unsigned int *latest_sequence) -{ - *latest_sequence = sequence; -} - static void wait_for_sync_point (unsigned int sync_point) { - gulong handler_id; - unsigned int latest_sequence = 0; - - handler_id = g_signal_connect (test_driver, "sync-point", - G_CALLBACK (on_sync_point), - &latest_sequence); - while (latest_sequence != sync_point) - g_main_context_iteration (NULL, TRUE); - g_signal_handler_disconnect (test_driver, handler_id); + meta_wayland_test_driver_wait_for_sync_point (test_driver, sync_point); } static gboolean