[PATCH v2 libinput 5.1/6] test: add litest_assert_touch_sequence helper

Peter Hutterer peter.hutterer at who-t.net
Tue Sep 6 01:01:29 UTC 2016


Touch sequences are interrupted by TOUCH_FRAME events which makes them
annoying to handle event-by-event.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- new in this series

 test/litest.c | 33 +++++++++++++++++++++++++++++++++
 test/litest.h |  3 +++
 2 files changed, 36 insertions(+)

diff --git a/test/litest.c b/test/litest.c
index 78ff71c..f00d128 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -2850,6 +2850,39 @@ litest_assert_only_typed_events(struct libinput *li,
 }
 
 void
+litest_assert_touch_sequence(struct libinput *li)
+{
+	struct libinput_event *event;
+
+	event = libinput_get_event(li);
+	litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
+	libinput_event_destroy(event);
+
+	event = libinput_get_event(li);
+	litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
+	libinput_event_destroy(event);
+
+	event = libinput_get_event(li);
+	do {
+		litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_MOTION);
+		libinput_event_destroy(event);
+
+		event = libinput_get_event(li);
+		litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
+		libinput_event_destroy(event);
+
+		event = libinput_get_event(li);
+		litest_assert_notnull(event);
+	} while (libinput_event_get_type(event) != LIBINPUT_EVENT_TOUCH_UP);
+
+	litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_UP);
+	libinput_event_destroy(event);
+	event = libinput_get_event(li);
+	litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
+	libinput_event_destroy(event);
+}
+
+void
 litest_timeout_tap(void)
 {
 	msleep(200);
diff --git a/test/litest.h b/test/litest.h
index 8011a41..7dada4c 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -536,6 +536,9 @@ litest_assert_event_type(struct libinput_event *event,
 void
 litest_assert_empty_queue(struct libinput *li);
 
+void
+litest_assert_touch_sequence(struct libinput *li);
+
 struct libinput_event_pointer *
 litest_is_button_event(struct libinput_event *event,
 		       unsigned int button,
-- 
2.7.4



More information about the wayland-devel mailing list