diff --git a/test/eierpecken.c b/test/eierpecken.c index 8afdbc8..e391514 100644 --- a/test/eierpecken.c +++ b/test/eierpecken.c @@ -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); diff --git a/test/eierpecken.h b/test/eierpecken.h index 1c66a04..f053681 100644 --- a/test/eierpecken.h +++ b/test/eierpecken.h @@ -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); diff --git a/test/test-ei.c b/test/test-ei.c index 9ac77d0..31b3110 100644 --- a/test/test-ei.c +++ b/test/test-ei.c @@ -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) {