From: Peter Hutterer Date: Thu, 18 Dec 2014 01:29:32 +0000 (+1000) Subject: test: add helper function for checking for a specific event type X-Git-Tag: 0.8.0~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c464458f829361e38e4ee07a34538a9660f8d0c5;p=platform%2Fupstream%2Flibinput.git 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 --- 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,