[PATCH libinput 02/15] test: fix two tablet tests
Peter Hutterer
peter.hutterer at who-t.net
Tue Feb 17 21:45:03 PST 2015
The serial test was broken, it succeeded even if we never got an event. The
second test was fine, but complicated. Make it use some of the newer litest
features.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/tablet.c | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/test/tablet.c b/test/tablet.c
index 043f78c..1e5947a 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -705,18 +705,14 @@ START_TEST(tool_serial)
litest_event(dev, EV_MSC, MSC_SERIAL, 1000);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
- libinput_dispatch(li);
- while ((event = libinput_get_event(li))) {
- if (libinput_event_get_type(event) ==
- LIBINPUT_EVENT_TABLET_PROXIMITY) {
- tablet_event = libinput_event_get_tablet_event(event);
- tool = libinput_event_tablet_get_tool(tablet_event);
-
- ck_assert_uint_eq(libinput_tool_get_serial(tool), 1000);
- }
-
- libinput_event_destroy(event);
- }
+ litest_wait_for_event_of_type(li,
+ LIBINPUT_EVENT_TABLET_PROXIMITY,
+ -1);
+ event = libinput_get_event(li);
+ tablet_event = libinput_event_get_tablet_event(event);
+ tool = libinput_event_tablet_get_tool(tablet_event);
+ ck_assert_uint_eq(libinput_tool_get_serial(tool), 1000);
+ libinput_event_destroy(event);
}
END_TEST
@@ -727,7 +723,6 @@ START_TEST(serial_changes_tool)
struct libinput_event_tablet *tablet_event;
struct libinput_event *event;
struct libinput_tool *tool;
- bool tool_updated = false;
litest_drain_events(li);
@@ -742,20 +737,15 @@ START_TEST(serial_changes_tool)
litest_event(dev, EV_MSC, MSC_SERIAL, 2000);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
- libinput_dispatch(li);
- while ((event = libinput_get_event(li))) {
- if (libinput_event_get_type(event) ==
- LIBINPUT_EVENT_TABLET_PROXIMITY) {
- tablet_event = libinput_event_get_tablet_event(event);
- tool = libinput_event_tablet_get_tool(tablet_event);
+ litest_wait_for_event_of_type(li,
+ LIBINPUT_EVENT_TABLET_PROXIMITY,
+ -1);
+ event = libinput_get_event(li);
+ tablet_event = libinput_event_get_tablet_event(event);
+ tool = libinput_event_tablet_get_tool(tablet_event);
- ck_assert_uint_eq(libinput_tool_get_serial(tool), 2000);
- tool_updated = true;
- }
-
- libinput_event_destroy(event);
- }
- ck_assert(tool_updated);
+ ck_assert_uint_eq(libinput_tool_get_serial(tool), 2000);
+ libinput_event_destroy(event);
}
END_TEST
--
2.1.0
More information about the wayland-devel
mailing list