[mutter] tests/wayland-test-driver: Add generic "sync point" request



commit 8c5b7ddc48700569196cdf2df01404dc54c818cd
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jun 18 23:15:05 2021 +0100

    tests/wayland-test-driver: Add generic "sync point" request
    
    This can be used by test cases to make sure the compositor tries
    something after a known client state.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>

 src/tests/meta-wayland-test-driver.c           | 32 ++++++++++++++++++++++++++
 src/tests/wayland-test-clients/test-driver.xml |  4 ++++
 2 files changed, 36 insertions(+)
---
diff --git a/src/tests/meta-wayland-test-driver.c b/src/tests/meta-wayland-test-driver.c
index 9913e779fa..0eecf8d450 100644
--- a/src/tests/meta-wayland-test-driver.c
+++ b/src/tests/meta-wayland-test-driver.c
@@ -26,6 +26,15 @@
 
 #include "test-driver-server-protocol.h"
 
+enum
+{
+  SYNC_POINT,
+
+  N_SIGNALS
+};
+
+static int signals[N_SIGNALS];
+
 struct _MetaWaylandTestDriver
 {
   GObject parent;
@@ -69,8 +78,21 @@ sync_actor_destroy (struct wl_client   *client,
                     callback);
 }
 
+static void
+sync_point (struct wl_client   *client,
+            struct wl_resource *resource,
+            uint32_t            sequence)
+{
+  MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource);
+
+  g_signal_emit (test_driver, signals[SYNC_POINT], 0,
+                 sequence,
+                 client);
+}
+
 static const struct test_driver_interface meta_test_driver_interface = {
   sync_actor_destroy,
+  sync_point,
 };
 
 static void
@@ -104,6 +126,16 @@ meta_wayland_test_driver_class_init (MetaWaylandTestDriverClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->finalize = meta_wayland_test_driver_finalize;
+
+  signals[SYNC_POINT] =
+    g_signal_new ("sync-point",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 2,
+                  G_TYPE_UINT,
+                  G_TYPE_POINTER);
 }
 
 static void
diff --git a/src/tests/wayland-test-clients/test-driver.xml b/src/tests/wayland-test-clients/test-driver.xml
index dd5f521455..2433cf111a 100644
--- a/src/tests/wayland-test-clients/test-driver.xml
+++ b/src/tests/wayland-test-clients/test-driver.xml
@@ -5,5 +5,9 @@
       <arg name="callback" type="new_id" interface="wl_callback"/>
       <arg name="surface" type="object" interface="wl_surface"/>
     </request>
+
+    <request name="sync_point">
+      <arg name="sequence" type="uint"/>
+    </request>
   </interface>
 </protocol>


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