test: add litest_push/pop_event_frame() helpers
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 17 Sep 2014 00:07:38 +0000 (10:07 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 23 Sep 2014 04:38:52 +0000 (14:38 +1000)
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.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
test/litest.c
test/litest.h

index 29820a7..e028176 100644 (file)
@@ -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);
 }
 
@@ -1135,3 +1140,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);
+}
index c40427d..26b3040 100644 (file)
@@ -73,6 +73,8 @@ struct litest_device {
        struct litest_device_interface *interface;
 
        int ntouches_down;
+       bool skip_ev_syn;
+
        void *private; /* device-specific data */
 };
 
@@ -161,6 +163,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