From dee0e5e72597d2535f43d43cbeb8364fd5afffd1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 15 Mar 2021 16:56:23 +1000 Subject: [PATCH] test: simplify the helper for moving three touches at the same time There's no test case where we need to do something immediately after the last event so we might as well do everything in the same loop. This also fixes a bug where the first movement would usually get swallowed. Test cases in general put the finger down at x/y, then move them to some other position. We'd expect the first event in a loop to happen at x+n/y+n, not at x/y again. Signed-off-by: Peter Hutterer --- test/litest.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/litest.c b/test/litest.c index 89580118..0f086caf 100644 --- a/test/litest.c +++ b/test/litest.c @@ -2576,21 +2576,18 @@ litest_touch_move_three_touches(struct litest_device *d, { int sleep_ms = 10; - for (int i = 0; i < steps - 1; i++) { - litest_touch_move(d, 0, x0 + dx / steps * i, - y0 + dy / steps * i); - litest_touch_move(d, 1, x1 + dx / steps * i, - y1 + dy / steps * i); - litest_touch_move(d, 2, x2 + dx / steps * i, - y2 + dy / steps * i); + for (int i = 1; i <= steps; i++) { + double step_x = dx / steps * i; + double step_y = dy / steps * i; + + litest_touch_move(d, 0, x0 + step_x, y0 + step_y); + litest_touch_move(d, 1, x1 + step_x, y1 + step_y); + litest_touch_move(d, 2, x2 + step_x, y2 + step_y); libinput_dispatch(d->libinput); msleep(sleep_ms); - libinput_dispatch(d->libinput); } - litest_touch_move(d, 0, x0 + dx, y0 + dy); - litest_touch_move(d, 1, x1 + dx, y1 + dy); - litest_touch_move(d, 2, x2 + dx, y2 + dy); + libinput_dispatch(d->libinput); } void