mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 11:10:29 +01:00
test: Test handling of many touch points
libinput currently handles 16 per device touch points. Test that we behave as expected when a device has an even higher number of active touch points. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
cf2d61439e
commit
f8e8a265fe
1 changed files with 55 additions and 0 deletions
55
test/touch.c
55
test/touch.c
|
|
@ -113,11 +113,66 @@ START_TEST(touch_abs_transform)
|
|||
END_TEST
|
||||
|
||||
|
||||
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 },
|
||||
};
|
||||
|
||||
dev = litest_create_device_with_overrides(LITEST_WACOM_TOUCH,
|
||||
"Multi-touch device",
|
||||
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);
|
||||
|
||||
libinput_dispatch(libinput);
|
||||
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;
|
||||
|
||||
libinput_dispatch(libinput);
|
||||
}
|
||||
|
||||
ck_assert_notnull(ev);
|
||||
ck_assert_int_gt(slot_count, 0);
|
||||
|
||||
libinput_dispatch(libinput);
|
||||
do {
|
||||
type = libinput_event_get_type(ev);
|
||||
ck_assert_int_ne(type, LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
if (type == LIBINPUT_EVENT_TOUCH_UP)
|
||||
slot_count--;
|
||||
|
||||
libinput_dispatch(libinput);
|
||||
} while ((ev = libinput_get_event(libinput)));
|
||||
|
||||
ck_assert_int_eq(slot_count, 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
litest_add("touch:frame", touch_frame_events, LITEST_TOUCH, LITEST_ANY);
|
||||
litest_add_no_device("touch:abs-transform", touch_abs_transform);
|
||||
litest_add_no_device("touch:many-slots", touch_many_slots);
|
||||
|
||||
return litest_run(argc, argv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue