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>
This commit is contained in:
Jonas Ådahl 2021-06-18 23:15:05 +01:00 committed by Christian Rauch
parent 151c80d2ef
commit 8c5b7ddc48
2 changed files with 36 additions and 0 deletions

View File

@ -26,6 +26,15 @@
#include "test-driver-server-protocol.h" #include "test-driver-server-protocol.h"
enum
{
SYNC_POINT,
N_SIGNALS
};
static int signals[N_SIGNALS];
struct _MetaWaylandTestDriver struct _MetaWaylandTestDriver
{ {
GObject parent; GObject parent;
@ -69,8 +78,21 @@ sync_actor_destroy (struct wl_client *client,
callback); 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 = { static const struct test_driver_interface meta_test_driver_interface = {
sync_actor_destroy, sync_actor_destroy,
sync_point,
}; };
static void static void
@ -104,6 +126,16 @@ meta_wayland_test_driver_class_init (MetaWaylandTestDriverClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_wayland_test_driver_finalize; 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 static void

View File

@ -5,5 +5,9 @@
<arg name="callback" type="new_id" interface="wl_callback"/> <arg name="callback" type="new_id" interface="wl_callback"/>
<arg name="surface" type="object" interface="wl_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
</request> </request>
<request name="sync_point">
<arg name="sequence" type="uint"/>
</request>
</interface> </interface>
</protocol> </protocol>