From e4d50a73a1e963bdcc9ca63dd1a760eb9d777d1f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 8 Jul 2014 08:52:40 +1000 Subject: [PATCH] test: fix expected delta from relative motion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Hans de Goede --- test/pointer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pointer.c b/test/pointer.c index 3db0165b..aa75274b 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). */ -- 2.34.1