2014-01-22 10:34:11 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 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-22 10:34:11 +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-22 10:34:11 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <libinput.h>
|
2014-08-20 17:16:06 +10:00
|
|
|
#include <libevdev/libevdev.h>
|
2014-01-22 10:34:11 +10:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "libinput-util.h"
|
|
|
|
|
#include "litest.h"
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_frame_events)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
int have_frame_event = 0;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 10, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-22 10:34:11 +10:00
|
|
|
|
|
|
|
|
while ((event = libinput_get_event(li))) {
|
|
|
|
|
if (libinput_event_get_type(event) == LIBINPUT_EVENT_TOUCH_FRAME)
|
|
|
|
|
have_frame_event++;
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(have_frame_event, 1);
|
2014-01-22 10:34:11 +10:00
|
|
|
|
|
|
|
|
litest_touch_down(dev, 1, 10, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-22 10:34:11 +10:00
|
|
|
|
|
|
|
|
while ((event = libinput_get_event(li))) {
|
|
|
|
|
if (libinput_event_get_type(event) == LIBINPUT_EVENT_TOUCH_FRAME)
|
|
|
|
|
have_frame_event++;
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(have_frame_event, 2);
|
2014-01-22 10:34:11 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-10-16 12:50:44 +10:00
|
|
|
START_TEST(touch_downup_no_motion)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 10, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-10-16 12:50:44 +10:00
|
|
|
|
|
|
|
|
litest_assert_touch_down_frame(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-10-16 12:50:44 +10:00
|
|
|
|
|
|
|
|
litest_assert_touch_up_frame(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-02-18 20:13:58 +01:00
|
|
|
START_TEST(touch_abs_transform)
|
|
|
|
|
{
|
2014-04-03 22:35:47 +02:00
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput *libinput;
|
2014-02-18 20:13:58 +01:00
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
2014-06-02 23:09:27 +02:00
|
|
|
double fx, fy;
|
2014-02-18 20:13:58 +01:00
|
|
|
bool tested = false;
|
|
|
|
|
|
2014-04-03 22:35:47 +02:00
|
|
|
struct input_absinfo abs[] = {
|
2014-07-16 14:10:08 +10:00
|
|
|
{ ABS_X, 0, 32767, 75, 0, 10 },
|
|
|
|
|
{ ABS_Y, 0, 32767, 129, 0, 9 },
|
2014-04-03 22:35:47 +02:00
|
|
|
{ ABS_MT_POSITION_X, 0, 32767, 0, 0, 10 },
|
|
|
|
|
{ ABS_MT_POSITION_Y, 0, 32767, 0, 0, 9 },
|
|
|
|
|
{ .value = -1 },
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-12 09:34:47 +10:00
|
|
|
dev = litest_create_device_with_overrides(LITEST_WACOM_ISDV4_E6_FINGER,
|
2014-07-04 07:55:51 +10:00
|
|
|
"litest Highres touch device",
|
2014-04-03 22:35:47 +02:00
|
|
|
NULL, abs, NULL);
|
|
|
|
|
|
|
|
|
|
libinput = dev->libinput;
|
|
|
|
|
|
2014-02-18 20:13:58 +01:00
|
|
|
litest_touch_down(dev, 0, 100, 100);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-02-18 20:13:58 +01:00
|
|
|
|
|
|
|
|
while ((ev = libinput_get_event(libinput))) {
|
2014-03-27 08:43:04 +10:00
|
|
|
if (libinput_event_get_type(ev) != LIBINPUT_EVENT_TOUCH_DOWN) {
|
|
|
|
|
libinput_event_destroy(ev);
|
2014-02-18 20:13:58 +01:00
|
|
|
continue;
|
2014-03-27 08:43:04 +10:00
|
|
|
}
|
2014-02-18 20:13:58 +01:00
|
|
|
|
|
|
|
|
tev = libinput_event_get_touch_event(ev);
|
|
|
|
|
fx = libinput_event_touch_get_x_transformed(tev, 1920);
|
2024-10-14 15:20:21 +10:00
|
|
|
litest_assert_double_eq_epsilon(fx, 1920.0, 0.1);
|
|
|
|
|
litest_assert_double_lt(fx, 1920.0);
|
2014-02-18 20:13:58 +01:00
|
|
|
fy = libinput_event_touch_get_y_transformed(tev, 720);
|
2024-10-14 15:20:21 +10:00
|
|
|
litest_assert_double_eq_epsilon(fy, 720.0, 0.1);
|
|
|
|
|
litest_assert_double_lt(fy, 720.0);
|
2014-01-22 10:34:11 +10:00
|
|
|
|
2014-02-18 20:13:58 +01:00
|
|
|
tested = true;
|
2014-03-27 08:43:04 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
2014-02-18 20:13:58 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(tested);
|
2014-04-10 11:11:43 +10:00
|
|
|
|
|
|
|
|
litest_delete_device(dev);
|
2014-02-18 20:13:58 +01:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-06 11:47:56 +10:00
|
|
|
static inline void
|
|
|
|
|
touch_assert_seat_slot(struct libinput *li,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
unsigned int seat_slot)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-06 11:47:56 +10:00
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
tev = litest_is_touch_event(ev, type);
|
|
|
|
|
slot = libinput_event_touch_get_slot(tev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(slot, slot);
|
2017-02-06 11:47:56 +10:00
|
|
|
slot = libinput_event_touch_get_seat_slot(tev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(slot, seat_slot);
|
2017-02-06 11:47:56 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_assert_event_type(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_seat_slot)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev1 = litest_current_device();
|
|
|
|
|
struct litest_device *dev2;
|
|
|
|
|
struct libinput *li = dev1->libinput;
|
|
|
|
|
|
2025-03-12 09:34:47 +10:00
|
|
|
dev2 = litest_add_device(li, LITEST_WACOM_ISDV4_E6_FINGER);
|
2017-02-06 11:47:56 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev1, 0, 50, 50);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_DOWN, 0, 0);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev2, 0, 50, 50);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_DOWN, 0, 1);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev2, 1, 60, 50);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_DOWN, 1, 2);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev1, 1, 60, 50);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_DOWN, 1, 3);
|
|
|
|
|
|
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(dev1, 0, 50, 50, 60, 70, 10);
|
2017-02-06 11:47:56 +10:00
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_MOTION, 0, 0);
|
|
|
|
|
litest_drain_events(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(dev2, 1, 50, 50, 60, 70, 10);
|
2017-02-06 11:47:56 +10:00
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_MOTION, 1, 2);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev1, 0);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_UP, 0, 0);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev2, 0);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_UP, 0, 1);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev2, 1);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_UP, 1, 2);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev1, 1);
|
|
|
|
|
touch_assert_seat_slot(li, LIBINPUT_EVENT_TOUCH_UP, 1, 3);
|
|
|
|
|
|
|
|
|
|
litest_delete_device(dev2);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-03-24 22:37:00 +01:00
|
|
|
START_TEST(touch_many_slots)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *libinput;
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
int slot;
|
|
|
|
|
const int num_tps = 100;
|
|
|
|
|
int slot_count = 0;
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
|
|
|
|
|
struct input_absinfo abs[] = {
|
|
|
|
|
{ ABS_MT_SLOT, 0, num_tps - 1, 0, 0, 0 },
|
|
|
|
|
{ .value = -1 },
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-12 09:34:47 +10:00
|
|
|
dev = litest_create_device_with_overrides(LITEST_WACOM_ISDV4_E6_FINGER,
|
2014-07-04 07:55:51 +10:00
|
|
|
"litest Multi-touch device",
|
2014-03-24 22:37:00 +01:00
|
|
|
NULL, abs, NULL);
|
|
|
|
|
libinput = dev->libinput;
|
|
|
|
|
|
|
|
|
|
for (slot = 0; slot < num_tps; ++slot)
|
|
|
|
|
litest_touch_down(dev, slot, 0, 0);
|
|
|
|
|
for (slot = 0; slot < num_tps; ++slot)
|
|
|
|
|
litest_touch_up(dev, slot);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-03-24 22:37:00 +01:00
|
|
|
while ((ev = libinput_get_event(libinput))) {
|
|
|
|
|
type = libinput_event_get_type(ev);
|
|
|
|
|
|
|
|
|
|
if (type == LIBINPUT_EVENT_TOUCH_DOWN)
|
|
|
|
|
slot_count++;
|
|
|
|
|
else if (type == LIBINPUT_EVENT_TOUCH_UP)
|
|
|
|
|
break;
|
|
|
|
|
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-03-24 22:37:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(ev);
|
|
|
|
|
litest_assert_int_gt(slot_count, 0);
|
2014-03-24 22:37:00 +01:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-03-24 22:37:00 +01:00
|
|
|
do {
|
|
|
|
|
type = libinput_event_get_type(ev);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_ne(type, LIBINPUT_EVENT_TOUCH_DOWN);
|
2014-03-24 22:37:00 +01:00
|
|
|
if (type == LIBINPUT_EVENT_TOUCH_UP)
|
|
|
|
|
slot_count--;
|
|
|
|
|
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-03-24 22:37:00 +01:00
|
|
|
} while ((ev = libinput_get_event(libinput)));
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(slot_count, 0);
|
2014-04-23 11:04:48 +10:00
|
|
|
|
|
|
|
|
litest_delete_device(dev);
|
2014-03-24 22:37:00 +01:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-03-24 23:05:21 +01:00
|
|
|
START_TEST(touch_double_touch_down_up)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *libinput;
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
bool got_down = false;
|
|
|
|
|
bool got_up = false;
|
|
|
|
|
|
|
|
|
|
dev = litest_current_device();
|
|
|
|
|
libinput = dev->libinput;
|
|
|
|
|
|
2017-06-01 15:00:27 +10:00
|
|
|
litest_disable_log_handler(libinput);
|
2015-04-29 14:53:27 +10:00
|
|
|
/* note: this test is a false negative, libevdev will filter
|
|
|
|
|
* tracking IDs re-used in the same slot. */
|
2014-03-24 23:05:21 +01:00
|
|
|
litest_touch_down(dev, 0, 0, 0);
|
|
|
|
|
litest_touch_down(dev, 0, 0, 0);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2017-06-01 15:00:27 +10:00
|
|
|
litest_restore_log_handler(libinput);
|
2014-03-24 23:05:21 +01:00
|
|
|
|
|
|
|
|
while ((ev = libinput_get_event(libinput))) {
|
|
|
|
|
switch (libinput_event_get_type(ev)) {
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!got_down);
|
2014-03-24 23:05:21 +01:00
|
|
|
got_down = true;
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_UP:
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(got_down);
|
|
|
|
|
litest_assert(!got_up);
|
2014-03-24 23:05:21 +01:00
|
|
|
got_up = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-03-24 23:05:21 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(got_down);
|
|
|
|
|
litest_assert(got_up);
|
2014-03-24 23:05:21 +01:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-08-20 17:16:06 +10:00
|
|
|
START_TEST(touch_calibration_scale)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
float matrix[6] = {
|
|
|
|
|
1, 0, 0,
|
|
|
|
|
0, 1, 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
float calibration;
|
|
|
|
|
double x, y;
|
|
|
|
|
const int width = 640, height = 480;
|
|
|
|
|
|
|
|
|
|
dev = litest_current_device();
|
|
|
|
|
li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
for (calibration = 0.1; calibration < 1; calibration += 0.1) {
|
2014-08-26 11:41:19 +10:00
|
|
|
libinput_device_config_calibration_set_matrix(dev->libinput_device,
|
|
|
|
|
matrix);
|
2014-08-20 17:16:06 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 100, 100);
|
|
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
2015-05-04 13:51:39 +10:00
|
|
|
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
x = libinput_event_touch_get_x_transformed(tev, width);
|
|
|
|
|
y = libinput_event_touch_get_y_transformed(tev, height);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(round(x), round(width * matrix[0]));
|
|
|
|
|
litest_assert_int_eq(round(y), round(height * matrix[4]));
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
matrix[0] = calibration;
|
|
|
|
|
matrix[4] = 1 - calibration;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_calibration_rotation)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
float matrix[6];
|
|
|
|
|
int i;
|
|
|
|
|
double x, y;
|
|
|
|
|
int width = 1024, height = 480;
|
|
|
|
|
|
|
|
|
|
dev = litest_current_device();
|
|
|
|
|
li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
|
float angle = i * M_PI/2;
|
|
|
|
|
|
|
|
|
|
/* [ cos -sin tx ]
|
|
|
|
|
[ sin cos ty ]
|
|
|
|
|
[ 0 0 1 ] */
|
|
|
|
|
matrix[0] = cos(angle);
|
|
|
|
|
matrix[1] = -sin(angle);
|
|
|
|
|
matrix[3] = sin(angle);
|
|
|
|
|
matrix[4] = cos(angle);
|
|
|
|
|
|
|
|
|
|
switch(i) {
|
|
|
|
|
case 0: /* 0 deg */
|
|
|
|
|
matrix[2] = 0;
|
|
|
|
|
matrix[5] = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 1: /* 90 deg cw */
|
|
|
|
|
matrix[2] = 1;
|
|
|
|
|
matrix[5] = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 2: /* 180 deg cw */
|
|
|
|
|
matrix[2] = 1;
|
|
|
|
|
matrix[5] = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 3: /* 270 deg cw */
|
|
|
|
|
matrix[2] = 0;
|
|
|
|
|
matrix[5] = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 11:41:19 +10:00
|
|
|
libinput_device_config_calibration_set_matrix(dev->libinput_device,
|
|
|
|
|
matrix);
|
2014-08-20 17:16:06 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 80, 20);
|
|
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 17:16:06 +10:00
|
|
|
ev = libinput_get_event(li);
|
2015-05-04 13:51:39 +10:00
|
|
|
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
x = libinput_event_touch_get_x_transformed(tev, width);
|
|
|
|
|
y = libinput_event_touch_get_y_transformed(tev, height);
|
|
|
|
|
|
|
|
|
|
/* rounding errors... */
|
|
|
|
|
switch(i) {
|
|
|
|
|
case 0: /* 0 deg */
|
2024-10-14 10:14:56 +10:00
|
|
|
litest_assert_double_eq_epsilon(x, width * 0.8, 1.0);
|
|
|
|
|
litest_assert_double_eq_epsilon(y, height * 0.2, 1.0);
|
2014-08-20 17:16:06 +10:00
|
|
|
break;
|
|
|
|
|
case 1: /* 90 deg cw */
|
2024-10-14 10:14:56 +10:00
|
|
|
litest_assert_double_eq_epsilon(x, width * 0.8, 1.0);
|
|
|
|
|
litest_assert_double_eq_epsilon(y, height * 0.8, 1.0);
|
2014-08-20 17:16:06 +10:00
|
|
|
break;
|
|
|
|
|
case 2: /* 180 deg cw */
|
2024-10-14 10:14:56 +10:00
|
|
|
litest_assert_double_eq_epsilon(x, width * 0.2, 1.0);
|
|
|
|
|
litest_assert_double_eq_epsilon(y, height * 0.8, 1.0);
|
2014-08-20 17:16:06 +10:00
|
|
|
break;
|
|
|
|
|
case 3: /* 270 deg cw */
|
2024-10-14 10:14:56 +10:00
|
|
|
litest_assert_double_eq_epsilon(x, width * 0.2, 1.0);
|
|
|
|
|
litest_assert_double_eq_epsilon(y, height * 0.2, 1.0);
|
2014-08-20 17:16:06 +10:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_calibration_translation)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
float matrix[6] = {
|
|
|
|
|
1, 0, 0,
|
|
|
|
|
0, 1, 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
float translate;
|
|
|
|
|
double x, y;
|
|
|
|
|
const int width = 640, height = 480;
|
|
|
|
|
|
|
|
|
|
dev = litest_current_device();
|
|
|
|
|
li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
/* translating from 0 up to 1 device width/height */
|
|
|
|
|
for (translate = 0.1; translate <= 1; translate += 0.1) {
|
2014-08-26 11:41:19 +10:00
|
|
|
libinput_device_config_calibration_set_matrix(dev->libinput_device,
|
|
|
|
|
matrix);
|
2014-08-20 17:16:06 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 100, 100);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-08-20 17:16:06 +10:00
|
|
|
ev = libinput_get_event(li);
|
2015-05-04 13:51:39 +10:00
|
|
|
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
x = libinput_event_touch_get_x_transformed(tev, width);
|
|
|
|
|
y = libinput_event_touch_get_y_transformed(tev, height);
|
|
|
|
|
|
|
|
|
|
/* sigh. rounding errors */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_ge(round(x), width + round(width * matrix[2]) - 1);
|
|
|
|
|
litest_assert_int_ge(round(y), height + round(height * matrix[5]) - 1);
|
|
|
|
|
litest_assert_int_le(round(x), width + round(width * matrix[2]) + 1);
|
|
|
|
|
litest_assert_int_le(round(y), height + round(height * matrix[5]) + 1);
|
2014-08-20 17:16:06 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
matrix[2] = translate;
|
|
|
|
|
matrix[5] = 1 - translate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-11-25 14:59:27 +10:00
|
|
|
START_TEST(touch_calibrated_screen_path)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
float matrix[6];
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = libinput_device_config_calibration_has_matrix(dev->libinput_device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 1);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
|
|
|
|
rc = libinput_device_config_calibration_get_matrix(dev->libinput_device,
|
|
|
|
|
matrix);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 1);
|
|
|
|
|
|
|
|
|
|
litest_assert_double_eq(matrix[0], 1.2);
|
|
|
|
|
litest_assert_double_eq(matrix[1], 3.4);
|
|
|
|
|
litest_assert_double_eq(matrix[2], 5.6);
|
|
|
|
|
litest_assert_double_eq(matrix[3], 7.8);
|
|
|
|
|
litest_assert_double_eq(matrix[4], 9.10);
|
|
|
|
|
litest_assert_double_eq(matrix[5], 11.12);
|
2016-11-25 14:59:27 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-08-04 11:48:28 -04:00
|
|
|
START_TEST(touch_calibration_config)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
float identity[6] = {1, 0, 0, 0, 1, 0};
|
|
|
|
|
float nonidentity[6] = {1, 2, 3, 4, 5, 6};
|
|
|
|
|
float matrix[6];
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = libinput_device_config_calibration_has_matrix(dev->libinput_device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 1);
|
2019-08-04 11:48:28 -04:00
|
|
|
|
|
|
|
|
/* Twice so we have every to-fro combination */
|
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
|
status = libinput_device_config_calibration_set_matrix(dev->libinput_device, identity);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-08-04 11:48:28 -04:00
|
|
|
libinput_device_config_calibration_get_matrix(dev->libinput_device, matrix);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(memcmp(matrix, identity, sizeof(matrix)), 0);
|
2019-08-04 11:48:28 -04:00
|
|
|
|
|
|
|
|
status = libinput_device_config_calibration_set_matrix(dev->libinput_device, nonidentity);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-08-04 11:48:28 -04:00
|
|
|
libinput_device_config_calibration_get_matrix(dev->libinput_device, matrix);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(memcmp(matrix, nonidentity, sizeof(matrix)), 0);
|
2019-08-04 11:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-11-25 14:59:27 +10:00
|
|
|
static int open_restricted(const char *path, int flags, void *data)
|
|
|
|
|
{
|
|
|
|
|
int fd;
|
|
|
|
|
fd = open(path, flags);
|
|
|
|
|
return fd < 0 ? -errno : fd;
|
|
|
|
|
}
|
|
|
|
|
static void close_restricted(int fd, void *data)
|
|
|
|
|
{
|
|
|
|
|
close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct libinput_interface simple_interface = {
|
|
|
|
|
.open_restricted = open_restricted,
|
|
|
|
|
.close_restricted = close_restricted,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_calibrated_screen_udev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_device *device = NULL;
|
|
|
|
|
struct udev *udev;
|
|
|
|
|
float matrix[6];
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
udev = udev_new();
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(udev);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
|
|
|
|
li = libinput_udev_create_context(&simple_interface, NULL, udev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(li);
|
|
|
|
|
litest_assert_int_eq(libinput_udev_assign_seat(li, "seat0"), 0);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
|
|
|
|
while ((ev = libinput_get_event(li))) {
|
|
|
|
|
struct libinput_device *d;
|
|
|
|
|
|
|
|
|
|
if (libinput_event_get_type(ev) !=
|
|
|
|
|
LIBINPUT_EVENT_DEVICE_ADDED) {
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d = libinput_event_get_device(ev);
|
|
|
|
|
|
|
|
|
|
if (libinput_device_get_id_vendor(d) == 0x22 &&
|
|
|
|
|
libinput_device_get_id_product(d) == 0x33) {
|
|
|
|
|
device = libinput_device_ref(d);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
}
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(device);
|
2016-11-25 14:59:27 +10:00
|
|
|
rc = libinput_device_config_calibration_has_matrix(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 1);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
|
|
|
|
rc = libinput_device_config_calibration_get_matrix(device, matrix);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 1);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(matrix[0], 1.2);
|
|
|
|
|
litest_assert_double_eq(matrix[1], 3.4);
|
|
|
|
|
litest_assert_double_eq(matrix[2], 5.6);
|
|
|
|
|
litest_assert_double_eq(matrix[3], 7.8);
|
|
|
|
|
litest_assert_double_eq(matrix[4], 9.10);
|
|
|
|
|
litest_assert_double_eq(matrix[5], 11.12);
|
2016-11-25 14:59:27 +10:00
|
|
|
|
|
|
|
|
libinput_device_unref(device);
|
|
|
|
|
|
|
|
|
|
libinput_unref(li);
|
|
|
|
|
udev_unref(udev);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-09-23 12:46:02 +10:00
|
|
|
START_TEST(touch_no_left_handed)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int rc;
|
|
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_is_available(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_get(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_get_default(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
status = libinput_device_config_left_handed_set(d, 0);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2014-09-23 12:46:02 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-11-05 11:20:36 +10:00
|
|
|
START_TEST(fake_mt_exists)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-05-30 10:13:32 +10:00
|
|
|
|
2014-11-05 11:20:36 +10:00
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
device = libinput_event_get_device(event);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_has_capability(device,
|
2014-11-05 11:20:36 +10:00
|
|
|
LIBINPUT_DEVICE_CAP_TOUCH));
|
|
|
|
|
|
|
|
|
|
/* This test may need fixing if we add other fake-mt devices that
|
|
|
|
|
* have different capabilities */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_has_capability(device,
|
2014-11-05 11:20:36 +10:00
|
|
|
LIBINPUT_DEVICE_CAP_POINTER));
|
2015-04-27 08:56:50 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
2014-11-05 11:20:36 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(fake_mt_no_touch_events)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(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, 70, 70, 5);
|
2014-11-05 11:20:36 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_down(dev, 1, 70, 70);
|
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, 40, 10);
|
|
|
|
|
litest_touch_move_to(dev, 0, 70, 70, 40, 50, 10);
|
2014-11-05 11:20:36 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_touch_up(dev, 1);
|
|
|
|
|
|
2015-04-24 15:27:34 +10:00
|
|
|
litest_assert_only_typed_events(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
2014-11-05 11:20:36 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-02-25 16:30:06 +10:00
|
|
|
START_TEST(touch_protocol_a_init)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-18 18:28:26 +10:00
|
|
|
litest_wait_for_event(li);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_has_capability(device,
|
2015-02-25 16:30:06 +10:00
|
|
|
LIBINPUT_DEVICE_CAP_TOUCH));
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_protocol_a_touch)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
double x, y, oldx, oldy;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 5, 95);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
2015-05-04 13:51:39 +10:00
|
|
|
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
oldx = libinput_event_touch_get_x(tev);
|
|
|
|
|
oldy = libinput_event_touch_get_y(tev);
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
2017-05-30 10:13:32 +10:00
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
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, 10, 90, 90, 10, 20);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
while ((ev = libinput_get_event(li))) {
|
|
|
|
|
if (libinput_event_get_type(ev) ==
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME) {
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2024-09-18 14:44:38 +10:00
|
|
|
|
|
|
|
|
litest_assert_event_type(ev, LIBINPUT_EVENT_TOUCH_MOTION);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
tev = libinput_event_get_touch_event(ev);
|
|
|
|
|
x = libinput_event_touch_get_x(tev);
|
|
|
|
|
y = libinput_event_touch_get_y(tev);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_gt(x, oldx);
|
|
|
|
|
litest_assert_int_lt(y, oldy);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
oldx = x;
|
|
|
|
|
oldy = y;
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-05-30 10:13:32 +10:00
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_UP);
|
|
|
|
|
libinput_event_destroy(ev);
|
2015-02-25 16:30:06 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_protocol_a_2fg_touch)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *tev;
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 5, 95);
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_touch_down(dev, 1, 95, 5);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_assert_touch_down_frame(li);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
2017-05-30 10:13:32 +10:00
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
|
|
|
|
libinput_event_destroy(ev);
|
2015-02-25 16:30:06 +10:00
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
2017-05-30 10:13:32 +10:00
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
2015-02-25 16:30:06 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
for (pos = 10; pos < 100; pos += 10) {
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_touch_move(dev, 0, pos, 100 - pos);
|
|
|
|
|
litest_touch_move(dev, 1, 100 - pos, pos);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-05-30 10:13:32 +10:00
|
|
|
|
2015-02-25 16:30:06 +10:00
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
tev = libinput_event_get_touch_event(ev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_touch_get_slot(tev), 0);
|
2019-03-22 15:47:21 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
2015-02-25 16:30:06 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
tev = libinput_event_get_touch_event(ev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_touch_get_slot(tev), 1);
|
2015-02-25 16:30:06 +10:00
|
|
|
libinput_event_destroy(ev);
|
2017-05-30 10:13:32 +10:00
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(ev);
|
2015-02-25 16:30:06 +10:00
|
|
|
}
|
|
|
|
|
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_touch_up(dev, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_assert_touch_up_frame(li);
|
2017-05-30 10:13:32 +10:00
|
|
|
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_touch_up(dev, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-22 15:47:21 +10:00
|
|
|
litest_assert_touch_up_frame(li);
|
2015-02-25 16:30:06 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-05-08 13:06:25 +10:00
|
|
|
START_TEST(touch_initial_state)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput *libinput1, *libinput2;
|
2015-05-29 18:40:25 -07:00
|
|
|
struct libinput_event *ev1 = NULL;
|
|
|
|
|
struct libinput_event *ev2 = NULL;
|
2015-05-08 13:06:25 +10:00
|
|
|
struct libinput_event_touch *t1, *t2;
|
|
|
|
|
struct libinput_device *device1, *device2;
|
2025-02-13 22:10:02 +01:00
|
|
|
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
2015-05-08 13:06:25 +10:00
|
|
|
|
|
|
|
|
dev = litest_current_device();
|
|
|
|
|
device1 = dev->libinput_device;
|
|
|
|
|
libinput_device_config_tap_set_enabled(device1,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_DISABLED);
|
|
|
|
|
|
|
|
|
|
libinput1 = dev->libinput;
|
|
|
|
|
litest_touch_down(dev, 0, 40, 60);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
/* device is now on some x/y value */
|
|
|
|
|
litest_drain_events(libinput1);
|
|
|
|
|
|
|
|
|
|
libinput2 = litest_create_context();
|
|
|
|
|
device2 = libinput_path_add_device(libinput2,
|
|
|
|
|
libevdev_uinput_get_devnode(
|
|
|
|
|
dev->uinput));
|
|
|
|
|
libinput_device_config_tap_set_enabled(device2,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_DISABLED);
|
|
|
|
|
litest_drain_events(libinput2);
|
|
|
|
|
|
|
|
|
|
if (axis == ABS_X)
|
|
|
|
|
litest_touch_down(dev, 0, 40, 70);
|
|
|
|
|
else
|
|
|
|
|
litest_touch_down(dev, 0, 70, 60);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput1);
|
|
|
|
|
litest_dispatch(libinput2);
|
2015-05-08 13:06:25 +10:00
|
|
|
|
|
|
|
|
while (libinput_next_event_type(libinput1)) {
|
|
|
|
|
ev1 = libinput_get_event(libinput1);
|
|
|
|
|
ev2 = libinput_get_event(libinput2);
|
|
|
|
|
|
|
|
|
|
t1 = litest_is_touch_event(ev1, 0);
|
|
|
|
|
t2 = litest_is_touch_event(ev2, 0);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_get_type(ev1),
|
2015-05-08 13:06:25 +10:00
|
|
|
libinput_event_get_type(ev2));
|
|
|
|
|
|
|
|
|
|
if (libinput_event_get_type(ev1) == LIBINPUT_EVENT_TOUCH_UP ||
|
|
|
|
|
libinput_event_get_type(ev1) == LIBINPUT_EVENT_TOUCH_FRAME)
|
|
|
|
|
break;
|
|
|
|
|
|
2024-10-14 15:26:57 +10:00
|
|
|
litest_assert_double_eq(libinput_event_touch_get_x(t1),
|
|
|
|
|
libinput_event_touch_get_x(t2));
|
|
|
|
|
litest_assert_double_eq(libinput_event_touch_get_y(t1),
|
|
|
|
|
libinput_event_touch_get_y(t2));
|
2015-05-08 13:06:25 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev1);
|
|
|
|
|
libinput_event_destroy(ev2);
|
2019-10-30 10:38:02 +10:00
|
|
|
ev1 = NULL;
|
|
|
|
|
ev2 = NULL;
|
2015-05-08 13:06:25 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev1);
|
|
|
|
|
libinput_event_destroy(ev2);
|
|
|
|
|
|
2020-07-03 10:47:13 +10:00
|
|
|
litest_destroy_context(libinput2);
|
2015-05-08 13:06:25 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-07-27 17:51:52 +08:00
|
|
|
START_TEST(touch_time_usec)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_touch *tev;
|
2016-04-08 15:51:26 +08:00
|
|
|
uint64_t time_usec;
|
2015-07-27 17:51:52 +08:00
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 10, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-07-27 17:51:52 +08:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
|
2016-04-08 15:51:26 +08:00
|
|
|
time_usec = libinput_event_touch_get_time_usec(tev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_touch_get_time(tev),
|
2016-04-08 15:51:26 +08:00
|
|
|
(uint32_t) (time_usec / 1000));
|
2015-07-27 17:51:52 +08:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-04-14 15:21:50 +10:00
|
|
|
START_TEST(touch_fuzz)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
int i;
|
|
|
|
|
int x = 700, y = 300;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_TRACKING_ID, 30);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_X, x);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_Y, y);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-04-14 15:21:50 +10:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 50; i++) {
|
|
|
|
|
if (i % 2) {
|
|
|
|
|
x++;
|
|
|
|
|
y--;
|
|
|
|
|
} else {
|
|
|
|
|
x--;
|
|
|
|
|
y++;
|
|
|
|
|
}
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_X, x);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_Y, y);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-04-14 15:21:50 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-09-10 15:16:49 +10:00
|
|
|
START_TEST(touch_fuzz_property)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct udev_device *d;
|
|
|
|
|
const char *prop;
|
2024-10-13 11:06:39 +10:00
|
|
|
int fuzz = 0;
|
2018-09-10 15:16:49 +10:00
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libevdev_get_abs_fuzz(dev->evdev, ABS_X), 0);
|
|
|
|
|
litest_assert_int_eq(libevdev_get_abs_fuzz(dev->evdev, ABS_Y), 0);
|
2018-09-10 15:16:49 +10:00
|
|
|
|
|
|
|
|
d = libinput_device_get_udev_device(dev->libinput_device);
|
|
|
|
|
prop = udev_device_get_property_value(d, "LIBINPUT_FUZZ_00");
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(prop);
|
|
|
|
|
litest_assert(safe_atoi(prop, &fuzz));
|
|
|
|
|
litest_assert_int_eq(fuzz, 10); /* device-specific */
|
2018-09-10 15:16:49 +10:00
|
|
|
|
|
|
|
|
prop = udev_device_get_property_value(d, "LIBINPUT_FUZZ_01");
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(prop);
|
|
|
|
|
litest_assert(safe_atoi(prop, &fuzz));
|
|
|
|
|
litest_assert_int_eq(fuzz, 12); /* device-specific */
|
2018-09-10 15:16:49 +10:00
|
|
|
|
|
|
|
|
udev_device_unref(d);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-08-28 12:03:54 +10:00
|
|
|
START_TEST(touch_release_on_unplug)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
|
|
|
|
|
li = litest_create_context();
|
|
|
|
|
dev = litest_add_device(li, LITEST_GENERIC_MULTITOUCH_SCREEN);
|
|
|
|
|
litest_drain_events(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, 70, 70, 10);
|
2017-08-28 12:03:54 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2020-08-27 19:52:34 +02:00
|
|
|
/* Touch is still down when device is removed, expect a release */
|
2017-08-28 12:03:54 +10:00
|
|
|
litest_delete_device(dev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-08-28 12:03:54 +10:00
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
2018-09-20 14:09:31 +10:00
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_CANCEL);
|
2017-08-28 12:03:54 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
litest_assert_event_type(ev, LIBINPUT_EVENT_DEVICE_REMOVED);
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
|
2020-07-03 10:47:13 +10:00
|
|
|
litest_destroy_context(li);
|
2017-08-28 12:03:54 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-04-13 14:00:05 +10:00
|
|
|
START_TEST(touch_invalid_range_over)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *t;
|
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Touch outside the valid area */
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_TRACKING_ID, 1);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_X, 4000);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_Y, 5000);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_X, 4000);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_Y, 5000);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
/* Expect the mm to be correct regardless */
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
t = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
|
|
|
|
x = libinput_event_touch_get_x(t);
|
|
|
|
|
y = libinput_event_touch_get_y(t);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(x, 300); /* device has resolution 10 */
|
|
|
|
|
litest_assert_double_eq(y, 300); /* device has resolution 10 */
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
/* Expect the percentage to be correct too, even if > 100% */
|
|
|
|
|
x = libinput_event_touch_get_x_transformed(t, 100);
|
|
|
|
|
y = libinput_event_touch_get_y_transformed(t, 100);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(round(x), 200);
|
|
|
|
|
litest_assert_double_eq(round(y), 120);
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_invalid_range_under)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_touch *t;
|
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Touch outside the valid area */
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_TRACKING_ID, 1);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_X, -500);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_Y, 1000);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_X, -500);
|
|
|
|
|
litest_event(dev, EV_ABS, ABS_MT_POSITION_Y, 1000);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_TOUCH, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
/* Expect the mm to be correct regardless */
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
t = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
|
|
|
|
x = libinput_event_touch_get_x(t);
|
|
|
|
|
y = libinput_event_touch_get_y(t);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(x, -150); /* device has resolution 10 */
|
|
|
|
|
litest_assert_double_eq(y, -100); /* device has resolution 10 */
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
/* Expect the percentage to be correct too, even if > 100% */
|
|
|
|
|
x = libinput_event_touch_get_x_transformed(t, 100);
|
|
|
|
|
y = libinput_event_touch_get_y_transformed(t, 100);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(round(x), -100);
|
|
|
|
|
litest_assert_double_eq(round(y), -40);
|
2018-04-13 14:00:05 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-01-31 16:04:09 +10:00
|
|
|
START_TEST(touch_count_st)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_device_touch_get_touch_count(device), 1);
|
2018-01-31 16:04:09 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_count_mt)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libevdev *evdev = dev->evdev;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_device_touch_get_touch_count(device),
|
2018-01-31 16:04:09 +10:00
|
|
|
libevdev_get_num_slots(evdev));
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_count_unknown)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_device_touch_get_touch_count(device), 0);
|
2018-01-31 16:04:09 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_count_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_int_eq(libinput_device_touch_get_touch_count(device), -1);
|
2018-01-31 16:04:09 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-07-13 16:08:54 +10:00
|
|
|
static inline bool
|
|
|
|
|
touch_has_tool_palm(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
return libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_TOOL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
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, 70, 70, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_drain_events(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_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_cancel(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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm_on_off)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
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, 70, 70, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_drain_events(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_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_cancel(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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_axis_set_value(axes, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
|
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_extended(dev, 0, 50, 40, 70, 70, axes, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm_keep_type)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
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, 70, 70, 10);
|
|
|
|
|
litest_touch_move_to_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* ABS_MT_TOOL_TYPE never reset to finger, so a new touch
|
|
|
|
|
should be ignored outright */
|
|
|
|
|
litest_touch_down_extended(dev, 0, 50, 50, axes);
|
|
|
|
|
|
|
|
|
|
/* Test the revert to finger case too */
|
|
|
|
|
litest_axis_set_value(axes, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
|
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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm_2fg)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_down(dev, 1, 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, 70, 70, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_drain_events(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_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_cancel(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, 1, 50, 50, 70, 70, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_motion_frame(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_up_frame(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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm_on_off_2fg)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_down(dev, 1, 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, 70, 70, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_drain_events(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_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_cancel(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, 1, 50, 50, 70, 70, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_motion_frame(li);
|
|
|
|
|
|
|
|
|
|
litest_axis_set_value(axes, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
|
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_extended(dev, 0, 50, 40, 70, 70, axes, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
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, 1, 70, 70, 50, 40, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_motion_frame(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_up_frame(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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(touch_palm_detect_tool_palm_keep_type_2fg)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct axis_replacement axes[] = {
|
|
|
|
|
{ ABS_MT_TOOL_TYPE, MT_TOOL_PALM },
|
|
|
|
|
{ -1, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!touch_has_tool_palm(dev))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-07-13 16:08:54 +10:00
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, 50, 50);
|
|
|
|
|
litest_touch_down(dev, 1, 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, 70, 70, 10);
|
|
|
|
|
litest_touch_move_to_extended(dev, 0, 50, 50, 70, 70, axes, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
litest_drain_events(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, 1, 50, 50, 70, 70, 10);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_motion_frame(li);
|
|
|
|
|
|
|
|
|
|
/* ABS_MT_TOOL_TYPE never reset to finger, so a new touch
|
|
|
|
|
should be ignored outright */
|
|
|
|
|
litest_touch_down_extended(dev, 0, 50, 50, axes);
|
|
|
|
|
|
|
|
|
|
/* Test the revert to finger case too */
|
|
|
|
|
litest_axis_set_value(axes, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
|
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, 70, 70, 50, 40, 10);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_touch_up(dev, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-07-13 16:08:54 +10:00
|
|
|
litest_assert_touch_up_frame(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-03-21 12:54:10 +10:00
|
|
|
TEST_COLLECTION(touch)
|
2014-02-18 20:13:58 +01:00
|
|
|
{
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(touch_frame_events, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(touch_downup_no_motion, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(touch_downup_no_motion, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add_no_device(touch_abs_transform);
|
|
|
|
|
litest_add(touch_seat_slot, LITEST_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add_no_device(touch_many_slots);
|
|
|
|
|
litest_add(touch_double_touch_down_up, LITEST_TOUCH, LITEST_PROTOCOL_A);
|
|
|
|
|
litest_add(touch_calibration_scale, LITEST_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_calibration_scale, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_calibration_rotation, LITEST_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_calibration_rotation, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_calibration_translation, LITEST_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_calibration_translation, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add_for_device(touch_calibrated_screen_path, LITEST_CALIBRATED_TOUCHSCREEN);
|
|
|
|
|
litest_add_for_device(touch_calibrated_screen_udev, LITEST_CALIBRATED_TOUCHSCREEN);
|
|
|
|
|
litest_add(touch_calibration_config, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
|
|
|
|
|
litest_add(touch_no_left_handed, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
|
|
|
|
|
litest_add(fake_mt_exists, LITEST_FAKE_MT, LITEST_ANY);
|
|
|
|
|
litest_add(fake_mt_no_touch_events, LITEST_FAKE_MT, LITEST_ANY);
|
|
|
|
|
|
|
|
|
|
litest_add(touch_protocol_a_init, LITEST_PROTOCOL_A, LITEST_ANY);
|
|
|
|
|
litest_add(touch_protocol_a_touch, LITEST_PROTOCOL_A, LITEST_ANY);
|
|
|
|
|
litest_add(touch_protocol_a_2fg_touch, LITEST_PROTOCOL_A, LITEST_ANY);
|
|
|
|
|
|
2025-02-13 22:10:02 +01:00
|
|
|
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
litest_add_parametrized(touch_initial_state, LITEST_TOUCH, LITEST_PROTOCOL_A, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
|
|
|
|
|
litest_add(touch_time_usec, LITEST_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
|
|
|
|
|
litest_add_for_device(touch_fuzz, LITEST_MULTITOUCH_FUZZ_SCREEN);
|
|
|
|
|
litest_add_for_device(touch_fuzz_property, LITEST_MULTITOUCH_FUZZ_SCREEN);
|
|
|
|
|
|
|
|
|
|
litest_add_no_device(touch_release_on_unplug);
|
|
|
|
|
|
|
|
|
|
litest_add_for_device(touch_invalid_range_over, LITEST_TOUCHSCREEN_INVALID_RANGE);
|
|
|
|
|
litest_add_for_device(touch_invalid_range_under, LITEST_TOUCHSCREEN_INVALID_RANGE);
|
|
|
|
|
|
|
|
|
|
litest_add(touch_count_st, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(touch_count_mt, LITEST_TOUCH, LITEST_SINGLE_TOUCH|LITEST_PROTOCOL_A);
|
|
|
|
|
litest_add(touch_count_unknown, LITEST_PROTOCOL_A, LITEST_ANY);
|
|
|
|
|
litest_add(touch_count_invalid, LITEST_ANY, LITEST_TOUCH|LITEST_SINGLE_TOUCH|LITEST_PROTOCOL_A);
|
|
|
|
|
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm_on_off, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm_keep_type, LITEST_TOUCH, LITEST_ANY);
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm_2fg, LITEST_TOUCH, LITEST_SINGLE_TOUCH);
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm_on_off_2fg, LITEST_TOUCH, LITEST_SINGLE_TOUCH);
|
|
|
|
|
litest_add(touch_palm_detect_tool_palm_keep_type_2fg, LITEST_TOUCH, LITEST_ANY);
|
2014-01-22 10:34:11 +10:00
|
|
|
}
|