mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 00:00:14 +01:00
litest: Add a litest_touch_move_two_touches helper function
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 out than an actual 2fg scroll gesture. Add a helper function which can move 2 fingers at the same time (more or less), and use this where relevant. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
2ab0db9ee9
commit
a8eb6c84a2
3 changed files with 33 additions and 11 deletions
|
|
@ -903,6 +903,28 @@ litest_touch_move_to(struct litest_device *d,
|
|||
litest_touch_move(d, slot, x_to, y_to);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue