test: fix expected delta from relative motion
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 7 Jul 2014 22:52:40 +0000 (08:52 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 9 Jul 2014 02:39:45 +0000 (12:39 +1000)
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@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
test/pointer.c

index 3db0165b417dd5bd101ed69396e351d76c35c745..aa75274b1330f3ccef5376ac156d2d956d041419 100644 (file)
@@ -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). */