mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 15:00:05 +01:00
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>
This commit is contained in:
parent
5e256e4f49
commit
e4adbff919
4 changed files with 34 additions and 19 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue