mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-19 07:00:25 +01:00
test: add test for touchpad disabling on external mouse
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
52cd361907
commit
8fad73b67a
1 changed files with 183 additions and 0 deletions
183
test/touchpad.c
183
test/touchpad.c
|
|
@ -4436,6 +4436,184 @@ START_TEST(touchpad_jump_finger_motion)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(touchpad_disabled_on_mouse)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct litest_device *mouse;
|
||||
struct libinput *li = dev->libinput;
|
||||
enum libinput_config_status status;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
dev->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
mouse = litest_add_device(li, LITEST_MOUSE);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_delete_device(mouse);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(touchpad_disabled_on_mouse_suspend_mouse)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct litest_device *mouse;
|
||||
struct libinput *li = dev->libinput;
|
||||
enum libinput_config_status status;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
dev->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
mouse = litest_add_device(li, LITEST_MOUSE);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
|
||||
/* Disable external mouse -> expect touchpad events */
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
mouse->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
litest_delete_device(mouse);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(touchpad_disabled_double_mouse)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct litest_device *mouse1, *mouse2;
|
||||
struct libinput *li = dev->libinput;
|
||||
enum libinput_config_status status;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
dev->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
mouse1 = litest_add_device(li, LITEST_MOUSE);
|
||||
mouse2 = litest_add_device(li, LITEST_MOUSE);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_delete_device(mouse1);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_delete_device(mouse2);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(touchpad_disabled_double_mouse_one_suspended)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct litest_device *mouse1, *mouse2;
|
||||
struct libinput *li = dev->libinput;
|
||||
enum libinput_config_status status;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
dev->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
mouse1 = litest_add_device(li, LITEST_MOUSE);
|
||||
mouse2 = litest_add_device(li, LITEST_MOUSE);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
|
||||
/* Disable one external mouse -> don't expect touchpad events */
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
mouse1->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_delete_device(mouse1);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_delete_device(mouse2);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
|
||||
|
||||
litest_touch_down(dev, 0, 20, 30);
|
||||
litest_touch_move_to(dev, 0, 20, 30, 90, 30, 10, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void
|
||||
litest_setup_tests_touchpad(void)
|
||||
{
|
||||
|
|
@ -4568,4 +4746,9 @@ litest_setup_tests_touchpad(void)
|
|||
litest_add("touchpad:time", touchpad_time_usec, LITEST_TOUCHPAD, LITEST_ANY);
|
||||
|
||||
litest_add_for_device("touchpad:jumps", touchpad_jump_finger_motion, LITEST_SYNAPTICS_CLICKPAD);
|
||||
|
||||
litest_add_for_device("touchpad:sendevents", touchpad_disabled_on_mouse, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("touchpad:sendevents", touchpad_disabled_on_mouse_suspend_mouse, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("touchpad:sendevents", touchpad_disabled_double_mouse, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("touchpad:sendevents", touchpad_disabled_double_mouse_one_suspended, LITEST_SYNAPTICS_CLICKPAD);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue