test: add a test for 0/0 relative motion events

This test doesn't really test for that because the kernel shouldn't forward
these events to us in the first place. It's merely a canary to warn us if this
ever changes and we end up not ignoring the events.

The test is only run for one device (the default mouse), no need to waste more
time on this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2015-07-03 09:09:16 +10:00
parent 08fba7bd96
commit 2e339095b3

View file

@ -115,6 +115,47 @@ START_TEST(pointer_motion_relative)
}
END_TEST
START_TEST(pointer_motion_relative_zero)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
int i;
/* NOTE: this test does virtually nothing. The kernel should not
* allow 0/0 events to be passed to userspace. If it ever happens,
* let's hope this test fails if we do the wrong thing.
*/
litest_drain_events(li);
for (i = 0; i < 5; i++) {
litest_event(dev, EV_REL, REL_X, 0);
litest_event(dev, EV_REL, REL_Y, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
libinput_dispatch(li);
}
litest_assert_empty_queue(li);
/* send a single event, the first movement
is always decelerated by 0.3 */
litest_event(dev, EV_REL, REL_X, 1);
litest_event(dev, EV_REL, REL_Y, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
libinput_dispatch(li);
libinput_event_destroy(libinput_get_event(li));
litest_assert_empty_queue(li);
for (i = 0; i < 5; i++) {
litest_event(dev, EV_REL, REL_X, 0);
litest_event(dev, EV_REL, REL_Y, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
libinput_dispatch(dev->libinput);
}
litest_assert_empty_queue(li);
}
END_TEST
START_TEST(pointer_motion_relative_min_decel)
{
struct litest_device *dev = litest_current_device();
@ -1379,6 +1420,7 @@ litest_setup_tests(void)
struct range compass = {0, 7}; /* cardinal directions */
litest_add("pointer:motion", pointer_motion_relative, LITEST_RELATIVE, LITEST_ANY);
litest_add_for_device("pointer:motion", pointer_motion_relative_zero, LITEST_MOUSE);
litest_add_ranged("pointer:motion", pointer_motion_relative_min_decel, LITEST_RELATIVE, LITEST_ANY, &compass);
litest_add("pointer:motion", pointer_motion_absolute, LITEST_ABSOLUTE, LITEST_ANY);
litest_add("pointer:motion", pointer_motion_unaccel, LITEST_RELATIVE, LITEST_ANY);