[PATCH libinput 1/7] litest: Add a sleep_ms parameter to litest_touch_move_to
Hans de Goede
hdegoede at redhat.com
Sun Sep 28 04:22:17 PDT 2014
In reality moving a touch from point to another takes time. In some cases
(when a timeout may trigger during the move, e.g. tap-n-drag on a touchpad),
this is important. Add a sleep_ms parameter, which will cause
litest_touch_move_to to sleep the specified amount of ms every step.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
test/device.c | 2 +-
test/litest.c | 10 ++++++++--
test/litest.h | 2 +-
test/touchpad.c | 56 ++++++++++++++++++++++++++++----------------------------
4 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/test/device.c b/test/device.c
index 3061ebc..32eba00 100644
--- a/test/device.c
+++ b/test/device.c
@@ -131,7 +131,7 @@ START_TEST(device_disable_touchpad)
litest_assert_empty_queue(li);
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
+ litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10, 0);
litest_touch_up(dev, 0);
diff --git a/test/litest.c b/test/litest.c
index e028176..dc79258 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -762,12 +762,18 @@ litest_touch_move_to(struct litest_device *d,
unsigned int slot,
double x_from, double y_from,
double x_to, double y_to,
- int steps)
+ int steps, int sleep_ms)
{
- for (int i = 0; i < steps - 1; i++)
+ for (int i = 0; i < steps - 1; i++) {
litest_touch_move(d, slot,
x_from + (x_to - x_from)/steps * i,
y_from + (y_to - y_from)/steps * i);
+ if (sleep_ms) {
+ libinput_dispatch(d->libinput);
+ msleep(sleep_ms);
+ libinput_dispatch(d->libinput);
+ }
+ }
litest_touch_move(d, slot, x_to, y_to);
}
diff --git a/test/litest.h b/test/litest.h
index 26b3040..c26b9dd 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -136,7 +136,7 @@ void litest_touch_move_to(struct litest_device *d,
unsigned int slot,
double x_from, double y_from,
double x_to, double y_to,
- int steps);
+ 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 8cd838e..576f9ff 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -41,7 +41,7 @@ START_TEST(touchpad_1fg_motion)
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5);
+ litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5, 0);
litest_touch_up(dev, 0);
libinput_dispatch(li);
@@ -72,8 +72,8 @@ START_TEST(touchpad_2fg_no_motion)
litest_touch_down(dev, 0, 20, 20);
litest_touch_down(dev, 1, 70, 20);
- litest_touch_move_to(dev, 0, 20, 20, 80, 80, 5);
- litest_touch_move_to(dev, 1, 70, 20, 80, 50, 5);
+ litest_touch_move_to(dev, 0, 20, 20, 80, 80, 5, 0);
+ litest_touch_move_to(dev, 1, 70, 20, 80, 50, 5, 0);
litest_touch_up(dev, 1);
litest_touch_up(dev, 0);
@@ -131,7 +131,7 @@ START_TEST(touchpad_1fg_tap_n_drag)
litest_touch_down(dev, 0, 50, 50);
litest_touch_up(dev, 0);
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
+ litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 0);
litest_touch_up(dev, 0);
libinput_dispatch(li);
@@ -150,7 +150,7 @@ START_TEST(touchpad_1fg_tap_n_drag)
/* lift finger, set down again, should continue dragging */
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
+ litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 0);
litest_touch_up(dev, 0);
libinput_dispatch(li);
@@ -400,7 +400,7 @@ START_TEST(touchpad_no_2fg_tap_after_move)
-> no event
*/
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
+ litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10, 0);
litest_drain_events(dev->libinput);
litest_touch_down(dev, 1, 70, 50);
@@ -450,7 +450,7 @@ START_TEST(touchpad_no_first_fg_tap_after_move)
litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 70, 50);
libinput_dispatch(dev->libinput);
- litest_touch_move_to(dev, 1, 70, 50, 90, 90, 10);
+ litest_touch_move_to(dev, 1, 70, 50, 90, 90, 10, 0);
libinput_dispatch(dev->libinput);
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
@@ -516,7 +516,7 @@ START_TEST(touchpad_1fg_tap_n_drag_click)
litest_touch_down(dev, 0, 50, 50);
litest_touch_up(dev, 0);
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 80, 50, 10);
+ litest_touch_move_to(dev, 0, 50, 50, 80, 50, 10, 0);
litest_assert_button_event(li, BTN_LEFT,
LIBINPUT_BUTTON_STATE_PRESSED);
@@ -803,7 +803,7 @@ START_TEST(clickpad_click_n_drag)
/* now put a second finger down */
litest_touch_down(dev, 1, 70, 70);
- litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
+ litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5, 0);
litest_touch_up(dev, 1);
libinput_dispatch(li);
@@ -997,14 +997,14 @@ START_TEST(clickpad_softbutton_left_1st_fg_move)
litest_assert_empty_queue(li);
/* move out of the area, then wait for softbutton timer */
- litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10);
+ litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10, 0);
libinput_dispatch(li);
litest_timeout_softbuttons();
libinput_dispatch(li);
litest_drain_events(li);
/* move down left, expect motion */
- litest_touch_move_to(dev, 0, 90, 20, 20, 90, 10);
+ litest_touch_move_to(dev, 0, 90, 20, 20, 90, 10, 0);
libinput_dispatch(li);
event = libinput_get_event(li);
@@ -1070,7 +1070,7 @@ START_TEST(clickpad_softbutton_left_2nd_fg_move)
litest_assert_empty_queue(li);
litest_touch_down(dev, 1, 20, 20);
- litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10);
+ litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10, 0);
libinput_dispatch(li);
event = libinput_get_event(li);
@@ -1097,7 +1097,7 @@ START_TEST(clickpad_softbutton_left_2nd_fg_move)
/* second finger down */
litest_touch_down(dev, 1, 20, 20);
- litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10);
+ litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10, 0);
libinput_dispatch(li);
event = libinput_get_event(li);
@@ -1148,7 +1148,7 @@ START_TEST(clickpad_softbutton_left_to_right)
*/
litest_touch_down(dev, 0, 20, 90);
- litest_touch_move_to(dev, 0, 20, 90, 90, 90, 10);
+ litest_touch_move_to(dev, 0, 20, 90, 90, 90, 10, 0);
litest_event(dev, EV_KEY, BTN_LEFT, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
@@ -1182,7 +1182,7 @@ START_TEST(clickpad_softbutton_right_to_left)
*/
litest_touch_down(dev, 0, 90, 90);
- litest_touch_move_to(dev, 0, 90, 90, 20, 90, 10);
+ litest_touch_move_to(dev, 0, 90, 90, 20, 90, 10, 0);
litest_event(dev, EV_KEY, BTN_LEFT, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
@@ -1306,7 +1306,7 @@ START_TEST(clickpad_topsoftbuttons_move_out_ignore)
libinput_dispatch(li);
litest_assert_empty_queue(li);
- litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20);
+ litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20, 0);
libinput_dispatch(li);
litest_timeout_softbuttons();
libinput_dispatch(li);
@@ -1330,8 +1330,8 @@ 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);
- litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5);
+ 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);
/* Avoid a small scroll being seen as a tap */
if (want_sleep) {
@@ -1482,13 +1482,13 @@ START_TEST(touchpad_palm_detect_at_edge)
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 50);
- litest_touch_move_to(dev, 0, 99, 50, 99, 70, 5);
+ litest_touch_move_to(dev, 0, 99, 50, 99, 70, 5, 0);
litest_touch_up(dev, 0);
litest_assert_empty_queue(li);
litest_touch_down(dev, 0, 5, 50);
- litest_touch_move_to(dev, 0, 5, 50, 5, 70, 5);
+ litest_touch_move_to(dev, 0, 5, 50, 5, 70, 5, 0);
litest_touch_up(dev, 0);
}
END_TEST
@@ -1506,13 +1506,13 @@ START_TEST(touchpad_palm_detect_at_bottom_corners)
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 95);
- litest_touch_move_to(dev, 0, 99, 95, 99, 99, 10);
+ litest_touch_move_to(dev, 0, 99, 95, 99, 99, 10, 0);
litest_touch_up(dev, 0);
litest_assert_empty_queue(li);
litest_touch_down(dev, 0, 5, 95);
- litest_touch_move_to(dev, 0, 5, 95, 5, 99, 5);
+ litest_touch_move_to(dev, 0, 5, 95, 5, 99, 5, 0);
litest_touch_up(dev, 0);
}
END_TEST
@@ -1530,13 +1530,13 @@ START_TEST(touchpad_palm_detect_at_top_corners)
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 5);
- litest_touch_move_to(dev, 0, 99, 5, 99, 9, 10);
+ litest_touch_move_to(dev, 0, 99, 5, 99, 9, 10, 0);
litest_touch_up(dev, 0);
litest_assert_empty_queue(li);
litest_touch_down(dev, 0, 5, 5);
- litest_touch_move_to(dev, 0, 5, 5, 5, 9, 5);
+ litest_touch_move_to(dev, 0, 5, 5, 5, 9, 5, 0);
litest_touch_up(dev, 0);
}
END_TEST
@@ -1552,7 +1552,7 @@ START_TEST(touchpad_palm_detect_palm_stays_palm)
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 20);
- litest_touch_move_to(dev, 0, 99, 20, 75, 99, 5);
+ litest_touch_move_to(dev, 0, 99, 20, 75, 99, 5, 0);
litest_touch_up(dev, 0);
litest_assert_empty_queue(li);
}
@@ -1571,7 +1571,7 @@ START_TEST(touchpad_palm_detect_palm_becomes_pointer)
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 50);
- litest_touch_move_to(dev, 0, 99, 50, 0, 70, 5);
+ litest_touch_move_to(dev, 0, 99, 50, 0, 70, 5, 0);
litest_touch_up(dev, 0);
libinput_dispatch(li);
@@ -1604,11 +1604,11 @@ START_TEST(touchpad_palm_detect_no_palm_moving_into_edges)
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
- litest_touch_move_to(dev, 0, 50, 50, 99, 50, 5);
+ litest_touch_move_to(dev, 0, 50, 50, 99, 50, 5, 0);
litest_drain_events(li);
- litest_touch_move_to(dev, 0, 99, 50, 99, 90, 5);
+ litest_touch_move_to(dev, 0, 99, 50, 99, 90, 5, 0);
libinput_dispatch(li);
type = libinput_next_event_type(li);
--
2.1.0
More information about the wayland-devel
mailing list