summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-09-17 10:07:38 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-09-23 14:38:52 +1000
commit4dce0648f668d416d88a3835c29667cd4fdb5850 (patch)
tree88a8975879e247cc1cdb548b54ab756793692567
parente4adbff919223861bb2630eb413c1c64d02dfd57 (diff)
test: add litest_push/pop_event_frame() helpers
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>
-rw-r--r--test/litest.c22
-rw-r--r--test/litest.h5
2 files changed, 26 insertions, 1 deletions
diff --git a/test/litest.c b/test/litest.c
index 29820a7e..e028176d 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);
}
@@ -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);
+}
diff --git a/test/litest.h b/test/litest.h
index c40427db..26b30407 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -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