[PATCH libinput 2/5] test: add helper function for checking for a specific event type
Peter Hutterer
peter.hutterer at who-t.net
Thu Dec 18 15:24:51 PST 2014
In a few tests we care about that a specific set of events are in the queue
but not about the details of the events (usually checked elsewhere). Instead
of manual loops, provide a helper function that also checks that there is at
least one of those events in the queue.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/litest.c | 21 +++++++++++++++++++++
test/litest.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/test/litest.c b/test/litest.c
index befad5a..392ffe2 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1224,6 +1224,27 @@ litest_assert_scroll(struct libinput *li,
}
void
+litest_assert_only_typed_events(struct libinput *li,
+ enum libinput_event_type type)
+{
+ struct libinput_event *event;
+
+ assert(type != LIBINPUT_EVENT_NONE);
+
+ libinput_dispatch(li);
+ event = libinput_get_event(li);
+ ck_assert_notnull(event);
+
+ while (event) {
+ ck_assert_int_eq(libinput_event_get_type(event),
+ type);
+ libinput_event_destroy(event);
+ libinput_dispatch(li);
+ event = libinput_get_event(li);
+ }
+}
+
+void
litest_timeout_tap(void)
{
msleep(200);
diff --git a/test/litest.h b/test/litest.h
index 99c6ae3..31011a2 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -162,6 +162,8 @@ void litest_assert_button_event(struct libinput *li,
void litest_assert_scroll(struct libinput *li,
enum libinput_pointer_axis axis,
int minimum_movement);
+void litest_assert_only_typed_events(struct libinput *li,
+ enum libinput_event_type type);
struct libevdev_uinput * litest_create_uinput_device(const char *name,
struct input_id *id,
--
2.1.0
More information about the wayland-devel
mailing list