2014-01-30 15:40:35 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014 Red Hat, Inc.
|
|
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2014-01-30 15:40:35 +10:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2014-01-30 15:40:35 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <libinput.h>
|
|
|
|
|
#include <libudev.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "litest.h"
|
2014-08-20 10:32:29 +10:00
|
|
|
#include "libinput-util.h"
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
START_TEST(device_sendevents_config)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
uint32_t modes;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
modes = libinput_device_config_send_events_get_modes(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(modes,
|
2024-10-11 13:55:56 +10:00
|
|
|
(uint32_t)LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2014-01-30 15:40:35 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-10-30 15:36:52 +10:00
|
|
|
START_TEST(device_sendevents_config_invalid)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
2021-11-18 10:10:49 +10:00
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED | bit(4));
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2014-10-30 15:36:52 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-09-03 15:45:57 +10:00
|
|
|
START_TEST(device_sendevents_config_touchpad)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device;
|
2015-03-04 10:27:22 +10:00
|
|
|
uint32_t modes, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
|
|
|
|
|
|
|
|
|
|
/* The wacom devices in the test suite are external */
|
2015-07-10 12:01:15 +10:00
|
|
|
if (libevdev_get_id_vendor(dev->evdev) != VENDOR_ID_WACOM &&
|
2017-03-23 14:54:00 +10:00
|
|
|
!litest_touchpad_is_external(dev))
|
2015-03-04 10:27:22 +10:00
|
|
|
expected |=
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
|
2014-09-03 15:45:57 +10:00
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
modes = libinput_device_config_send_events_get_modes(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(modes, expected);
|
2014-09-03 15:45:57 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-10-30 15:36:52 +10:00
|
|
|
START_TEST(device_sendevents_config_touchpad_superset)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
uint32_t modes;
|
|
|
|
|
|
2015-03-04 10:27:22 +10:00
|
|
|
/* The wacom devices in the test suite are external */
|
2015-07-10 12:01:15 +10:00
|
|
|
if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_WACOM ||
|
2017-03-23 14:54:00 +10:00
|
|
|
litest_touchpad_is_external(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-03-04 10:27:22 +10:00
|
|
|
|
2014-10-30 15:36:52 +10:00
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
modes = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED |
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
modes);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-10-30 15:36:52 +10:00
|
|
|
|
|
|
|
|
/* DISABLED supersedes the rest, expect the rest to be dropped */
|
|
|
|
|
modes = libinput_device_config_send_events_get_mode(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(modes, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2014-10-30 15:36:52 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-01-30 15:40:35 +10:00
|
|
|
START_TEST(device_sendevents_config_default)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
uint32_t mode;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
mode = libinput_device_config_send_events_get_mode(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(mode,
|
2014-01-30 15:40:35 +10:00
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
|
|
|
|
|
|
|
|
|
mode = libinput_device_config_send_events_get_default_mode(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(mode,
|
2014-01-30 15:40:35 +10:00
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
2014-12-10 11:01:08 +10:00
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct litest_device *tmp;
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
/* no event from disabling */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* no event from disabled device */
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 10);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2014-12-10 11:01:08 +10:00
|
|
|
/* create a new device so the resumed fd isn't the same as the
|
|
|
|
|
suspended one */
|
|
|
|
|
tmp = litest_add_device(li, LITEST_KEYBOARD);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(tmp);
|
2014-12-10 11:01:08 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2014-01-30 15:40:35 +10:00
|
|
|
/* no event from resuming */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
litest_assert_empty_queue(li);
|
2014-12-10 11:01:08 +10:00
|
|
|
|
2020-08-27 19:52:34 +02:00
|
|
|
/* event from re-enabled device */
|
2014-12-10 11:01:08 +10:00
|
|
|
litest_event(dev, EV_REL, REL_X, 10);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-12-10 11:01:08 +10:00
|
|
|
event = libinput_get_event(li);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(event);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-12-10 11:01:08 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(tmp);
|
2014-01-30 15:40:35 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2020-05-22 11:39:49 +10:00
|
|
|
START_TEST(device_disable_tablet)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_DISTANCE, 10 },
|
|
|
|
|
{ ABS_PRESSURE, 0 },
|
|
|
|
|
{ -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2020-05-22 11:39:49 +10:00
|
|
|
|
|
|
|
|
/* no event from disabling */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_tablet_proximity_in(dev, 60, 60, axes);
|
|
|
|
|
for (int i = 60; i < 70; i++) {
|
|
|
|
|
litest_tablet_motion(dev, i, i, axes);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2020-05-22 11:39:49 +10:00
|
|
|
}
|
|
|
|
|
litest_tablet_proximity_out(dev);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* no event from resuming */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2020-05-22 11:39:49 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-08-20 10:32:29 +10:00
|
|
|
START_TEST(device_disable_touchpad)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
/* no event from disabling */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* no event from resuming */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-08-02 17:03:54 +10:00
|
|
|
START_TEST(device_disable_touch)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-08-02 17:03:54 +10:00
|
|
|
|
|
|
|
|
/* no event from disabling */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* no event from resuming */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable_touch_during_touch)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-08-02 17:03:54 +10:00
|
|
|
|
|
|
|
|
/* after disabling sendevents we require a touch up */
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-08-02 17:03:54 +10:00
|
|
|
event = libinput_get_event(li);
|
2018-09-20 14:09:31 +10:00
|
|
|
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_CANCEL);
|
2016-08-02 17:03:54 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 90, 90, 50, 50, 10);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* no event from resuming */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-08-02 17:03:54 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-01-30 15:40:35 +10:00
|
|
|
START_TEST(device_disable_events_pending)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* put a couple of events in the queue, enough to
|
|
|
|
|
feed the ptraccel trackers */
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 10);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
/* expect above events */
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
while ((event = libinput_get_event(li)) != NULL) {
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-01-30 15:40:35 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_double_disable)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_double_enable)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_reenable_syspath_changed)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *litest_device;
|
2016-08-01 14:38:34 +10:00
|
|
|
struct libinput_device *device1;
|
2014-01-30 15:40:35 +10:00
|
|
|
enum libinput_config_status status;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2014-01-30 15:40:35 +10:00
|
|
|
litest_device = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
device1 = litest_device->libinput_device;
|
|
|
|
|
|
|
|
|
|
libinput_device_ref(device1);
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device1,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(litest_device);
|
2014-01-30 15:40:35 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_device = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device1,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
/* can't really check for much here, other than that if we pump
|
|
|
|
|
events through libinput, none of them should be from the first
|
|
|
|
|
device */
|
|
|
|
|
litest_event(litest_device, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(litest_device, EV_REL, REL_Y, 1);
|
|
|
|
|
litest_event(litest_device, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-30 15:40:35 +10:00
|
|
|
while ((event = libinput_get_event(li))) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_event_get_device(event) != device1);
|
2014-01-30 15:40:35 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(litest_device);
|
2014-01-30 15:40:35 +10:00
|
|
|
libinput_device_unref(device1);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_reenable_device_removed)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *litest_device;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2014-01-30 15:40:35 +10:00
|
|
|
litest_device = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
device = litest_device->libinput_device;
|
|
|
|
|
|
|
|
|
|
libinput_device_ref(device);
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(litest_device);
|
2014-01-30 15:40:35 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-01-30 15:40:35 +10:00
|
|
|
|
|
|
|
|
/* can't really check for much here, this really just exercises the
|
|
|
|
|
code path. */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
libinput_device_unref(device);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-08-20 10:32:29 +10:00
|
|
|
START_TEST(device_disable_release_buttons)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrevent;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-08-20 10:32:29 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
|
|
|
|
ptrevent = libinput_event_get_pointer_event(event);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(ptrevent),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)BTN_LEFT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(ptrevent),
|
2014-08-20 10:32:29 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable_release_keys)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_keyboard *kbdevent;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
2017-11-20 10:58:00 +10:00
|
|
|
litest_keyboard_key(dev, KEY_A, true);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-08-20 10:32:29 +10:00
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
kbdevent = libinput_event_get_keyboard_event(event);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_keyboard_get_key(kbdevent),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)KEY_A);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_keyboard_get_key_state(kbdevent),
|
2014-08-20 10:32:29 +10:00
|
|
|
LIBINPUT_KEY_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable_release_tap)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
/* tap happened before suspending, so we still expect the event */
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_tap(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_LEFT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_LEFT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* resume, make sure we don't get anything */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable_release_tap_n_drag)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_tap(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_LEFT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_LEFT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_disable_release_softbutton)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 90, 90);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
/* make sure softbutton works */
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_RIGHT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
/* disable */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-08-20 10:32:29 +10:00
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_RIGHT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* resume, make sure we don't get anything */
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 10:32:29 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-09-16 16:22:42 +02:00
|
|
|
START_TEST(device_disable_topsoftbutton)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct litest_device *trackpoint;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrevent;
|
|
|
|
|
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
trackpoint = litest_add_device(li, LITEST_TRACKPOINT);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-09-16 16:22:42 +02:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 90, 10);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2014-09-16 16:22:42 +02:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
event = libinput_get_event(li);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-09-16 16:22:42 +02:00
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_ptr_eq(libinput_event_get_device(event),
|
2014-09-16 16:22:42 +02:00
|
|
|
trackpoint->libinput_device);
|
|
|
|
|
ptrevent = libinput_event_get_pointer_event(event);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(ptrevent),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)BTN_RIGHT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(ptrevent),
|
2014-09-16 16:22:42 +02:00
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(event),
|
2014-09-16 16:22:42 +02:00
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_ptr_eq(libinput_event_get_device(event),
|
2014-09-16 16:22:42 +02:00
|
|
|
trackpoint->libinput_device);
|
|
|
|
|
ptrevent = libinput_event_get_pointer_event(event);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(ptrevent),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)BTN_RIGHT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(ptrevent),
|
2014-09-16 16:22:42 +02:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(trackpoint);
|
2014-09-16 16:22:42 +02:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-12-01 13:21:26 +10:00
|
|
|
START_TEST(device_ids)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
const char *name;
|
2024-02-28 16:18:54 +01:00
|
|
|
unsigned int bus, pid, vid;
|
2014-12-01 13:21:26 +10:00
|
|
|
|
|
|
|
|
name = libevdev_get_name(dev->evdev);
|
2024-02-28 16:18:54 +01:00
|
|
|
bus = libevdev_get_id_bustype(dev->evdev);
|
2014-12-01 13:21:26 +10:00
|
|
|
pid = libevdev_get_id_product(dev->evdev);
|
|
|
|
|
vid = libevdev_get_id_vendor(dev->evdev);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_str_eq(name,
|
2014-12-01 13:21:26 +10:00
|
|
|
libinput_device_get_name(dev->libinput_device));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(bus,
|
2024-02-28 16:18:54 +01:00
|
|
|
libinput_device_get_id_bustype(dev->libinput_device));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(pid,
|
2014-12-01 13:21:26 +10:00
|
|
|
libinput_device_get_id_product(dev->libinput_device));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(vid,
|
2014-12-01 13:21:26 +10:00
|
|
|
libinput_device_get_id_vendor(dev->libinput_device));
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-10-31 10:53:53 +10:00
|
|
|
START_TEST(device_get_udev_handle)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct udev_device *udev_device;
|
|
|
|
|
|
|
|
|
|
udev_device = libinput_device_get_udev_device(dev->libinput_device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(udev_device);
|
2014-10-31 10:53:53 +10:00
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-12-01 16:00:13 +10:00
|
|
|
START_TEST(device_context)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_seat *seat;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(dev->libinput == libinput_device_get_context(dev->libinput_device));
|
2014-12-01 16:00:13 +10:00
|
|
|
seat = libinput_device_get_seat(dev->libinput_device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(dev->libinput == libinput_seat_get_context(seat));
|
2014-12-01 16:00:13 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-01-13 15:39:07 +10:00
|
|
|
START_TEST(device_user_data)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
void *userdata = &dev; /* not referenced */
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_get_user_data(device) == NULL);
|
2017-01-13 15:39:07 +10:00
|
|
|
libinput_device_set_user_data(device, userdata);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_ptr_eq(libinput_device_get_user_data(device), userdata);
|
2017-01-13 15:39:07 +10:00
|
|
|
libinput_device_set_user_data(device, NULL);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_get_user_data(device) == NULL);
|
2017-01-13 15:39:07 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
START_TEST(device_group_get)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device_group *group;
|
|
|
|
|
|
|
|
|
|
int userdata = 10;
|
|
|
|
|
|
|
|
|
|
group = libinput_device_get_device_group(dev->libinput_device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(group);
|
2015-02-05 13:39:04 +10:00
|
|
|
|
|
|
|
|
libinput_device_group_ref(group);
|
|
|
|
|
|
|
|
|
|
libinput_device_group_set_user_data(group, &userdata);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_ptr_eq(&userdata,
|
2015-02-05 13:39:04 +10:00
|
|
|
libinput_device_group_get_user_data(group));
|
|
|
|
|
|
|
|
|
|
libinput_device_group_unref(group);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_group_ref)
|
|
|
|
|
{
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-02-05 13:39:04 +10:00
|
|
|
struct litest_device *dev = litest_add_device(li,
|
|
|
|
|
LITEST_MOUSE);
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput_device_group *group;
|
|
|
|
|
|
|
|
|
|
group = libinput_device_get_device_group(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(group);
|
2015-02-05 13:39:04 +10:00
|
|
|
libinput_device_group_ref(group);
|
|
|
|
|
|
|
|
|
|
libinput_device_ref(device);
|
|
|
|
|
litest_drain_events(li);
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2015-02-05 13:39:04 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* make sure the device is dead but the group is still around */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_unref(device) == NULL);
|
2015-02-05 13:39:04 +10:00
|
|
|
|
|
|
|
|
libinput_device_group_ref(group);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(libinput_device_group_unref(group));
|
|
|
|
|
litest_assert(libinput_device_group_unref(group) == NULL);
|
2015-02-05 13:39:04 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-09-04 12:56:41 +10:00
|
|
|
START_TEST(device_group_leak)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device_group *group;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
EV_REL, REL_X,
|
|
|
|
|
EV_REL, REL_Y,
|
|
|
|
|
-1);
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-09-04 12:56:41 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
|
|
|
|
|
group = libinput_device_get_device_group(device);
|
|
|
|
|
libinput_device_group_ref(group);
|
|
|
|
|
|
|
|
|
|
libinput_path_remove_device(device);
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
|
|
|
|
|
/* the device group leaks, check valgrind */
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-03-17 12:41:13 +10:00
|
|
|
START_TEST(abs_device_no_absx)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
EV_ABS, ABS_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-17 12:41:13 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_restore_log_handler(li);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(device == NULL);
|
2015-03-17 12:41:13 +10:00
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(abs_device_no_absy)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
EV_ABS, ABS_X,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-17 12:41:13 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_restore_log_handler(li);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(device == NULL);
|
2015-03-17 12:41:13 +10:00
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(abs_mt_device_no_absy)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
EV_ABS, ABS_X,
|
|
|
|
|
EV_ABS, ABS_Y,
|
|
|
|
|
EV_ABS, ABS_MT_SLOT,
|
|
|
|
|
EV_ABS, ABS_MT_POSITION_X,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-17 12:41:13 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_restore_log_handler(li);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(device == NULL);
|
2015-03-17 12:41:13 +10:00
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(abs_mt_device_no_absx)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
EV_ABS, ABS_X,
|
|
|
|
|
EV_ABS, ABS_Y,
|
|
|
|
|
EV_ABS, ABS_MT_SLOT,
|
|
|
|
|
EV_ABS, ABS_MT_POSITION_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-17 12:41:13 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_restore_log_handler(li);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(device == NULL);
|
2015-03-17 12:41:13 +10:00
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-05-05 16:44:34 +10:00
|
|
|
static void
|
|
|
|
|
assert_device_ignored(struct libinput *li, struct input_absinfo *absinfo)
|
2015-03-23 12:08:14 +10:00
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
2015-05-05 16:44:34 +10:00
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("test device", NULL,
|
|
|
|
|
absinfo,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_KEY, BTN_RIGHT,
|
|
|
|
|
-1);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
2015-05-04 11:40:39 +10:00
|
|
|
litest_assert_ptr_null(device);
|
2015-05-05 16:44:34 +10:00
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 08:26:47 +10:00
|
|
|
START_TEST(abs_device_no_range)
|
2015-05-05 16:44:34 +10:00
|
|
|
{
|
2015-05-06 08:26:47 +10:00
|
|
|
int code = _i; /* looped test */
|
2015-03-23 12:08:14 +10:00
|
|
|
/* set x/y so libinput doesn't just reject for missing axes */
|
|
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 0 },
|
2015-05-06 08:26:47 +10:00
|
|
|
{ code, 0, 0, 0, 0, 0 },
|
2015-03-23 12:08:14 +10:00
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-23 12:08:14 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
|
2015-05-06 08:26:47 +10:00
|
|
|
assert_device_ignored(li, absinfo);
|
2015-03-23 12:08:14 +10:00
|
|
|
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(abs_mt_device_no_range)
|
|
|
|
|
{
|
2015-05-06 08:26:47 +10:00
|
|
|
int code = _i; /* looped test */
|
2015-03-23 12:08:14 +10:00
|
|
|
/* set x/y so libinput doesn't just reject for missing axes */
|
|
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_SLOT, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_TRACKING_ID, 0, 255, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_POSITION_X, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_POSITION_Y, 0, 10, 0, 0, 0 },
|
2015-05-06 08:26:47 +10:00
|
|
|
{ code, 0, 0, 0, 0, 0 },
|
2015-03-23 12:08:14 +10:00
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-03-23 12:08:14 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
|
2015-05-06 08:26:47 +10:00
|
|
|
if (code != ABS_MT_TOOL_TYPE &&
|
|
|
|
|
code != ABS_MT_TRACKING_ID) /* kernel overrides it */
|
2015-05-05 16:44:34 +10:00
|
|
|
assert_device_ignored(li, absinfo);
|
2015-03-23 12:08:14 +10:00
|
|
|
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-09 07:51:51 +10:00
|
|
|
START_TEST(abs_device_missing_res)
|
2014-01-30 15:40:35 +10:00
|
|
|
{
|
2015-04-09 07:51:51 +10:00
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-04-09 07:51:51 +10:00
|
|
|
litest_disable_log_handler(li);
|
2015-05-05 16:44:34 +10:00
|
|
|
|
|
|
|
|
assert_device_ignored(li, absinfo);
|
2015-04-09 07:51:51 +10:00
|
|
|
|
|
|
|
|
absinfo[0].resolution = 0;
|
|
|
|
|
absinfo[1].resolution = 20;
|
2015-05-05 16:44:34 +10:00
|
|
|
|
|
|
|
|
assert_device_ignored(li, absinfo);
|
2015-04-09 07:51:51 +10:00
|
|
|
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(abs_mt_device_missing_res)
|
|
|
|
|
{
|
|
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_SLOT, 0, 2, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_TRACKING_ID, 0, 255, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_POSITION_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_POSITION_Y, 0, 10, 0, 0, 0 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-04-09 07:51:51 +10:00
|
|
|
litest_disable_log_handler(li);
|
2015-05-05 16:44:34 +10:00
|
|
|
assert_device_ignored(li, absinfo);
|
2015-04-09 07:51:51 +10:00
|
|
|
|
|
|
|
|
absinfo[4].resolution = 0;
|
|
|
|
|
absinfo[5].resolution = 20;
|
2015-05-05 16:44:34 +10:00
|
|
|
|
|
|
|
|
assert_device_ignored(li, absinfo);
|
2015-04-09 07:51:51 +10:00
|
|
|
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
2015-04-13 10:23:45 +10:00
|
|
|
|
2016-11-02 10:45:39 +10:00
|
|
|
START_TEST(ignore_joystick)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_RX, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_RY, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_THROTTLE, 0, 2, 0, 0, 0 },
|
|
|
|
|
{ ABS_RUDDER, 0, 255, 0, 0, 0 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2016-11-02 10:45:39 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("joystick test device", NULL,
|
|
|
|
|
absinfo,
|
|
|
|
|
EV_KEY, BTN_TRIGGER,
|
|
|
|
|
EV_KEY, BTN_A,
|
|
|
|
|
-1);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_assert_ptr_null(device);
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-13 10:23:45 +10:00
|
|
|
START_TEST(device_wheel_only)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_has_capability(device,
|
2015-04-13 10:23:45 +10:00
|
|
|
LIBINPUT_DEVICE_CAP_POINTER));
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-09-01 08:11:58 +10:00
|
|
|
START_TEST(device_accelerometer)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
|
|
struct input_absinfo absinfo[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Z, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-09-01 08:11:58 +10:00
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("test device", NULL,
|
|
|
|
|
absinfo,
|
|
|
|
|
-1);
|
|
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_assert_ptr_null(device);
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-07-14 14:36:51 +10:00
|
|
|
START_TEST(device_udev_tag_wacom_tablet)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct udev_device *d;
|
|
|
|
|
const char *prop;
|
|
|
|
|
|
|
|
|
|
d = libinput_device_get_udev_device(device);
|
|
|
|
|
prop = udev_device_get_property_value(d,
|
|
|
|
|
"ID_INPUT_TABLET");
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(prop);
|
2015-07-14 14:36:51 +10:00
|
|
|
udev_device_unref(d);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-08-18 13:00:15 +10:00
|
|
|
START_TEST(device_nonpointer_rel)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_device("test device",
|
|
|
|
|
NULL,
|
|
|
|
|
EV_KEY, KEY_A,
|
|
|
|
|
EV_KEY, KEY_B,
|
|
|
|
|
EV_REL, REL_X,
|
|
|
|
|
EV_REL, REL_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-08-18 13:00:15 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(device);
|
2015-08-18 13:00:15 +10:00
|
|
|
|
|
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_X, 1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_Y, -1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-08-18 13:00:15 +10:00
|
|
|
}
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_touchpad_rel)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
const struct input_absinfo abs[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_SLOT, 0, 2, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_TRACKING_ID, 0, 255, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_POSITION_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_POSITION_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("test device",
|
|
|
|
|
NULL, abs,
|
|
|
|
|
EV_KEY, BTN_TOOL_FINGER,
|
|
|
|
|
EV_KEY, BTN_TOUCH,
|
|
|
|
|
EV_REL, REL_X,
|
|
|
|
|
EV_REL, REL_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-08-18 13:00:15 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(device);
|
2015-08-18 13:00:15 +10:00
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_X, 1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_Y, -1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-08-18 13:00:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_touch_rel)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
const struct input_absinfo abs[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_SLOT, 0, 2, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_TRACKING_ID, 0, 255, 0, 0, 0 },
|
|
|
|
|
{ ABS_MT_POSITION_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_POSITION_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("test device",
|
|
|
|
|
NULL, abs,
|
|
|
|
|
EV_KEY, BTN_TOUCH,
|
|
|
|
|
EV_REL, REL_X,
|
|
|
|
|
EV_REL, REL_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-08-18 13:00:15 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(device);
|
2015-08-18 13:00:15 +10:00
|
|
|
|
|
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_X, 1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_Y, -1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-08-18 13:00:15 +10:00
|
|
|
}
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_abs_rel)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
const struct input_absinfo abs[] = {
|
|
|
|
|
{ ABS_X, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 10, 0, 0, 10 },
|
|
|
|
|
{ -1, -1, -1, -1, -1, -1 }
|
|
|
|
|
};
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput_abs_device("test device",
|
|
|
|
|
NULL, abs,
|
|
|
|
|
EV_KEY, BTN_TOUCH,
|
|
|
|
|
EV_KEY, BTN_LEFT,
|
|
|
|
|
EV_REL, REL_X,
|
|
|
|
|
EV_REL, REL_Y,
|
|
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2015-08-18 13:00:15 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(device);
|
2015-08-18 13:00:15 +10:00
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_X, 1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_REL, REL_Y, -1);
|
|
|
|
|
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-08-18 13:00:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-12-23 15:15:29 +10:00
|
|
|
START_TEST(device_quirks_no_abs_mt_y)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *pev;
|
2018-11-22 10:24:54 +10:00
|
|
|
bool hi_res_event_found, low_res_event_found;
|
|
|
|
|
int code, i;
|
|
|
|
|
|
|
|
|
|
hi_res_event_found = false;
|
|
|
|
|
low_res_event_found = false;
|
2015-12-23 15:15:29 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_HWHEEL, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-12-23 15:15:29 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
/* both high and low scroll end events must be sent */
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
pev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
|
|
|
|
|
|
|
|
|
|
if (litest_is_high_res_axis_event(event)) {
|
|
|
|
|
litest_assert(!hi_res_event_found);
|
|
|
|
|
hi_res_event_found = true;
|
|
|
|
|
} else {
|
|
|
|
|
litest_assert(!low_res_event_found);
|
|
|
|
|
low_res_event_found = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(libinput_event_pointer_get_base_event(pev));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_assert(low_res_event_found);
|
|
|
|
|
litest_assert(hi_res_event_found);
|
2015-12-23 15:15:29 +10:00
|
|
|
|
|
|
|
|
for (code = ABS_MISC + 1; code < ABS_MAX; code++) {
|
|
|
|
|
litest_event(dev, EV_ABS, code, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-01-29 10:09:13 +10:00
|
|
|
START_TEST(device_quirks_cyborg_rat_mode_button)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_pointer_has_button(device, 0x118));
|
|
|
|
|
litest_assert(!libinput_device_pointer_has_button(device, 0x119));
|
|
|
|
|
litest_assert(!libinput_device_pointer_has_button(device, 0x11a));
|
2016-01-29 10:09:13 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, 0x118, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, 0x119, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, 0x119, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, 0x11a, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, 0x11a, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, 0x118, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-06-15 19:36:56 +10:00
|
|
|
START_TEST(device_quirks_apple_magicmouse)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* ensure we get no events from the touch */
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
litest_touch_move_to(dev, 0, 50, 50, 80, 80, 10);
|
2016-06-15 19:36:56 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-17 08:39:51 +10:00
|
|
|
START_TEST(device_quirks_logitech_marble_mouse)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_pointer_has_button(dev->libinput_device,
|
2017-02-17 08:39:51 +10:00
|
|
|
BTN_MIDDLE));
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2024-03-18 16:24:11 +01:00
|
|
|
static char *debug_messages[64] = { NULL };
|
2020-10-23 09:14:33 +10:00
|
|
|
|
2021-07-22 15:25:03 +10:00
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
|
2020-10-23 09:14:33 +10:00
|
|
|
static void
|
|
|
|
|
debug_log_handler(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format,
|
|
|
|
|
va_list args)
|
|
|
|
|
{
|
2022-03-07 14:44:21 +10:00
|
|
|
char *message;
|
2020-10-23 09:14:33 +10:00
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
if (priority != LIBINPUT_LOG_PRIORITY_DEBUG)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
n = xvasprintf(&message, format, args);
|
|
|
|
|
litest_assert_int_gt(n, 0);
|
|
|
|
|
|
2021-08-30 18:39:56 +09:00
|
|
|
ARRAY_FOR_EACH(debug_messages, dmsg) {
|
|
|
|
|
if (*dmsg == NULL) {
|
|
|
|
|
*dmsg = message;
|
2020-10-23 09:14:33 +10:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_abort_msg("Out of space for debug messages");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(device_quirks)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
char **message;
|
|
|
|
|
bool disable_key_f1 = false,
|
|
|
|
|
enable_btn_left = false;
|
2020-10-23 10:38:14 +10:00
|
|
|
#if HAVE_LIBEVDEV_DISABLE_PROPERTY
|
|
|
|
|
bool disable_pointingstick = false,
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
enable_buttonpad = false,
|
|
|
|
|
enable_direct = false,
|
|
|
|
|
disable_direct = false,
|
|
|
|
|
enable_semi_mt = false,
|
|
|
|
|
disable_semi_mt = false;
|
2020-10-23 10:38:14 +10:00
|
|
|
#endif
|
2020-10-23 09:14:33 +10:00
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2020-10-23 09:14:33 +10:00
|
|
|
libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
|
|
|
|
|
libinput_log_set_handler(li, debug_log_handler);
|
|
|
|
|
dev = litest_add_device(li, LITEST_KEYBOARD_QUIRKED);
|
|
|
|
|
device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_pointer_has_button(device,
|
2020-10-23 09:14:33 +10:00
|
|
|
BTN_LEFT));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_pointer_has_button(dev->libinput_device,
|
2020-10-23 09:14:33 +10:00
|
|
|
BTN_RIGHT));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_pointer_has_button(device,
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
BTN_MIDDLE));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
|
2020-10-23 09:14:33 +10:00
|
|
|
KEY_F1));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
|
2020-10-23 09:14:33 +10:00
|
|
|
KEY_F2));
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
|
2020-10-23 09:14:33 +10:00
|
|
|
KEY_F3));
|
|
|
|
|
|
|
|
|
|
/* Scrape the debug messages for confirmation that our quirks are
|
|
|
|
|
* triggered, the above checks cannot work non-key codes */
|
|
|
|
|
message = debug_messages;
|
|
|
|
|
while (*message) {
|
|
|
|
|
if (strstr(*message, "disabling EV_KEY KEY_F1"))
|
|
|
|
|
disable_key_f1 = true;
|
|
|
|
|
if (strstr(*message, "enabling EV_KEY BTN_LEFT"))
|
|
|
|
|
enable_btn_left = true;
|
2020-10-23 10:38:14 +10:00
|
|
|
#if HAVE_LIBEVDEV_DISABLE_PROPERTY
|
|
|
|
|
if (strstr(*message, "enabling INPUT_PROP_BUTTONPAD"))
|
|
|
|
|
enable_buttonpad = true;
|
|
|
|
|
if (strstr(*message, "disabling INPUT_PROP_POINTING_STICK"))
|
|
|
|
|
disable_pointingstick = true;
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
if (strstr(*message, "enabling INPUT_PROP_DIRECT")) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!disable_direct);
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
enable_direct = true;
|
|
|
|
|
}
|
|
|
|
|
if (strstr(*message, "disabling INPUT_PROP_DIRECT")) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(enable_direct);
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
disable_direct = true;
|
|
|
|
|
}
|
|
|
|
|
if (strstr(*message, "enabling INPUT_PROP_SEMI_MT")) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(disable_semi_mt);
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
enable_semi_mt = true;
|
|
|
|
|
}
|
|
|
|
|
if (strstr(*message, "disabling INPUT_PROP_SEMI_MT")) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!enable_semi_mt);
|
quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.
Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:
[first]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE
[second]
AttrEventCodeDisable=BTN_RIGHT
[third]
AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;
Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.
Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.
Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.
For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
recent one to the existing entry (instead of creating a new entry in
the array). This way we have all entries that match and in-order of
precedence - i.e. we can process them left-to-right to end up
with the right state.
Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-15 13:53:43 +10:00
|
|
|
disable_semi_mt = true;
|
|
|
|
|
}
|
2020-10-23 10:38:14 +10:00
|
|
|
#endif
|
|
|
|
|
free(*message);
|
2020-10-23 09:14:33 +10:00
|
|
|
message++;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(disable_key_f1);
|
|
|
|
|
litest_assert(enable_btn_left);
|
2020-10-23 10:38:14 +10:00
|
|
|
#if HAVE_LIBEVDEV_DISABLE_PROPERTY
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(enable_buttonpad);
|
|
|
|
|
litest_assert(disable_pointingstick);
|
|
|
|
|
litest_assert(enable_direct);
|
|
|
|
|
litest_assert(disable_direct);
|
|
|
|
|
litest_assert(enable_semi_mt);
|
|
|
|
|
litest_assert(disable_semi_mt);
|
2020-10-23 10:38:14 +10:00
|
|
|
#endif
|
2020-10-23 09:14:33 +10:00
|
|
|
|
|
|
|
|
litest_disable_log_handler(li);
|
|
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2020-10-23 09:14:33 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-01-13 15:50:23 +10:00
|
|
|
START_TEST(device_capability_at_least_one)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_device_capability caps[] = {
|
|
|
|
|
LIBINPUT_DEVICE_CAP_KEYBOARD,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_POINTER,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_TOUCH,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_TABLET_TOOL,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_TABLET_PAD,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_GESTURE,
|
2017-01-20 16:54:16 +11:00
|
|
|
LIBINPUT_DEVICE_CAP_SWITCH,
|
2017-01-13 15:50:23 +10:00
|
|
|
};
|
|
|
|
|
int ncaps = 0;
|
|
|
|
|
|
|
|
|
|
ARRAY_FOR_EACH(caps, cap) {
|
|
|
|
|
if (libinput_device_has_capability(device, *cap))
|
|
|
|
|
ncaps++;
|
|
|
|
|
}
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_gt(ncaps, 0);
|
2017-01-13 15:50:23 +10:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_capability_check_invalid)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_has_capability(device, -1));
|
|
|
|
|
litest_assert(!libinput_device_has_capability(device, 7));
|
|
|
|
|
litest_assert(!libinput_device_has_capability(device, 0xffff));
|
2017-01-13 15:50:23 +10:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2020-05-28 16:41:09 +10:00
|
|
|
START_TEST(device_capability_nocaps_ignored)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
2020-08-13 09:59:10 +10:00
|
|
|
/* SW_PEN_INSERTED isn't handled in libinput so the device is
|
|
|
|
|
* processed but ends up without seat capabilities and is ignored.
|
|
|
|
|
*/
|
2020-05-28 16:41:09 +10:00
|
|
|
uinput = litest_create_uinput_device("test device", NULL,
|
2020-08-13 09:59:10 +10:00
|
|
|
EV_SW, SW_PEN_INSERTED,
|
2020-05-28 16:41:09 +10:00
|
|
|
-1);
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2020-05-28 16:41:09 +10:00
|
|
|
device = libinput_path_add_device(li,
|
|
|
|
|
libevdev_uinput_get_devnode(uinput));
|
|
|
|
|
litest_assert_ptr_null(device);
|
|
|
|
|
|
|
|
|
|
libevdev_uinput_destroy(uinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-01-13 17:01:33 +10:00
|
|
|
START_TEST(device_has_size)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
double w, h;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = libinput_device_get_size(device, &w, &h);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2017-01-13 17:01:33 +10:00
|
|
|
/* This matches the current set of test devices but may fail if
|
|
|
|
|
* newer ones are added */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_gt(w, 30);
|
|
|
|
|
litest_assert_double_gt(h, 20);
|
2017-01-13 17:01:33 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_has_no_size)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
double w = 45, h = 67;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = libinput_device_get_size(device, &w, &h);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, -1);
|
|
|
|
|
litest_assert_double_eq(w, 45);
|
|
|
|
|
litest_assert_double_eq(h, 67);
|
2017-01-13 17:01:33 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-09 09:43:54 +10:00
|
|
|
START_TEST(device_get_output)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
const char *output_name;
|
|
|
|
|
|
|
|
|
|
output_name = libinput_device_get_output_name(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_str_eq(output_name, "myOutput");
|
2017-02-09 09:43:54 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(device_no_output)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
const char *output_name;
|
|
|
|
|
|
|
|
|
|
output_name = libinput_device_get_output_name(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(output_name == NULL);
|
2017-02-09 09:43:54 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-09 10:32:02 +10:00
|
|
|
START_TEST(device_seat_phys_name)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput_seat *seat = libinput_device_get_seat(device);
|
|
|
|
|
const char *seat_name;
|
|
|
|
|
|
|
|
|
|
seat_name = libinput_seat_get_physical_name(seat);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(streq(seat_name, "seat0"));
|
2017-02-09 10:32:02 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-01-31 11:09:53 +10:00
|
|
|
START_TEST(device_button_down_remove)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *lidev = litest_current_device();
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
|
|
|
|
|
for (int code = 0; code < KEY_MAX; code++) {
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *p;
|
|
|
|
|
bool have_down = false,
|
|
|
|
|
have_up = false;
|
|
|
|
|
const char *keyname;
|
|
|
|
|
int button_down = 0, button_up = 0;
|
|
|
|
|
|
|
|
|
|
keyname = libevdev_event_code_get_name(EV_KEY, code);
|
|
|
|
|
if (!keyname ||
|
2025-01-09 09:04:54 +10:00
|
|
|
!strstartswith(keyname, "BTN_") ||
|
|
|
|
|
strstartswith(keyname, "BTN_TOOL_"))
|
2019-01-31 11:09:53 +10:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!libevdev_has_event_code(lidev->evdev, EV_KEY, code))
|
|
|
|
|
continue;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2019-01-31 11:09:53 +10:00
|
|
|
dev = litest_add_device(li, lidev->which);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Clickpads require a touch down to trigger the button
|
|
|
|
|
* press */
|
|
|
|
|
if (libevdev_has_property(lidev->evdev, INPUT_PROP_BUTTONPAD)) {
|
|
|
|
|
litest_touch_down(dev, 0, 20, 90);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-31 11:09:53 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, code, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-31 11:09:53 +10:00
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-31 11:09:53 +10:00
|
|
|
|
|
|
|
|
while ((event = libinput_get_event(li))) {
|
|
|
|
|
if (libinput_event_get_type(event) !=
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON) {
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p = libinput_event_get_pointer_event(event);
|
|
|
|
|
if (libinput_event_pointer_get_button_state(p)) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(button_down == 0);
|
2019-01-31 11:09:53 +10:00
|
|
|
button_down = libinput_event_pointer_get_button(p);
|
|
|
|
|
} else {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(button_up == 0);
|
2019-01-31 11:09:53 +10:00
|
|
|
button_up = libinput_event_pointer_get_button(p);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(button_down, button_up);
|
2019-01-31 11:09:53 +10:00
|
|
|
}
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(have_down, have_up);
|
2019-01-31 11:09:53 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-03-21 12:54:10 +10:00
|
|
|
TEST_COLLECTION(device)
|
2014-01-30 15:40:35 +10:00
|
|
|
{
|
2025-02-16 17:05:39 +01:00
|
|
|
struct range abs_range = range_init_exclusive(0, ABS_MISC);
|
|
|
|
|
struct range abs_mt_range = range_init_exclusive(ABS_MT_SLOT + 1, ABS_CNT);
|
2015-05-06 08:26:47 +10:00
|
|
|
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(device_sendevents_config, LITEST_ANY, LITEST_TOUCHPAD|LITEST_TABLET);
|
|
|
|
|
litest_add(device_sendevents_config_invalid, LITEST_ANY, LITEST_TABLET);
|
|
|
|
|
litest_add(device_sendevents_config_touchpad, LITEST_TOUCHPAD, LITEST_TABLET);
|
|
|
|
|
litest_add(device_sendevents_config_touchpad_superset, LITEST_TOUCHPAD, LITEST_TABLET);
|
|
|
|
|
litest_add(device_sendevents_config_default, LITEST_ANY, LITEST_TABLET);
|
|
|
|
|
litest_add(device_disable, LITEST_RELATIVE, LITEST_TABLET);
|
|
|
|
|
litest_add(device_disable_tablet, LITEST_TABLET, LITEST_ANY);
|
|
|
|
|
litest_add(device_disable_touchpad, LITEST_TOUCHPAD, LITEST_TABLET);
|
|
|
|
|
litest_add(device_disable_touch, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(device_disable_touch_during_touch, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(device_disable_touch, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(device_disable_touch_during_touch, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(device_disable_events_pending, LITEST_RELATIVE, LITEST_TOUCHPAD|LITEST_TABLET);
|
|
|
|
|
litest_add(device_double_disable, LITEST_ANY, LITEST_TABLET);
|
|
|
|
|
litest_add(device_double_enable, LITEST_ANY, LITEST_TABLET);
|
|
|
|
|
litest_add_no_device(device_reenable_syspath_changed);
|
|
|
|
|
litest_add_no_device(device_reenable_device_removed);
|
|
|
|
|
litest_add_for_device(device_disable_release_buttons, LITEST_MOUSE);
|
|
|
|
|
litest_add_for_device(device_disable_release_keys, LITEST_KEYBOARD);
|
|
|
|
|
litest_add(device_disable_release_tap, LITEST_TOUCHPAD, LITEST_ANY);
|
|
|
|
|
litest_add(device_disable_release_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
|
|
|
|
|
litest_add(device_disable_release_softbutton, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
|
|
|
|
|
litest_add(device_disable_topsoftbutton, LITEST_TOPBUTTONPAD, LITEST_ANY);
|
|
|
|
|
litest_add(device_ids, LITEST_ANY, LITEST_ANY);
|
|
|
|
|
litest_add_for_device(device_context, LITEST_SYNAPTICS_CLICKPAD_X220);
|
|
|
|
|
litest_add_for_device(device_user_data, LITEST_SYNAPTICS_CLICKPAD_X220);
|
|
|
|
|
|
|
|
|
|
litest_add(device_get_udev_handle, LITEST_ANY, LITEST_ANY);
|
|
|
|
|
|
|
|
|
|
litest_add(device_group_get, LITEST_ANY, LITEST_ANY);
|
|
|
|
|
litest_add_no_device(device_group_ref);
|
|
|
|
|
litest_add_no_device(device_group_leak);
|
|
|
|
|
|
|
|
|
|
litest_add_no_device(abs_device_no_absx);
|
|
|
|
|
litest_add_no_device(abs_device_no_absy);
|
|
|
|
|
litest_add_no_device(abs_mt_device_no_absx);
|
|
|
|
|
litest_add_no_device(abs_mt_device_no_absy);
|
|
|
|
|
litest_add_ranged_no_device(abs_device_no_range, &abs_range);
|
|
|
|
|
litest_add_ranged_no_device(abs_mt_device_no_range, &abs_mt_range);
|
|
|
|
|
litest_add_no_device(abs_device_missing_res);
|
|
|
|
|
litest_add_no_device(abs_mt_device_missing_res);
|
|
|
|
|
litest_add_no_device(ignore_joystick);
|
|
|
|
|
|
|
|
|
|
litest_add(device_wheel_only, LITEST_WHEEL, LITEST_RELATIVE|LITEST_ABSOLUTE|LITEST_TABLET);
|
|
|
|
|
litest_add_no_device(device_accelerometer);
|
|
|
|
|
|
|
|
|
|
litest_add(device_udev_tag_wacom_tablet, LITEST_TABLET, LITEST_TOTEM);
|
|
|
|
|
|
|
|
|
|
litest_add_no_device(device_nonpointer_rel);
|
|
|
|
|
litest_add_no_device(device_touchpad_rel);
|
|
|
|
|
litest_add_no_device(device_touch_rel);
|
|
|
|
|
litest_add_no_device(device_abs_rel);
|
|
|
|
|
|
|
|
|
|
litest_add_for_device(device_quirks_no_abs_mt_y, LITEST_ANKER_MOUSE_KBD);
|
|
|
|
|
litest_add_for_device(device_quirks_cyborg_rat_mode_button, LITEST_CYBORG_RAT);
|
|
|
|
|
litest_add_for_device(device_quirks_apple_magicmouse, LITEST_MAGICMOUSE);
|
|
|
|
|
litest_add_for_device(device_quirks_logitech_marble_mouse, LITEST_LOGITECH_TRACKBALL);
|
|
|
|
|
litest_add_no_device(device_quirks);
|
|
|
|
|
|
|
|
|
|
litest_add(device_capability_at_least_one, LITEST_ANY, LITEST_ANY);
|
|
|
|
|
litest_add(device_capability_check_invalid, LITEST_ANY, LITEST_ANY);
|
|
|
|
|
litest_add_no_device(device_capability_nocaps_ignored);
|
|
|
|
|
|
|
|
|
|
litest_add(device_has_size, LITEST_TOUCHPAD, LITEST_ANY);
|
|
|
|
|
litest_add(device_has_size, LITEST_TABLET, LITEST_ANY);
|
|
|
|
|
litest_add(device_has_no_size, LITEST_ANY,
|
2018-09-14 14:03:09 +10:00
|
|
|
LITEST_TOUCHPAD|LITEST_TABLET|LITEST_TOUCH|LITEST_ABSOLUTE|LITEST_SINGLE_TOUCH|LITEST_TOTEM);
|
2017-02-09 09:43:54 +10:00
|
|
|
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add_for_device(device_get_output, LITEST_CALIBRATED_TOUCHSCREEN);
|
|
|
|
|
litest_add(device_no_output, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(device_no_output, LITEST_KEYS, LITEST_ANY);
|
2017-02-09 10:32:02 +10:00
|
|
|
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(device_seat_phys_name, LITEST_ANY, LITEST_ANY);
|
2019-01-31 11:09:53 +10:00
|
|
|
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(device_button_down_remove, LITEST_BUTTON, LITEST_ANY);
|
2014-01-30 15:40:35 +10:00
|
|
|
}
|