test: add dwt modifier/fkey test cases
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 4 Aug 2016 01:00:37 +0000 (11:00 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 4 Aug 2016 02:57:02 +0000 (12:57 +1000)
dwt shouldn't trigger on those keys

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/touchpad.c

index 57e4712..9f78ed7 100644 (file)
@@ -2955,6 +2955,86 @@ START_TEST(touchpad_dwt_type_short_timeout)
 }
 END_TEST
 
+START_TEST(touchpad_dwt_modifier_no_dwt)
+{
+       struct litest_device *touchpad = litest_current_device();
+       struct litest_device *keyboard;
+       struct libinput *li = touchpad->libinput;
+       unsigned int modifiers[] = {
+               KEY_LEFTCTRL,
+               KEY_RIGHTCTRL,
+               KEY_LEFTALT,
+               KEY_RIGHTALT,
+               KEY_LEFTSHIFT,
+               KEY_RIGHTSHIFT,
+               KEY_FN,
+               KEY_CAPSLOCK,
+               KEY_TAB,
+               KEY_COMPOSE,
+               KEY_RIGHTMETA,
+               KEY_LEFTMETA,
+       };
+       unsigned int *key;
+
+       if (!has_disable_while_typing(touchpad))
+               return;
+
+       keyboard = dwt_init_paired_keyboard(li, touchpad);
+       litest_disable_tap(touchpad->libinput_device);
+       litest_drain_events(li);
+
+       ARRAY_FOR_EACH(modifiers, key) {
+               litest_keyboard_key(keyboard, *key, true);
+               litest_keyboard_key(keyboard, *key, false);
+               libinput_dispatch(li);
+
+               litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
+
+               litest_touch_down(touchpad, 0, 50, 50);
+               litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 5, 1);
+               litest_touch_up(touchpad, 0);
+               litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+       }
+
+       litest_delete_device(keyboard);
+}
+END_TEST
+
+START_TEST(touchpad_dwt_fkeys_no_dwt)
+{
+       struct litest_device *touchpad = litest_current_device();
+       struct litest_device *keyboard;
+       struct libinput *li = touchpad->libinput;
+       unsigned int key;
+
+       if (!has_disable_while_typing(touchpad))
+               return;
+
+       keyboard = dwt_init_paired_keyboard(li, touchpad);
+       litest_disable_tap(touchpad->libinput_device);
+       litest_drain_events(li);
+
+       for (key = KEY_F1; key < KEY_CNT; key++) {
+               if (!libinput_device_keyboard_has_key(keyboard->libinput_device,
+                                                     key))
+                       continue;
+
+               litest_keyboard_key(keyboard, key, true);
+               litest_keyboard_key(keyboard, key, false);
+               libinput_dispatch(li);
+
+               litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
+
+               litest_touch_down(touchpad, 0, 50, 50);
+               litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 5, 1);
+               litest_touch_up(touchpad, 0);
+               litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+       }
+
+       litest_delete_device(keyboard);
+}
+END_TEST
+
 START_TEST(touchpad_dwt_tap)
 {
        struct litest_device *touchpad = litest_current_device();
@@ -4227,6 +4307,8 @@ litest_setup_tests(void)
        litest_add("touchpad:dwt", touchpad_dwt_key_hold_timeout_existing_touch_cornercase, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_type, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_type_short_timeout, LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("touchpad:dwt", touchpad_dwt_modifier_no_dwt, LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("touchpad:dwt", touchpad_dwt_fkeys_no_dwt, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_tap, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_tap_drag, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_click, LITEST_TOUCHPAD, LITEST_ANY);