From: Peter Hutterer Date: Mon, 7 Jul 2014 22:52:40 +0000 (+1000) Subject: test: fix expected delta from relative motion X-Git-Tag: 0.5.0~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4d50a73a1e963bdcc9ca63dd1a760eb9d777d1f;p=platform%2Fupstream%2Flibinput.git test: fix expected delta from relative motion 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 --- 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). */