From ed4e5326906216c57dc856c9260e28f27a5ace17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 7 Sep 2021 10:32:53 +0200 Subject: [PATCH] tests/wayland-test-driver: Add sync event Will be used to signal test cases. Part-of: --- src/tests/meta-wayland-test-driver.c | 28 ++++++++++++++++++- src/tests/meta-wayland-test-driver.h | 3 ++ .../wayland-test-clients/test-driver.xml | 4 +++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/tests/meta-wayland-test-driver.c b/src/tests/meta-wayland-test-driver.c index 24ce06030..e8413e0b8 100644 --- a/src/tests/meta-wayland-test-driver.c +++ b/src/tests/meta-wayland-test-driver.c @@ -40,6 +40,8 @@ struct _MetaWaylandTestDriver GObject parent; struct wl_global *test_driver; + + GList *resources; }; G_DEFINE_TYPE (MetaWaylandTestDriver, meta_wayland_test_driver, @@ -97,6 +99,14 @@ static const struct test_driver_interface meta_test_driver_interface = { sync_point, }; +static void +test_driver_destructor (struct wl_resource *resource) +{ + MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource); + + test_driver->resources = g_list_remove (test_driver->resources, resource); +} + static void bind_test_driver (struct wl_client *client, void *user_data, @@ -109,7 +119,9 @@ bind_test_driver (struct wl_client *client, resource = wl_resource_create (client, &test_driver_interface, version, id); wl_resource_set_implementation (resource, &meta_test_driver_interface, - test_driver, NULL); + test_driver, test_driver_destructor); + + test_driver->resources = g_list_prepend (test_driver->resources, resource); } static void @@ -161,3 +173,17 @@ meta_wayland_test_driver_new (MetaWaylandCompositor *compositor) return test_driver; } + +void +meta_wayland_test_driver_emit_sync_event (MetaWaylandTestDriver *test_driver, + uint32_t serial) +{ + GList *l; + + for (l = test_driver->resources; l; l = l->next) + { + struct wl_resource *resource = l->data; + + test_driver_send_sync_event (resource, serial); + } +} diff --git a/src/tests/meta-wayland-test-driver.h b/src/tests/meta-wayland-test-driver.h index ccbfe1312..6d357650c 100644 --- a/src/tests/meta-wayland-test-driver.h +++ b/src/tests/meta-wayland-test-driver.h @@ -27,4 +27,7 @@ G_DECLARE_FINAL_TYPE (MetaWaylandTestDriver, meta_wayland_test_driver, MetaWaylandTestDriver * meta_wayland_test_driver_new (MetaWaylandCompositor *compositor); +void meta_wayland_test_driver_emit_sync_event (MetaWaylandTestDriver *test_driver, + uint32_t serial); + #endif /* META_WAYLAND_TEST_DRIVER_H */ diff --git a/src/tests/wayland-test-clients/test-driver.xml b/src/tests/wayland-test-clients/test-driver.xml index 27574b101..763e1f674 100644 --- a/src/tests/wayland-test-clients/test-driver.xml +++ b/src/tests/wayland-test-clients/test-driver.xml @@ -10,5 +10,9 @@ + + + +