test: add a test to simulate the xdotool/xwayland behavior

xdotool sends the events and disconnects immediately, Xwayland queues up those
events until it has a seat but then also disconnects immediately. Let's
emulate this behavior so we can catch breakages before Xwayland sees them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-10-27 11:34:10 +10:00
parent 683ff5cca0
commit 0558866f5b
3 changed files with 61 additions and 0 deletions

View file

@ -102,6 +102,12 @@ OBJECT_IMPLEMENT_UNREF(peck);
OBJECT_IMPLEMENT_GETTER(peck, ei, struct ei*);
OBJECT_IMPLEMENT_GETTER(peck, eis, struct eis*);
void
peck_drop_ei(struct peck *peck)
{
peck->ei = NULL;
}
struct eis_client *
peck_eis_get_default_client(struct peck *peck)
{
@ -615,6 +621,9 @@ _peck_dispatch_until_stable(struct peck *peck, int lineno)
void
peck_drain_eis(struct eis *eis)
{
if (!eis)
return;
eis_dispatch(eis);
while (true) {
@ -627,6 +636,9 @@ peck_drain_eis(struct eis *eis)
void
peck_drain_ei(struct ei *ei)
{
if (!ei)
return;
ei_dispatch(ei);
while (true) {
_unref_(ei_event) *e = ei_get_event(ei);

View file

@ -125,6 +125,9 @@ peck_enable_ei_behavior(struct peck *peck, enum peck_ei_behavior behavior);
struct ei *
peck_get_ei(struct peck *peck);
void
peck_drop_ei(struct peck *peck);
struct eis *
peck_get_eis(struct peck *peck);

View file

@ -1130,6 +1130,52 @@ MUNIT_TEST(test_ei_keymap_changed)
return MUNIT_OK;
}
/* Emulates the XWayland behavior for calling
* xdotool mousemove_relative -- -1 10
*/
MUNIT_TEST(test_xdotool_rel_motion)
{
_unref_(peck) *peck = peck_new();
struct ei_device *device = NULL;
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_dispatch_until_stable(peck);
with_client(peck) {
struct ei_seat *seat = peck_ei_get_default_seat(peck);
device = ei_device_new(seat);
ei_device_configure_name(device, __func__);
ei_device_configure_capability(device, EI_DEVICE_CAP_POINTER);
ei_device_configure_capability(device, EI_DEVICE_CAP_KEYBOARD);
ei_device_add(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
ei_device_pointer_motion(device, -1, 10);
ei_device_remove(device);
ei_device_unref(device);
ei_unref(ei);
peck_drop_ei(peck);
}
peck_dispatch_eis(peck);
with_server(peck) {
_unref_(eis_event) *motion =
peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION);
_unref_(eis_event) *removed =
peck_eis_next_event(eis, EIS_EVENT_DEVICE_REMOVED);
_unref_(eis_event) *disconnect =
peck_eis_next_event(eis, EIS_EVENT_CLIENT_DISCONNECT);
peck_assert_no_eis_events(eis);
}
return MUNIT_OK;
}
int
main(int argc, char **argv)
{