diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-09-16 16:08:29 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-09-23 14:38:37 +1000 |
commit | e4adbff919223861bb2630eb413c1c64d02dfd57 (patch) | |
tree | 39e452a1bd540e34f009bdcc81c9201017db3efb /test | |
parent | 5e256e4f49abf018791f52d5e01faf5d4b5b00a6 (diff) | |
download | libinput-e4adbff919223861bb2630eb413c1c64d02dfd57.tar.gz |
test: add helper functions for the two timers we care about
Rather than a random msleep() with a comment, use a helper function that
describes what we're waiting for. Also makes changing the timeouts easier in
the future.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/device.c | 4 | ||||
-rw-r--r-- | test/litest.c | 12 | ||||
-rw-r--r-- | test/litest.h | 3 | ||||
-rw-r--r-- | test/touchpad.c | 34 |
4 files changed, 34 insertions, 19 deletions
diff --git a/test/device.c b/test/device.c index 33aae04e..3061ebc6 100644 --- a/test/device.c +++ b/test/device.c @@ -404,7 +404,7 @@ START_TEST(device_disable_release_tap) ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); /* tap happened before suspending, so we still expect the event */ - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_LEFT, @@ -443,7 +443,7 @@ START_TEST(device_disable_release_tap_n_drag) litest_touch_up(dev, 0); litest_touch_down(dev, 0, 50, 50); libinput_dispatch(li); - msleep(400); /* tap-n-drag timeout */ + litest_timeout_tap(); libinput_dispatch(li); status = libinput_device_config_send_events_set_mode(device, diff --git a/test/litest.c b/test/litest.c index e5092b8c..29820a7e 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1123,3 +1123,15 @@ void litest_assert_scroll(struct libinput *li, unsigned int axis, int dir) next_event = libinput_get_event(li); } } + +void +litest_timeout_tap(void) +{ + msleep(200); +} + +void +litest_timeout_softbuttons(void) +{ + msleep(300); +} diff --git a/test/litest.h b/test/litest.h index fca6acb3..c40427db 100644 --- a/test/litest.h +++ b/test/litest.h @@ -158,6 +158,9 @@ struct libevdev_uinput * litest_create_uinput_abs_device(const char *name, const struct input_absinfo *abs, ...); +void litest_timeout_tap(void); +void litest_timeout_softbuttons(void); + #ifndef ck_assert_notnull #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL) #endif diff --git a/test/touchpad.c b/test/touchpad.c index 717cb692..c89a71cd 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -107,7 +107,7 @@ START_TEST(touchpad_1fg_tap) litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); @@ -162,7 +162,7 @@ START_TEST(touchpad_1fg_tap_n_drag) ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); @@ -185,7 +185,7 @@ START_TEST(touchpad_1fg_tap_n_drag_timeout) litest_touch_up(dev, 0); litest_touch_down(dev, 0, 50, 50); libinput_dispatch(li); - msleep(300); + litest_timeout_tap(); litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); @@ -219,7 +219,7 @@ START_TEST(touchpad_2fg_tap) litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED); @@ -246,7 +246,7 @@ START_TEST(touchpad_2fg_tap_inverted) litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED); @@ -274,7 +274,7 @@ START_TEST(touchpad_1fg_tap_click) litest_event(dev, EV_KEY, BTN_LEFT, 0); litest_event(dev, EV_SYN, SYN_REPORT, 0); libinput_dispatch(li); - msleep(200); + litest_timeout_tap(); libinput_dispatch(li); @@ -423,7 +423,7 @@ START_TEST(touchpad_no_2fg_tap_after_timeout) */ litest_touch_down(dev, 0, 50, 50); libinput_dispatch(dev->libinput); - msleep(300); + litest_timeout_tap(); libinput_dispatch(dev->libinput); litest_drain_events(dev->libinput); @@ -577,7 +577,7 @@ START_TEST(touchpad_3fg_tap) litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_RELEASED); @@ -613,7 +613,7 @@ START_TEST(touchpad_3fg_tap_btntool) litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_RELEASED); @@ -648,7 +648,7 @@ START_TEST(touchpad_3fg_tap_btntool_inverted) litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_PRESSED); - msleep(300); /* tap-n-drag timeout */ + litest_timeout_tap(); litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_RELEASED); @@ -750,7 +750,7 @@ START_TEST(clickpad_1fg_tap_click) litest_event(dev, EV_SYN, SYN_REPORT, 0); litest_touch_up(dev, 0); libinput_dispatch(li); - msleep(200); + litest_timeout_tap(); libinput_dispatch(li); @@ -999,7 +999,7 @@ START_TEST(clickpad_softbutton_left_1st_fg_move) /* move out of the area, then wait for softbutton timer */ litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10); libinput_dispatch(li); - msleep(400); + litest_timeout_softbuttons(); libinput_dispatch(li); litest_drain_events(li); @@ -1302,13 +1302,13 @@ START_TEST(clickpad_topsoftbuttons_move_out_ignore) litest_touch_down(dev, 0, 50, 5); libinput_dispatch(li); - msleep(200); + litest_timeout_softbuttons(); libinput_dispatch(li); litest_assert_empty_queue(li); litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20); libinput_dispatch(li); - msleep(400); + litest_timeout_softbuttons(); libinput_dispatch(li); litest_event(dev, EV_KEY, BTN_LEFT, 1); @@ -1323,7 +1323,7 @@ START_TEST(clickpad_topsoftbuttons_move_out_ignore) END_TEST static void -test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep) +test_2fg_scroll(struct litest_device *dev, double dx, double dy, int want_sleep) { struct libinput *li = dev->libinput; @@ -1334,9 +1334,9 @@ test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep) litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5); /* Avoid a small scroll being seen as a tap */ - if (sleep) { + if (want_sleep) { libinput_dispatch(li); - msleep(sleep); + litest_timeout_tap(); libinput_dispatch(li); } |