Commit 16b290a7 authored by Peter Hutterer's avatar Peter Hutterer

test: replace litest_button_click with a debounced version

This is via a simple search & replace. Later auditing is needed to switch
clicks that should not be debounced (e.g. touchpads) back to a non-debounced
version.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 8cf6893f)
parent 01ae8bd6
......@@ -2018,7 +2018,10 @@ litest_hover_move_two_touches(struct litest_device *d,
}
void
litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
litest_button_click_debounced(struct litest_device *d,
struct libinput *li,
unsigned int button,
bool is_press)
{
struct input_event *ev;
......@@ -2029,7 +2032,9 @@ litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
ARRAY_FOR_EACH(click, ev)
litest_event(d, ev->type, ev->code, ev->value);
libinput_dispatch(li);
litest_timeout_debounce();
libinput_dispatch(li);
}
void
......@@ -2039,7 +2044,7 @@ litest_button_scroll(struct litest_device *dev,
{
struct libinput *li = dev->libinput;
litest_button_click(dev, button, 1);
litest_button_click_debounced(dev, li, button, 1);
libinput_dispatch(li);
litest_timeout_buttonscroll();
......@@ -2049,7 +2054,7 @@ litest_button_scroll(struct litest_device *dev,
litest_event(dev, EV_REL, REL_Y, dy);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_button_click(dev, button, 0);
litest_button_click_debounced(dev, li, button, 0);
libinput_dispatch(li);
}
......@@ -2057,7 +2062,14 @@ litest_button_scroll(struct litest_device *dev,
void
litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
{
litest_button_click(d, key, is_press);
struct input_event *ev;
struct input_event click[] = {
{ .type = EV_KEY, .code = key, .value = is_press ? 1 : 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
ARRAY_FOR_EACH(click, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
void
......
......@@ -596,9 +596,10 @@ litest_hover_move_two_touches(struct litest_device *d,
int steps, int sleep_ms);
void
litest_button_click(struct litest_device *d,
unsigned int button,
bool is_press);
litest_button_click_debounced(struct litest_device *d,
struct libinput *li,
unsigned int button,
bool is_press);
void
litest_button_scroll(struct litest_device *d,
......
......@@ -463,7 +463,7 @@ START_TEST(device_disable_release_buttons)
device = dev->libinput_device;
litest_button_click(dev, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_drain_events(li);
status = libinput_device_config_send_events_set_mode(device,
......@@ -497,7 +497,7 @@ START_TEST(device_disable_release_keys)
device = dev->libinput_device;
litest_button_click(dev, KEY_A, true);
litest_button_click_debounced(dev, li, KEY_A, true);
litest_drain_events(li);
status = libinput_device_config_send_events_set_mode(device,
......@@ -616,7 +616,7 @@ START_TEST(device_disable_release_softbutton)
litest_drain_events(li);
litest_touch_down(dev, 0, 90, 90);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
/* make sure softbutton works */
litest_assert_button_event(li,
......@@ -633,7 +633,7 @@ START_TEST(device_disable_release_softbutton)
litest_assert_empty_queue(li);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
litest_touch_up(dev, 0);
litest_assert_empty_queue(li);
......@@ -669,8 +669,8 @@ START_TEST(device_disable_topsoftbutton)
litest_drain_events(li);
litest_touch_down(dev, 0, 90, 10);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
litest_touch_up(dev, 0);
litest_wait_for_event(li);
......
......@@ -416,8 +416,8 @@ START_TEST(event_conversion_tablet)
litest_tablet_proximity_in(dev, 50, 50, axes);
litest_tablet_motion(dev, 60, 50, axes);
litest_button_click(dev, BTN_STYLUS, true);
litest_button_click(dev, BTN_STYLUS, false);
litest_button_click_debounced(dev, li, BTN_STYLUS, true);
litest_button_click_debounced(dev, li, BTN_STYLUS, false);
libinput_dispatch(li);
......@@ -458,7 +458,7 @@ START_TEST(event_conversion_tablet_pad)
struct libinput_event *event;
int events = 0;
litest_button_click(dev, BTN_0, true);
litest_button_click_debounced(dev, li, BTN_0, true);
litest_pad_ring_start(dev, 10);
litest_pad_ring_end(dev);
......
......@@ -68,8 +68,8 @@ START_TEST(pad_time)
if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
continue;
litest_button_click(dev, code, 1);
litest_button_click(dev, code, 0);
litest_button_click_debounced(dev, li, code, 1);
litest_button_click_debounced(dev, li, code, 0);
libinput_dispatch(li);
switch (code) {
......@@ -98,8 +98,8 @@ START_TEST(pad_time)
litest_drain_events(li);
msleep(10);
litest_button_click(dev, code, 1);
litest_button_click(dev, code, 0);
litest_button_click_debounced(dev, li, code, 1);
litest_button_click_debounced(dev, li, code, 0);
libinput_dispatch(li);
ev = libinput_get_event(li);
......@@ -156,8 +156,8 @@ START_TEST(pad_button)
if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
continue;
litest_button_click(dev, code, 1);
litest_button_click(dev, code, 0);
litest_button_click_debounced(dev, li, code, 1);
litest_button_click_debounced(dev, li, code, 0);
libinput_dispatch(li);
switch (code) {
......@@ -207,8 +207,8 @@ START_TEST(pad_button_mode_groups)
if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
continue;
litest_button_click(dev, code, 1);
litest_button_click(dev, code, 0);
litest_button_click_debounced(dev, li, code, 1);
litest_button_click_debounced(dev, li, code, 0);
libinput_dispatch(li);
switch (code) {
......
This diff is collapsed.
......@@ -1041,7 +1041,7 @@ START_TEST(clickpad_finger_pin)
litest_touch_move_to(dev, 0, 48, 48, 50, 50, 10, 1);
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_drain_events(li);
litest_touch_move_to(dev, 0, 50, 50, 50 + dist, 50 + dist, 10, 1);
......@@ -1050,7 +1050,7 @@ START_TEST(clickpad_finger_pin)
litest_assert_empty_queue(li);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_BUTTON);
/* still pinned after release */
......@@ -1490,7 +1490,7 @@ START_TEST(clickpad_softbutton_hover_into_buttons)
litest_touch_move_to(dev, 0, 90, 90, 91, 91, 1, 0);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
libinput_dispatch(li);
litest_assert_button_event(li,
......@@ -1498,7 +1498,7 @@ START_TEST(clickpad_softbutton_hover_into_buttons)
LIBINPUT_BUTTON_STATE_PRESSED);
litest_assert_empty_queue(li);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
litest_touch_up(dev, 0);
litest_assert_button_event(li,
......
......@@ -332,8 +332,8 @@ START_TEST(touchpad_1fg_multitap_n_drag_click)
litest_touch_down(dev, 0, 50, 50);
libinput_dispatch(li);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
......@@ -627,8 +627,8 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap_click)
litest_touch_up(dev, 0);
litest_touch_down(dev, 0, 70, 50);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
libinput_dispatch(li);
litest_assert_button_event(li,
......@@ -799,8 +799,8 @@ START_TEST(touchpad_1fg_tap_n_drag_draglock_tap_click)
litest_touch_up(dev, 0);
litest_touch_down(dev, 0, 50, 50);
litest_button_click(dev, BTN_LEFT, true);
litest_button_click(dev, BTN_LEFT, false);
litest_button_click_debounced(dev, li, BTN_LEFT, true);
litest_button_click_debounced(dev, li, BTN_LEFT, false);
libinput_dispatch(li);
litest_assert_button_event(li, BTN_LEFT,
......
This diff is collapsed.
......@@ -43,9 +43,9 @@ START_TEST(trackpoint_middlebutton)
litest_drain_events(li);
/* A quick middle button click should get reported normally */
litest_button_click(dev, BTN_MIDDLE, 1);
litest_button_click_debounced(dev, li, BTN_MIDDLE, 1);
msleep(2);
litest_button_click(dev, BTN_MIDDLE, 0);
litest_button_click_debounced(dev, li, BTN_MIDDLE, 0);
litest_wait_for_event(li);
......@@ -173,7 +173,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_trackpoint)
litest_touch_down(touchpad, 0, 5, 5);
libinput_dispatch(li);
litest_button_click(touchpad, BTN_LEFT, true);
litest_button_click_debounced(touchpad, li, BTN_LEFT, true);
libinput_dispatch(li);
event = libinput_get_event(li);
......@@ -184,7 +184,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_trackpoint)
ck_assert(device == trackpoint->libinput_device);
libinput_event_destroy(event);
litest_button_click(touchpad, BTN_LEFT, false);
litest_button_click_debounced(touchpad, li, BTN_LEFT, false);
libinput_dispatch(li);
event = libinput_get_event(li);
litest_is_button_event(event,
......@@ -216,7 +216,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_touchpad)
litest_touch_down(touchpad, 0, 5, 5);
libinput_dispatch(li);
litest_button_click(touchpad, BTN_LEFT, true);
litest_button_click_debounced(touchpad, li, BTN_LEFT, true);
libinput_dispatch(li);
event = libinput_get_event(li);
......@@ -225,7 +225,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_touchpad)
ck_assert(device == trackpoint->libinput_device);
libinput_event_destroy(event);
litest_button_click(touchpad, BTN_LEFT, false);
litest_button_click_debounced(touchpad, li, BTN_LEFT, false);
libinput_dispatch(li);
event = libinput_get_event(li);
litest_is_button_event(event,
......@@ -260,7 +260,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_both)
litest_touch_down(touchpad, 0, 5, 5);
libinput_dispatch(li);
litest_button_click(touchpad, BTN_LEFT, true);
litest_button_click_debounced(touchpad, li, BTN_LEFT, true);
libinput_dispatch(li);
event = libinput_get_event(li);
......@@ -271,7 +271,7 @@ START_TEST(trackpoint_topsoftbuttons_left_handed_both)
ck_assert(device == trackpoint->libinput_device);
libinput_event_destroy(event);
litest_button_click(touchpad, BTN_LEFT, false);
litest_button_click_debounced(touchpad, li, BTN_LEFT, false);
libinput_dispatch(li);
event = libinput_get_event(li);
litest_is_button_event(event,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment