Commit graph

514 commits

Author SHA1 Message Date
Peter Hutterer
ecb2664e05 test: fix litest_abort_msg() not starting a new line
Most callers of litest_abort_msg() don't add '\n' so the output was
mangled.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1062>
2024-10-16 18:03:03 +10:00
Peter Hutterer
f89fd6d924 test: switch ck_assert over to litest_assert
This is the first step in switching away from the check framework.
Our litest macros already do almost exactly the same anyway so most of
this is a simple sed with a few compiler fixes where things mismatch
(nonnull -> notnull) and (_tol -> _epsilon).

This now generates a whole bunch of integer mismatch warnings: check
casts everything to intmax_t whereas we use typeof, so lots of warnings
especially for enums.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
0bc2bf60d2 test: add litest string comparison macros
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
3ed70e864f test: add litest_assert_event_type_not_one_of
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
67061c1af0 test: replace ck_abort with litest_abort_msg()
Weirdly, that also required initializing two variables to NULL to stop a
compiler warning.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
7316a627d6 test: add a missing va_end
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
aecfcf3d1b test: fix uinput creation for the slotted devices with too many slots
Kernel commit 206f533a0a7c
       "Input: uinput - reject requests with unreasonable number of slots"
limits the number of slots to 99 - let's manually adjust that so we can
keep creating uinput devices.

