diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-11-07 11:02:22 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-11-07 11:03:12 +1000 |
commit | c6052769842c2e4ab11ef9db536d7ffd3cb87481 (patch) | |
tree | 30d2ba812dfcb7cc43d36bb417182588d9376ee6 /test | |
parent | 6d781f8817b409b49eae95b1c982a0c5b75f6630 (diff) | |
parent | a78a25e62eaec24d625a48d9d0dcd524f874ad7f (diff) | |
download | libinput-c6052769842c2e4ab11ef9db536d7ffd3cb87481.tar.gz |
Merge branch 'for-peter' of git://people.freedesktop.org/~jwrdegoede/libinput
Diffstat (limited to 'test')
-rw-r--r-- | test/device.c | 2 | ||||
-rw-r--r-- | test/litest.c | 10 | ||||
-rw-r--r-- | test/litest.h | 2 | ||||
-rw-r--r-- | test/touch.c | 6 | ||||
-rw-r--r-- | test/touchpad.c | 145 |
5 files changed, 130 insertions, 35 deletions
diff --git a/test/device.c b/test/device.c index 0a60dd90..7bc7ac8c 100644 --- a/test/device.c +++ b/test/device.c @@ -165,7 +165,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 b7866714..dc6a6306 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 fe1001ad..5b0478b1 100644 --- a/test/litest.h +++ b/test/litest.h @@ -138,7 +138,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/touch.c b/test/touch.c index 168e2aa6..5c9b72a8 100644 --- a/test/touch.c +++ b/test/touch.c @@ -451,13 +451,13 @@ START_TEST(fake_mt_no_touch_events) litest_drain_events(li); litest_touch_down(dev, 0, 50, 50); - litest_touch_move_to(dev, 0, 50, 50, 70, 70, 5); + litest_touch_move_to(dev, 0, 50, 50, 70, 70, 5, 10); litest_touch_up(dev, 0); litest_touch_down(dev, 0, 50, 50); litest_touch_down(dev, 1, 70, 70); - litest_touch_move_to(dev, 0, 50, 50, 90, 40, 10); - litest_touch_move_to(dev, 0, 70, 70, 40, 50, 10); + litest_touch_move_to(dev, 0, 50, 50, 90, 40, 10, 10); + litest_touch_move_to(dev, 0, 70, 70, 40, 50, 10, 10); litest_touch_up(dev, 0); litest_touch_up(dev, 1); diff --git a/test/touchpad.c b/test/touchpad.c index 8cd838e7..f9031dd9 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, 40); 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, 40); litest_touch_up(dev, 0); libinput_dispatch(li); @@ -200,6 +200,93 @@ START_TEST(touchpad_1fg_tap_n_drag_timeout) } END_TEST +START_TEST(touchpad_2fg_tap_n_drag) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + struct libinput_event *event; + + libinput_device_config_tap_set_enabled(dev->libinput_device, + LIBINPUT_CONFIG_TAP_ENABLED); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_touch_up(dev, 0); + litest_touch_down(dev, 0, 50, 50); + litest_touch_down(dev, 1, 60, 50); + litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 40); + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_PRESSED); + + while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) { + event = libinput_get_event(li); + libinput_event_destroy(event); + libinput_dispatch(li); + } + litest_assert_empty_queue(li); + + litest_touch_up(dev, 0); + litest_touch_up(dev, 1); + + /* This will wait for the DRAGGING_WAIT timeout */ + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_RELEASED); + + litest_assert_empty_queue(li); +} +END_TEST + +START_TEST(touchpad_2fg_tap_n_drag_3fg_btntool) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + struct libinput_event *event; + + libinput_device_config_tap_set_enabled(dev->libinput_device, + LIBINPUT_CONFIG_TAP_ENABLED); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_touch_up(dev, 0); + litest_touch_down(dev, 0, 50, 50); + litest_touch_down(dev, 1, 60, 50); + litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 40); + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_PRESSED); + + while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) { + event = libinput_get_event(li); + libinput_event_destroy(event); + libinput_dispatch(li); + } + litest_assert_empty_queue(li); + + /* Putting down a third finger should end the drag */ + litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1); + litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_RELEASED); + + /* Releasing the fingers should not cause any events */ + litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0); + litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_touch_up(dev, 1); + litest_touch_up(dev, 0); + + litest_assert_empty_queue(li); +} +END_TEST + START_TEST(touchpad_2fg_tap) { struct litest_device *dev = litest_current_device(); @@ -400,7 +487,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 +537,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 +603,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 +890,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 +1084,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 +1157,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 +1184,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 +1235,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 +1269,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 +1393,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 +1417,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 +1569,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 +1593,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 +1617,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 +1639,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 +1658,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 +1691,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); @@ -1934,6 +2021,8 @@ int main(int argc, char **argv) { litest_add("touchpad:tap", touchpad_1fg_tap, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_timeout, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_2fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); + litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD); litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_CLICKPAD); |