For some tests we need to string multiple event sequences together into one
event frame. Use a push/pop frame approach that stops litest from sending any
EV_SYN/SYN_REPORT events, so we can merge two touches together by e.g.

litest_push_event_frame(d);
litest_touch_down(d, 0, 10, 10);
litest_touch_down(d, 1, 20, 50);
litest_pop_event_frame(d);

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 test/litest.c | 22 +++++++++++++++++++++-
 test/litest.h |  5 +++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/test/litest.c b/test/litest.c
index 2b356be..eed41ba 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -634,7 +634,12 @@ void
 litest_event(struct litest_device *d, unsigned int type,
             unsigned int code, int value)
 {
-       int ret = libevdev_uinput_write_event(d->uinput, type, code, value);
+       int ret;
+
+       if (d->skip_ev_syn && type == EV_SYN && code == SYN_REPORT)
+               return;
+
+       ret = libevdev_uinput_write_event(d->uinput, type, code, value);
        ck_assert_int_eq(ret, 0);
 }
 
@@ -1096,3 +1101,18 @@ litest_timeout_softbuttons(void)
 {
        msleep(300);
 }
+
+void
+litest_push_event_frame(struct litest_device *dev)
+{
+       assert(!dev->skip_ev_syn);
+       dev->skip_ev_syn = true;
+}
+
+void
+litest_pop_event_frame(struct litest_device *dev)
+{
+       assert(dev->skip_ev_syn);
+       dev->skip_ev_syn = false;
+       litest_event(dev, EV_SYN, SYN_REPORT, 0);
+}
diff --git a/test/litest.h b/test/litest.h
index 40d4df9..540e07b 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -72,6 +72,8 @@ struct litest_device {
        struct litest_device_interface *interface;
 
        int ntouches_down;
+       bool skip_ev_syn;
+
        void *private; /* device-specific data */
 };
 
@@ -159,6 +161,9 @@ struct libevdev_uinput * 
litest_create_uinput_abs_device(const char *name,
 void litest_timeout_tap(void);
 void litest_timeout_softbuttons(void);
 
+void litest_push_event_frame(struct litest_device *dev);
+void litest_pop_event_frame(struct litest_device *dev);
+
 #ifndef ck_assert_notnull
 #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
 #endif
-- 
1.9.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to