[mutter] tests/wayland-test-driver: Add sync event



commit ed4e5326906216c57dc856c9260e28f27a5ace17
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Sep 7 10:32:53 2021 +0200

    tests/wayland-test-driver: Add sync event
    
    Will be used to signal test cases.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>

 src/tests/meta-wayland-test-driver.c           | 28 +++++++++++++++++++++++++-
 src/tests/meta-wayland-test-driver.h           |  3 +++
 src/tests/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 24ce06030f..e8413e0b85 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 ccbfe1312d..6d357650cf 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 27574b101b..763e1f6743 100644
--- a/src/tests/wayland-test-clients/test-driver.xml
+++ b/src/tests/wayland-test-clients/test-driver.xml
@@ -10,5 +10,9 @@
       <arg name="sequence" type="uint"/>
       <arg name="surface" type="object" interface="wl_surface" allow-null="true"/>
     </request>
+
+    <event name="sync_event">
+      <arg name="sequence" type="uint"/>
+    </event>
   </interface>
 </protocol>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]