[PATCH libinput 2/6] test: fix expected delta from relative motion
Peter Hutterer
peter.hutterer at who-t.net
Mon Jul 7 16:21:18 PDT 2014
We send two delta events. One may get eaten or softened by the accel code but
our expectation should be that both may get through, so the length of the
expected vector is √((2dx)² + (2dy)²). That is the maximum length we expect
though for deltas ranged [-1, 1].
Deltas above the threshold would fail this test but we can fix that when
needed.
Pointer acceleration is subject to timing changes. When running tests in
valgrind pointer accel timeouts and tracker resets may happen so we can't
guarantee a specific acceleration length.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/pointer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/pointer.c b/test/pointer.c
index 3db0165..aa75274 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -63,7 +63,7 @@ test_relative_event(struct litest_device *dev, int dx, int dy)
ptrev = libinput_event_get_pointer_event(event);
ck_assert(ptrev != NULL);
- expected_length = sqrt(dx*dx + dy*dy);
+ expected_length = sqrt(4 * dx*dx + 4 * dy*dy);
expected_dir = atan2(dx, dy);
ev_dx = libinput_event_pointer_get_dx(ptrev);
@@ -72,7 +72,7 @@ test_relative_event(struct litest_device *dev, int dx, int dy)
actual_dir = atan2(ev_dx, ev_dy);
/* Check the length of the motion vector (tolerate 1.0 indifference). */
- ck_assert(fabs(expected_length - actual_length) < 1.0);
+ ck_assert(fabs(expected_length) >= actual_length);
/* Check the direction of the motion vector (tolerate 2π/4 radians
* indifference). */
--
1.9.3
More information about the wayland-devel
mailing list