[PATCH libinput 3/4] test: allow the first event to be a short one during scroll tests

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 22 01:32:43 UTC 2016


The hysteresis cuts the first pointer motion by the hysteresis margin. On some
touchpads this causes the tests to fail when the motion history length is
reduced (future patch). Allow the first event to be smaller than the expected
minimum.

This doesn't trigger in current tests because the hysteresis is per-event and
by the time we get past the minimum 4 events to move the pointer, we're
already flying unaffected by the hysteresis.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/litest.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index e685d61..b74f905 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -2806,6 +2806,7 @@ litest_assert_scroll(struct libinput *li,
 	struct libinput_event *event, *next_event;
 	struct libinput_event_pointer *ptrev;
 	int value;
+	int nevents = 0;
 
 	event = libinput_get_event(li);
 	next_event = libinput_get_event(li);
@@ -2813,16 +2814,26 @@ litest_assert_scroll(struct libinput *li,
 
 	while (event) {
 		ptrev = litest_is_axis_event(event, axis, 0);
+		nevents++;
 
 		if (next_event) {
+			int min = minimum_movement;
+
 			value = libinput_event_pointer_get_axis_value(ptrev,
 								      axis);
+			/* Due to how the hysteresis works on touchpad
+			 * events, the first event is reduced by the
+			 * hysteresis margin that can cause the first event
+			 * go under the minimum we expect for all other
+			 * events */
+			if (nevents == 1)
+				min = minimum_movement/2;
+
 			/* Normal scroll event, check dir */
-			if (minimum_movement > 0) {
-				litest_assert_int_ge(value, minimum_movement);
-			} else {
-				litest_assert_int_le(value, minimum_movement);
-			}
+			if (minimum_movement > 0)
+				litest_assert_int_ge(value, min);
+			else
+				litest_assert_int_le(value, min);
 		} else {
 			/* Last scroll event, must be 0 */
 			ck_assert_double_eq(
-- 
2.9.3



More information about the wayland-devel mailing list