From c464458f829361e38e4ee07a34538a9660f8d0c5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 18 Dec 2014 11:29:32 +1000 Subject: [PATCH] test: add helper function for checking for a specific event type 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 --- test/litest.c | 21 +++++++++++++++++++++ test/litest.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/test/litest.c b/test/litest.c index befad5aa..392ffe25 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1223,6 +1223,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) { diff --git a/test/litest.h b/test/litest.h index 99c6ae3b..31011a2b 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,