Skip to content

Commit

Permalink
test: don't run the MT pressure test on devices without MT pressure
Browse files Browse the repository at this point in the history
This test worked because on devices that don't use pressure the touches were
reset when BTN_TOUCH when to 0, triggering the 'ignore fake fingers when no
real fingers are down' behavior. But this is a different code path than the
pressure handling, so let's separate those tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 990da54)
  • Loading branch information
whot committed Mar 7, 2018
1 parent c4fc987 commit 0fec9c6
Showing 1 changed file with 60 additions and 3 deletions.
63 changes: 60 additions & 3 deletions test/test-touchpad-tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,13 +1591,19 @@ START_TEST(touchpad_3fg_tap_quickrelease)
}
END_TEST

START_TEST(touchpad_3fg_tap_hover_btntool)
START_TEST(touchpad_3fg_tap_pressure_btntool)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;

if (libevdev_get_abs_maximum(dev->evdev,
ABS_MT_SLOT) >= 2)
if (libevdev_get_abs_maximum(dev->evdev, ABS_MT_SLOT) >= 2)
return;

/* libinput doesn't export when it uses pressure detection, so we
* need to reconstruct this here. Specifically, semi-mt devices are
* non-mt in libinput, so if they have ABS_PRESSURE, they'll use it.
*/
if (!libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_PRESSURE))
return;

litest_enable_tap(dev->libinput_device);
Expand All @@ -1616,6 +1622,56 @@ START_TEST(touchpad_3fg_tap_hover_btntool)
/* drop below the pressure threshold in the same frame as starting a */
litest_event(dev, EV_ABS, ABS_MT_PRESSURE, 3);
litest_event(dev, EV_ABS, ABS_PRESSURE, 3);
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
libinput_dispatch(li);

litest_push_event_frame(dev);
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
litest_pop_event_frame(dev);
litest_assert_empty_queue(li);

litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
}
END_TEST

START_TEST(touchpad_3fg_tap_hover_btntool)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;

if (libevdev_get_abs_maximum(dev->evdev, ABS_MT_SLOT) >= 2)
return;

/* libinput doesn't export when it uses pressure detection, so we
* need to reconstruct this here. Specifically, semi-mt devices are
* non-mt in libinput, so if they have ABS_PRESSURE, they'll use it.
*/
if (libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_PRESSURE))
return;

if (libevdev_has_property(dev->evdev, INPUT_PROP_SEMI_MT) &&
libevdev_has_event_code(dev->evdev, EV_ABS, ABS_PRESSURE))
return;

litest_enable_tap(dev->libinput_device);
litest_enable_edge_scroll(dev);

litest_drain_events(li);

litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 70, 50);
libinput_dispatch(li);

litest_touch_move_to(dev, 0, 50, 50, 50, 70, 10, 0);
litest_touch_move_to(dev, 1, 70, 50, 50, 70, 10, 0);
litest_drain_events(li);

/* drop below the pressure threshold in the same frame as starting a
* third touch */
litest_event(dev, EV_KEY, BTN_TOUCH, 0);
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
Expand Down Expand Up @@ -3316,6 +3372,7 @@ litest_setup_tests_touchpad_tap(void)
litest_add("tap-3fg:3fg", touchpad_3fg_tap_tap_again, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("tap-3fg:3fg", touchpad_3fg_tap_quickrelease, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("tap-3fg:3fg", touchpad_3fg_tap_hover_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("tap-3fg:3fg", touchpad_3fg_tap_pressure_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add_for_device("tap-3fg:3fg", touchpad_3fg_tap_btntool_pointerjump, LITEST_SYNAPTICS_TOPBUTTONPAD);
litest_add("tap-4fg:4fg", touchpad_4fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
litest_add("tap-4fg:4fg", touchpad_4fg_tap_quickrelease, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
Expand Down

0 comments on commit 0fec9c6

Please sign in to comment.