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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2014-12-18 11:29:32 +10:00
parent 6138babc12
commit c464458f82
2 changed files with 23 additions and 0 deletions

View file

@ -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)
{

View file

@ -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,