test: split 3-finger tap-and-drag test
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 4 Mar 2015 02:24:09 +0000 (12:24 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 5 Mar 2015 03:30:49 +0000 (13:30 +1000)
Split out into a btntool test and a true three-finger test. For consistency,
check the number of slots on all those tests rather than having
litest-device-specific exclusions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
test/touchpad.c

index 773d085..34ac899 100644 (file)
@@ -231,6 +231,10 @@ START_TEST(touchpad_2fg_tap_n_drag_3fg_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_device_config_tap_set_enabled(dev->libinput_device,
                                               LIBINPUT_CONFIG_TAP_ENABLED);
 
@@ -268,6 +272,49 @@ START_TEST(touchpad_2fg_tap_n_drag_3fg_btntool)
 }
 END_TEST
 
+START_TEST(touchpad_2fg_tap_n_drag_3fg)
+{
+       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_device_config_tap_set_enabled(dev->libinput_device,
+                                              LIBINPUT_CONFIG_TAP_ENABLED);
+
+       litest_drain_events(li);
+
+       litest_touch_down(dev, 0, 30, 70);
+       litest_touch_up(dev, 0);
+       litest_touch_down(dev, 0, 30, 70);
+       litest_touch_down(dev, 1, 80, 90);
+       litest_touch_move_to(dev, 0, 30, 70, 30, 30, 5, 40);
+       libinput_dispatch(li);
+
+       litest_assert_button_event(li, BTN_LEFT,
+                                  LIBINPUT_BUTTON_STATE_PRESSED);
+
+       litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+
+       /* Putting down a third finger should end the drag */
+       litest_touch_down(dev, 2, 50, 50);
+
+       libinput_dispatch(li);
+
+       litest_assert_button_event(li, BTN_LEFT,
+                                  LIBINPUT_BUTTON_STATE_RELEASED);
+
+       /* Releasing the fingers should not cause any events */
+       litest_touch_up(dev, 2);
+       litest_touch_up(dev, 1);
+       litest_touch_up(dev, 0);
+
+       litest_assert_empty_queue(li);
+}
+END_TEST
+
 START_TEST(touchpad_2fg_tap)
 {
        struct litest_device *dev = litest_current_device();
@@ -618,6 +665,10 @@ START_TEST(touchpad_3fg_tap)
        struct libinput_event *event;
        int i;
 
+       if (libevdev_get_abs_maximum(dev->evdev,
+                                    ABS_MT_SLOT) <= 2)
+               return;
+
        libinput_device_config_tap_set_enabled(dev->libinput_device,
                                               LIBINPUT_CONFIG_TAP_ENABLED);
 
@@ -653,6 +704,10 @@ START_TEST(touchpad_3fg_tap_btntool)
        struct libinput *li = dev->libinput;
        struct libinput_event *event;
 
+       if (libevdev_get_abs_maximum(dev->evdev,
+                                    ABS_MT_SLOT) > 2)
+               return;
+
        libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
 
        litest_drain_events(li);
@@ -688,6 +743,10 @@ START_TEST(touchpad_3fg_tap_btntool_inverted)
        struct libinput *li = dev->libinput;
        struct libinput_event *event;
 
+       if (libevdev_get_abs_maximum(dev->evdev,
+                                    ABS_MT_SLOT) > 2)
+               return;
+
        libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
 
        litest_drain_events(li);
@@ -3278,6 +3337,7 @@ int main(int argc, char **argv) {
        litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_timeout, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:tap", touchpad_2fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
+       litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_CLICKPAD);
@@ -3288,10 +3348,9 @@ int main(int argc, char **argv) {
        litest_add("touchpad:tap", touchpad_no_2fg_tap_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
-       /* apple is the only one with real 3-finger support */
-       litest_add("touchpad:tap", touchpad_3fg_tap_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
-       litest_add("touchpad:tap", touchpad_3fg_tap_btntool_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
-       litest_add("touchpad:tap", touchpad_3fg_tap, LITEST_APPLE_CLICKPAD, LITEST_ANY);
+       litest_add("touchpad:tap", touchpad_3fg_tap_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+       litest_add("touchpad:tap", touchpad_3fg_tap_btntool_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+       litest_add("touchpad:tap", touchpad_3fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
 
        /* Real buttons don't interfere with tapping, so don't run those for
           pads with buttons */