[PATCH libinput 1/2] test: add litest_is_button_event
Peter Hutterer
peter.hutterer at who-t.net
Wed Apr 15 22:04:51 PDT 2015
Makes it easier from a caller to check for common things without all the other
boilerplate code.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/litest.c | 26 +++++++++++++++++++-------
test/litest.h | 4 ++++
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/test/litest.c b/test/litest.c
index 5c4f84d..5600b8e 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1321,16 +1321,13 @@ litest_create_uinput_device(const char *name, struct input_id *id, ...)
return uinput;
}
-void
-litest_assert_button_event(struct libinput *li, unsigned int button,
- enum libinput_button_state state)
+struct libinput_event_pointer*
+litest_is_button_event(struct libinput_event *event,
+ int button,
+ enum libinput_button_state state)
{
- struct libinput_event *event;
struct libinput_event_pointer *ptrev;
- litest_wait_for_event(li);
- event = libinput_get_event(li);
-
ck_assert(event != NULL);
ck_assert_int_eq(libinput_event_get_type(event),
LIBINPUT_EVENT_POINTER_BUTTON);
@@ -1339,6 +1336,21 @@ litest_assert_button_event(struct libinput *li, unsigned int button,
button);
ck_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
state);
+
+ return ptrev;
+}
+
+void
+litest_assert_button_event(struct libinput *li, unsigned int button,
+ enum libinput_button_state state)
+{
+ struct libinput_event *event;
+
+ litest_wait_for_event(li);
+ event = libinput_get_event(li);
+
+ litest_is_button_event(event, button, state);
+
libinput_event_destroy(event);
}
diff --git a/test/litest.h b/test/litest.h
index 84567be..64db8c3 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -172,6 +172,10 @@ 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_assert_empty_queue(struct libinput *li);
+struct libinput_event_pointer * litest_is_button_event(
+ struct libinput_event *event,
+ int button,
+ enum libinput_button_state state);
void litest_assert_button_event(struct libinput *li,
unsigned int button,
enum libinput_button_state state);
--
2.3.4
More information about the wayland-devel
mailing list