summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-03 13:58:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-21 10:03:58 +1000
commit9495713b05d244b0293cbf4fc5e6a7094ee50e27 (patch)
tree4bb6a23fa9c3108bc3164e20bb620d0ae3618cd7 /test
parent7d1a047b7c2f7acf6fdce5ac5d352bd909605234 (diff)
touchpad: add MT_TOOL-based palm detection
If the touchpad driver tells us something is a palm, go with that. https://bugs.freedesktop.org/show_bug.cgi?id=100243 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r--test/test-touchpad.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/test-touchpad.c b/test/test-touchpad.c
index c0de99b..2731500 100644
--- a/test/test-touchpad.c
+++ b/test/test-touchpad.c
@@ -1293,6 +1293,86 @@ START_TEST(touchpad_palm_detect_both_edges)
}
END_TEST
+static inline bool
+touchpad_has_tool_palm(struct litest_device *dev)
+{
+ return libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_TOOL_TYPE);
+}
+
+START_TEST(touchpad_palm_detect_tool_palm)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ if (!touchpad_has_tool_palm(dev))
+ return;
+
+ litest_touch_down(dev, 0, 50, 50);
+ litest_touch_move_to(dev, 0, 50, 50, 70, 70, 10, 1);
+ litest_drain_events(li);
+
+ litest_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_touch_move_to(dev, 0, 70, 70, 50, 40, 10, 1);
+ litest_touch_up(dev, 0);
+
+ litest_assert_empty_queue(li);
+}
+END_TEST
+
+START_TEST(touchpad_palm_detect_tool_palm_on_off)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ if (!touchpad_has_tool_palm(dev))
+ return;
+
+ litest_touch_down(dev, 0, 50, 50);
+ litest_touch_move_to(dev, 0, 50, 50, 70, 70, 10, 1);
+ litest_drain_events(li);
+
+ litest_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_touch_move_to(dev, 0, 70, 70, 50, 40, 10, 1);
+
+ litest_assert_empty_queue(li);
+
+ litest_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_touch_move_to(dev, 0, 50, 40, 70, 70, 10, 1);
+ litest_touch_up(dev, 0);
+
+ litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+}
+END_TEST
+
+START_TEST(touchpad_palm_detect_tool_palm_tap)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ if (!touchpad_has_tool_palm(dev))
+ return;
+
+ litest_enable_tap(dev->libinput_device);
+ litest_drain_events(li);
+
+ litest_push_event_frame(dev);
+ litest_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
+ litest_touch_down(dev, 0, 50, 50);
+ litest_pop_event_frame(dev);
+ libinput_dispatch(li);
+ litest_assert_empty_queue(li);
+
+ litest_touch_up(dev, 0);
+ libinput_dispatch(li);
+ litest_timeout_tap();
+
+ litest_assert_empty_queue(li);
+}
+END_TEST
+
START_TEST(touchpad_left_handed)
{
struct litest_device *dev = litest_current_device();
@@ -4987,6 +5067,9 @@ litest_setup_tests_touchpad(void)
litest_add("touchpad:palm", touchpad_no_palm_detect_at_edge_for_edge_scrolling, LITEST_TOUCHPAD, LITEST_CLICKPAD);
litest_add("touchpad:palm", touchpad_no_palm_detect_2fg_scroll, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:palm", touchpad_palm_detect_both_edges, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+ litest_add("touchpad:palm", touchpad_palm_detect_tool_palm, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+ litest_add("touchpad:palm", touchpad_palm_detect_tool_palm_on_off, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+ litest_add("touchpad:palm", touchpad_palm_detect_tool_palm_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:left-handed", touchpad_left_handed, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD);
litest_add_for_device("touchpad:left-handed", touchpad_left_handed_appletouch, LITEST_APPLETOUCH);