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