[PATCH libinput] test: add test for the vertical position-dependent pinch

Peter Hutterer peter.hutterer at who-t.net
Wed Dec 21 00:13:05 UTC 2016


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/gestures.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/litest.c   |  6 ++++++
 test/litest.h   |  3 +++
 3 files changed, 64 insertions(+)

diff --git a/test/gestures.c b/test/gestures.c
index 0b132c3..3a66afb 100644
--- a/test/gestures.c
+++ b/test/gestures.c
@@ -496,6 +496,58 @@ START_TEST(gestures_swipe_4fg_btntool)
 }
 END_TEST
 
+START_TEST(gestures_pinch_vertical_positon)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+	struct libinput_event *event;
+	int nfingers = _i; /* ranged test */
+
+	if (libevdev_get_num_slots(dev->evdev) < nfingers ||
+	    !libinput_device_has_capability(dev->libinput_device,
+					    LIBINPUT_DEVICE_CAP_GESTURE))
+		return;
+
+	litest_disable_tap(dev->libinput_device);
+	litest_drain_events(li);
+
+	litest_touch_down(dev, 0, 40, 30);
+	litest_touch_down(dev, 1, 50, 70);
+	litest_touch_down(dev, 2, 60, 70);
+	if (nfingers > 3)
+		litest_touch_down(dev, 3, 70, 70);
+	libinput_dispatch(li);
+	litest_timeout_gesture_scroll();
+	libinput_dispatch(li);
+
+	/* This is actually a small swipe gesture, all three fingers moving
+	 * down but we're checking for the code that triggers based on
+	 * finger position. */
+	litest_touch_move_to(dev, 0, 40, 30, 40, 30.5, 1, 0);
+	litest_touch_move_to(dev, 1, 50, 70, 50, 70.5, 1, 0);
+	litest_touch_move_to(dev, 2, 60, 70, 60, 70.5, 1, 0);
+	if (nfingers > 3)
+		litest_touch_move_to(dev, 3, 70, 70, 70, 70.5, 1, 0);
+	libinput_dispatch(li);
+
+	event = libinput_get_event(li);
+	litest_is_gesture_event(event,
+				LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
+				nfingers);
+	libinput_event_destroy(event);
+
+	litest_touch_move_to(dev, 0, 40, 30.5, 40, 36, 5, 0);
+	litest_touch_move_to(dev, 1, 50, 70.5, 50, 76, 5, 0);
+	litest_touch_move_to(dev, 2, 60, 70.5, 60, 76, 5, 0);
+	if (nfingers > 3)
+		litest_touch_move_to(dev, 3, 70, 70.5, 60, 76, 5, 0);
+	libinput_dispatch(li);
+
+	litest_assert_only_typed_events(li,
+					LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
+}
+END_TEST
+
 START_TEST(gestures_pinch)
 {
 	struct litest_device *dev = litest_current_device();
@@ -1219,6 +1271,7 @@ litest_setup_tests_gestures(void)
 {
 	/* N, NE, ... */
 	struct range cardinals = { 0, 8 };
+	struct range fingers = { 3, 5 };
 
 	litest_add("gestures:cap", gestures_cap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
 	litest_add("gestures:cap", gestures_nocap, LITEST_ANY, LITEST_TOUCHPAD);
@@ -1230,9 +1283,11 @@ litest_setup_tests_gestures(void)
 	litest_add_ranged("gestures:pinch", gestures_pinch, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
 	litest_add_ranged("gestures:pinch", gestures_pinch_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
 	litest_add_ranged("gestures:pinch", gestures_pinch_3fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
+	litest_add_ranged("gestures:pinch", gestures_pinch_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
 	litest_add_ranged("gestures:pinch", gestures_pinch_4fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
 	litest_add_ranged("gestures:pinch", gestures_pinch_4fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
 	litest_add_ranged("gestures:pinch", gestures_spread, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
+	litest_add_ranged("gestures:pinch", gestures_pinch_vertical_positon, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &fingers);
 
 	litest_add("gestures:swipe", gestures_3fg_buttonarea_scroll, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
 	litest_add("gestures:swipe", gestures_3fg_buttonarea_scroll_btntool, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
diff --git a/test/litest.c b/test/litest.c
index 40029d6..0574c0a 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -2964,6 +2964,12 @@ litest_timeout_gesture(void)
 }
 
 void
+litest_timeout_gesture_scroll(void)
+{
+	msleep(180);
+}
+
+void
 litest_timeout_trackpoint(void)
 {
 	msleep(320);
diff --git a/test/litest.h b/test/litest.h
index 017a3d2..a707509 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -654,6 +654,9 @@ void
 litest_timeout_gesture(void);
 
 void
+litest_timeout_gesture_scroll(void);
+
+void
 litest_timeout_trackpoint(void);
 
 void
-- 
2.9.3



More information about the wayland-devel mailing list