Since these are just a test device and we don't use the slots here
anyway (they're all fake MT devices) we can manually work around this.
The real devices won't be affected by this since this is a limitation
in uinput, not the input subsystem.

Also move the comment one line up in the ms-surface device, the previous
comment referred to the wrong event code.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1061>
2024-10-15 09:56:19 +10:00
Peter Hutterer
c123a76b0d test: make litest-test-suite --list YAML-compatible
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1060>
2024-10-14 08:56:07 +00:00
Peter Hutterer
5b5776b148 test: move the test devices into the test_device_section
Better naming this way

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1060>
2024-10-14 08:56:07 +00:00
Peter Hutterer
3577369805 test: switch unused argc/argv to the list of tests
This means we don't rely on the "all_tests" global here though it also
means we need to move the cleanup into the caller.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1060>
2024-10-14 08:56:07 +00:00
Peter Hutterer
86c47be816 test: add litest_dispatch() for better test debugging
Wraps libinput_dispatch() with a location which will make things a bit
easier to track. Output (in --verbose) is something like:

  gestures_swipe_3fg_unaccel_fn():1346 - dispatching

Which makes it easier to associate the various calls to libinput
dispatch with the other output from libinput.

This patch switches all uses of libinput_dispatch() in test cases over
but not the litest functions that may call dispatch too. Remains to be
seen if that is necessary.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-19 15:21:04 +10:00
Peter Hutterer
27e3897420 test: abort on libinput bugs again
This was always intended but a bug prevented the actual abort.
strstr returns NULL when we cannot find the substring so we always
triggered the first noop condition on bugs.

Fixes: bd7b91065b ("evdev: warn if our event processing lags by 10ms or more")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-19 15:07:50 +10:00
Peter Hutterer
596d86ecc1 test: improve event debugging a bit
Add a litest_checkpoint macro and convert a few of the litest_assert
macros to make use of that - this gives us a printf of the call site in
case it fails.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-19 15:07:44 +10:00
Peter Hutterer
721426a1be test: highlight the gesture state machine log messages in yellow
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 15:24:47 +10:00
Peter Hutterer
0ec0a4212a test: make litest_wait_for_event_of_type auto-terminating
Wrap this in a macro so we cannot forget to pass -1

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 12:37:55 +10:00
Peter Hutterer
d0bec3843a test: make litest_drain_events_of_type auto-terminating
Wrap this in a macro so we cannot forget to pass -1

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 12:37:50 +10:00
Peter Hutterer
47f94633fe test: remove some old compat code for kernel<4.5
Kernel 4.5 and libevdev 1.5 were released in 2016, this code is no
longer necessary.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/986>
2024-03-18 23:02:05 +00:00
Peter Hutterer
3d246ef248 test: remove a workaround for libevdev 1.2 and earlier
libevdev 1.3 was released in 2014.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/986>
2024-03-18 23:02:05 +00:00
Peter Hutterer
34f86489a8 Revert "test: allow for substring matching in the various --filter- arguments"
Substring matching means it's impossible to select filters that are
substrings of others, making it too painful to test one specific filter.

This reverts commit a524cf9761.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
c775c23121 test: slightly increase the finger switch timeout wait
In touchpad_2fg_scroll_return_to_motion we sometimes fail because the
timeout is too close to the actual timeout expiry, creating a race
condition on whether the scroll stop event (triggered by the gesture
end) is sent before or after the timeout expiry.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
9c69152428 Move mkdir_p into a utility header
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
3644372696 test: add helpers for checking (negative) errnos
This way we get to see the actual error when it happens.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Joshua Goins
beca998122 tablet: add API for relative dials
Some tablets such as those in the XP-PEN PRO series use "dials" which
are actually scrollwheels and emit EV_REL events. These should not be
emulated as rings (which are absolute) so we must expose them as a new
tablet event.

Adds LIBINPUT_EVENT_TABLET_PAD_DIAL that work largely identical as our
high-resolution wheel events (i.e. the values are in multiples or
fractions of of 120). Currently supports two dials.

This is a lot of copy/paste from the ring axes because the interface is
virtually identical. The main difference is that dials give us a v120
value in the same manner as our scroll axes.

Notes:
- REL_DIAL is mutually exclusive with REL_WHEEL, we assume the kernel
  doesn't (at this point) give us devices with both. If this changes for
  devices with three dials (wheel + hwheel + dial) we need to add code
  for that.
- REL_DIAL does not have a high-resolution axis and we assume that any
  device with REL_WHEEL_HI_RES will also have REL_HWHEEL_HI_RES (if the
  second wheel exists).
- With dials being REL_DIAL or REL_WHEEL there is no possibility of
  detecting a finger release (the kernel does not route EV_RELs with a
  value of zero). Unless this is implemented via a side-channel - and it
  doesn't look like any hardware that supports dials does that - we
  cannot forward any information here. So unlike absolute rings we
  cannot provide a source information here.

Closes #600

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/967>
2024-02-20 02:49:05 +00:00
Peter Hutterer
c5f808ac2e test: debug print the events we're draining 2024-01-22 01:21:29 +00:00
Peter Hutterer
3fb876a49d test: expand the tablet mode switch test to check for fake key releases
If a key is still down when the tablet mode switch goes on, make sure we
release the key before the switch goes in effect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-07-17 09:32:24 +10:00
Peter Hutterer
44de3ff367 test: add an extra override hook for tablet motion
Currently unused but it complements the existing override handlers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-07 09:23:05 +10:00
Peter Hutterer
160b062454 test: change tablet coords to doubles and pass the pointer through
All other motion/touch/... coords are already doubles so let's follow
suite here. And passing a pointer into the custom handlers
means we can modify x/y slightly and return false, leaving the rest up
to the generic event handling code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-07 09:23:05 +10:00
José Expósito
8a6ca3c1c5 sparse: make some variables static
When compiling with Sparse enabled:

	$ CC=cgcc meson builddir

Fix warnings about variables that should be made static.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-11-23 21:57:28 +00:00
Peter Hutterer
395d12d634 util: auto-declare the element variable in ARRAY_FOR_EACH
All cases we have in our code base have an otherwise unused variable to
loop through the array. Let's auto-declare this as part of the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-09 10:16:07 +10:00
Peter Hutterer
878d00b0e9 test: add tip down/up helper functions
Add two helper functions that set/unset BTN_TOUCH together with the
specified axes and switch all tests over.

Devices can override the tip down/up sequence.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-11-24 06:17:31 +00:00
José Expósito
b6a944bb80 wheel: ignore initial small scroll deltas
Mice with high-resolution support can generate deltas when the finger is
put on the wheel or when the user tries to click the wheel.

To avoid sending involuntary scroll events, add an extra state the the
wheel state machine to accumulate scroll deltas.
While the accumulated scroll is lower than a certain threshold, ignore
them until the threshold is reached.

Since no finish event is sent by the mouse, reset the state machine
after a period of scroll inactivity.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-11-08 18:00:46 +01:00
José Expósito
e0aa946e39 test: add kernel bugs to log handler
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-09-27 22:43:22 +00:00
Peter Hutterer
6bb02aaf30 High-resolution scroll wheel support
Starting with kernel v5.0 two new axes are available for high-resolution wheel
scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in
fractions of 120 where each multiple of 120 amounts to one logical scroll
event. Fractions of 120 indicate a wheel movement less than one detent.

This commit adds a new API for scroll events. Three new event types that encode
the axis source in the event type name and a new API to get a normalized-to-120
value that also used by Windows and the kernel (each multiple of 120 represents
a logical scroll click).

This addresses a main shortcoming with the existing API - it was unreliable to
calculate the click angle based on the axis value+discrete events and thus any
caller using the axis value alone would be left with some ambiguity. With the
v120 API it's now possible to (usually) calculate the click angle, but more
importantly it provides the simplest hw-independent way of scrolling by a
click or a fraction of a click.

A new event type is required, the only way to integrate the v120 value
otherwise was to start sending events with a discrete value of 0. This
would break existing xf86-input-libinput (divide by zero, fixed in 0.28.2) and
weston (general confusion). mutter, kwin are unaffected.

With the new API, the old POINTER_AXIS event are deprecated - callers should use
the new API where available and discard any POINTER_AXIS events.

Notable: REL_WHEEL/REL_HWHEEL are emulated by the kernel but there's no
guarantee that they'll come every accumulated 120 values, e.g. Logitech mice
often send events that don't add up to 120 per detent.

We use the kernel's wheel click emulation instead of doing our own.

libinput guarantees high-resolution events even on pre-5.0 kernels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 08:45:01 +02:00
José Expósito
427c855d21 test: refactor litest_assert_event_type logic
Extract the logic in litest_assert_event_type to a generic function,
litest_assert_event_type_is_one_of, that takes a variable number of
expected event types.

Refactor, no functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 14:42:15 +10:00
Peter Hutterer
b925b55634 test: use MESON_TESTTHREADS to determine the number of jobs
meson uses MESON_TESTTHREADS to determine the number of parallel test
jobs. Since our main test suite cannot be run in parallel anyway, use
that same variable in litest to determine how many jobs we should fork
off.

In the CI pipeline, we can use FDO_CI_CONCURRENT to pass that down so we
don't end up running a billion jobs on a test runner.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-03 22:14:29 +00:00
luokai
87447a0ee9 using secure functions safe_strdup
Signed-off-by: luokai <l18674732394.com>
2021-06-15 11:27:29 +08:00
José Expósito
9b024c6928 gestures: add quick hold implementation
When 1 or 2 fingers are used to hold, use a faster timer to make the
"hold to stop kinetic scrolling" user interaction feel more immediate.

Also handle double tap and tap and drag interations to send only one
hold gesture instead of two.

Holding with 3 or 4 fingers remains the same to try to avoid callers
missusing hold gestures to build their own tap implementation.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
José Expósito
a18d9d3de4 tests: optionally hold in gesture test functions
Add an extra parameter to the common gesture test functions to allow to hold
before performing the gesture.

This parameter will be used by the hold tests allowing to share the code.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
José Expósito
b6b15fa304 libinput: add hold gesture public API and tool support
Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
Peter Hutterer
1d9cdf76a5 test: push/pop event frames around three-touch movements
Without this, each finger movement happens in a different evdev event frame.
Since we average deltas for gestures, this messes with the expected data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
dee0e5e725 test: simplify the helper for moving three touches at the same time
There's no test case where we need to do something immediately after the last
event so we might as well do everything in the same loop.

This also fixes a bug where the first movement would usually get swallowed.
Test cases in general put the finger down at x/y, then move them to some other
position. We'd expect the first event in a loop to happen at x+n/y+n, not at
x/y again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
5129d178b3 test: fix debugging messages for gesture begin event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Konstantin Kharlamov
3d3d9b7f69 treewide: get rid of tmp argument in list_for_each_safe
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2021-03-02 09:10:35 +03:00
Peter Hutterer
e96852ac37 test: add test cases for 2/3 finger movement after tap
We have two behaviors here:
- tap + 2fg -> scrolling
- tap + 1fg move + 2f down -> dragging

Let's document this. The 3fg case only has one situation, so let's test that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 18:03:34 +10:00
Peter Hutterer
06ef838b5b test: drop the needless base event conversion
This was just there to avoid unused variable warnings but the simpler approach
to that is to just not assign a variable in the first place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 18:03:34 +10:00
Peter Hutterer
b8d4197697 test: print the event type on mismatch
We already have a helper function for this, let's use it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 17:34:51 +10:00
satrmb
a91ecbde74 touchpad: stretch the tap-and-drag timeout a bit depending on finger count
Some users reported problems triggering multi-finger tap-and-drag,
with reliability decreasing as the finger count increased.
This is plausible because they may shift towards moving the whole hand
up and down, which obviously takes more time than just a finger.

Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org>
2021-02-15 05:46:46 +00:00
Peter Hutterer
d3115f4875 test: drop the custom group names
The group names are forced by check (they are called suite names there) but
for our test suite they provide very little benefit. Much easier to just
use the filename a test is in as group name.

This removes the pure substring match for --filter-group, it's now fnmatch
only. group names are short enough that the typing isn't an issue and we don't
want to run tests twice (e.g. 'pad' is also in 'touchpad').

This patch caused #574 until it got fixed in d838e3a3a4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 15:24:15 +10:00
Peter Hutterer
4422e95747 test: don't require root to list tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-05 16:04:54 +10:00
weizhixiang
2ed0f24e20 check return value for libudev/udev_device_get_action
Signed-off-by: weizhixiang <1138871845@qq.com>
2021-01-06 17:46:14 +08:00