For the case where we don't care about a specific set of events in the queue and want to jump over them.
Signed-off-by: Peter Hutterer <[email protected]> --- test/litest.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/litest.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/test/litest.c b/test/litest.c index 7d48278..643c168 100644 --- a/test/litest.c +++ b/test/litest.c @@ -899,6 +899,51 @@ litest_drain_events(struct libinput *li) } } +void +litest_drain_typed_events(struct libinput *li, ...) +{ + va_list args; + enum libinput_event_type types[32] = {LIBINPUT_EVENT_NONE}; + size_t ntypes = 0; + enum libinput_event_type type; + + + va_start(args, li); + type = va_arg(args, int); + while ((int)type != -1) { + assert(type > 0); + assert(ntypes < ARRAY_LENGTH(types)); + types[ntypes++] = type; + type = va_arg(args, int); + } + va_end(args); + + libinput_dispatch(li); + + while (1) { + bool found; + size_t i; + struct libinput_event *event; + + type = libinput_next_event_type(li); + if (type == LIBINPUT_EVENT_NONE) + break; + + found = false; + for (i = 0; i < ntypes; i++) { + if (type == types[i]) { + found = true; + break; + } + } + if (!found) + break; + + event = libinput_get_event(li); + libinput_event_destroy(event); + } +} + static const char * litest_event_type_str(struct libinput_event *event) { diff --git a/test/litest.h b/test/litest.h index 2d4b4d8..f551bde 100644 --- a/test/litest.h +++ b/test/litest.h @@ -156,6 +156,8 @@ void litest_keyboard_key(struct litest_device *d, void litest_wait_for_event(struct libinput *li); void litest_wait_for_event_of_type(struct libinput *li, ...); void litest_drain_events(struct libinput *li); +void litest_drain_typed_events(struct libinput *li, + ...); void litest_assert_empty_queue(struct libinput *li); void litest_assert_button_event(struct libinput *li, unsigned int button, -- 2.1.0 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
