test: add helper function for checking for a specific event type
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 18 Dec 2014 01:29:32 +0000 (11:29 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 23 Dec 2014 01:14:39 +0000 (11:14 +1000)
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>
test/litest.c
test/litest.h

index befad5a..392ffe2 100644 (file)
@@ -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);
index 99c6ae3..31011a2 100644 (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,