From 2e339095b38b06b72a5ce6c4485c8aad758a74e7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 3 Jul 2015 09:09:16 +1000 Subject: [PATCH] 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 --- test/pointer.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/pointer.c b/test/pointer.c index 2cd2a2da..28d7c9a6 100644 --- a/test/pointer.c +++ b/test/pointer.c @@ -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);