Currently all the touchpad 2fg tests move the 2 fingers 1 at a time, causing a finger motion which looks more like a pinch zoom in followed by a zoom outthen an actual 2fg scroll gesture. Add a helper function which can move 2 fingers at the same time (more or less), and use this were relevant.
Signed-off-by: Hans de Goede <hdego...@redhat.com> --- test/litest.c | 22 ++++++++++++++++++++++ test/litest.h | 5 +++++ test/touchpad.c | 17 ++++++----------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/test/litest.c b/test/litest.c index 3646446..fc4b1fb 100644 --- a/test/litest.c +++ b/test/litest.c @@ -904,6 +904,28 @@ litest_touch_move_to(struct litest_device *d, } void +litest_touch_move_two_touches(struct litest_device *d, + double x0, double y0, + double x1, double y1, + double dx, double dy, + int steps, int sleep_ms) +{ + 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); + if (sleep_ms) { + 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); +} + +void litest_button_click(struct litest_device *d, unsigned int button, bool is_press) { diff --git a/test/litest.h b/test/litest.h index e85b511..a48daf4 100644 --- a/test/litest.h +++ b/test/litest.h @@ -150,6 +150,11 @@ void litest_touch_move_to(struct litest_device *d, double x_from, double y_from, double x_to, double y_to, int steps, int sleep_ms); +void litest_touch_move_two_touches(struct litest_device *d, + double x0, double y0, + double x1, double y1, + double dx, double dy, + int steps, int sleep_ms); void litest_button_click(struct litest_device *d, unsigned int button, bool is_press); diff --git a/test/touchpad.c b/test/touchpad.c index 36fe6e4..140d770 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -1820,8 +1820,7 @@ test_2fg_scroll(struct litest_device *dev, double dx, double dy, int want_sleep) litest_touch_down(dev, 0, 47, 50); litest_touch_down(dev, 1, 53, 50); - litest_touch_move_to(dev, 0, 47, 50, 47 + dx, 50 + dy, 5, 0); - litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5, 0); + litest_touch_move_two_touches(dev, 47, 50, 53, 50, dx, dy, 5, 0); /* Avoid a small scroll being seen as a tap */ if (want_sleep) { @@ -1880,8 +1879,7 @@ START_TEST(touchpad_2fg_scroll_slow_distance) litest_touch_down(dev, 0, 20, 30); litest_touch_down(dev, 1, 40, 30); - litest_touch_move_to(dev, 0, 20, 30, 20, 30 + y_move, 70, 10); - litest_touch_move_to(dev, 1, 40, 30, 40, 30 + y_move, 70, 10); + litest_touch_move_two_touches(dev, 20, 30, 40, 30, 0, y_move, 70, 10); litest_touch_up(dev, 1); litest_touch_up(dev, 0); libinput_dispatch(li); @@ -1951,8 +1949,7 @@ START_TEST(touchpad_2fg_scroll_return_to_motion) /* 2fg scroll */ litest_touch_down(dev, 1, 53, 50); - litest_touch_move_to(dev, 0, 47, 50, 47, 70, 5, 0); - litest_touch_move_to(dev, 1, 53, 50, 53, 70, 5, 0); + litest_touch_move_two_touches(dev, 47, 50, 53, 50, 0, 20, 5, 0); litest_touch_up(dev, 1); libinput_dispatch(li); litest_timeout_finger_switch(); @@ -1963,9 +1960,8 @@ START_TEST(touchpad_2fg_scroll_return_to_motion) litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); /* back to 2fg scroll, lifting the other finger */ - litest_touch_down(dev, 1, 50, 50); - litest_touch_move_to(dev, 0, 47, 50, 47, 70, 5, 0); - litest_touch_move_to(dev, 1, 53, 50, 53, 70, 5, 0); + litest_touch_down(dev, 1, 53, 50); + litest_touch_move_two_touches(dev, 47, 50, 53, 50, 0, 20, 5, 0); litest_touch_up(dev, 0); libinput_dispatch(li); litest_timeout_finger_switch(); @@ -3273,8 +3269,7 @@ START_TEST(touchpad_trackpoint_buttons_2fg_scroll) litest_touch_down(touchpad, 0, 40, 70); litest_touch_down(touchpad, 1, 60, 70); - litest_touch_move_to(touchpad, 0, 40, 70, 40, 30, 10, 0); - litest_touch_move_to(touchpad, 1, 60, 70, 60, 30, 10, 0); + litest_touch_move_two_touches(touchpad, 40, 70, 60, 70, 0, -40, 10, 0); libinput_dispatch(li); litest_wait_for_event(li); -- 2.3.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel