[PATCH libinput 3/3] Add tests for pen rotation

Jason Gerecke killertofu at gmail.com
Mon Dec 8 09:59:07 PST 2014


Signed-off-by: Jason Gerecke <killertofu at gmail.com>
Acked-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/litest-wacom-intuos-tablet.c |  3 +++
 test/tablet.c                     | 41 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/test/litest-wacom-intuos-tablet.c b/test/litest-wacom-intuos-tablet.c
index 2d95ad1..aa38090 100644
--- a/test/litest-wacom-intuos-tablet.c
+++ b/test/litest-wacom-intuos-tablet.c
@@ -36,6 +36,7 @@ static void litest_wacom_intuos_tablet_setup(void)
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+	{ .type = EV_ABS, .code = ABS_Z, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
@@ -49,6 +50,7 @@ static struct input_event proximity_in[] = {
 static struct input_event proximity_out[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = 0 },
 	{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
+	{ .type = EV_ABS, .code = ABS_Z, .value = 0 },
 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
 	{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
@@ -62,6 +64,7 @@ static struct input_event proximity_out[] = {
 static struct input_event motion[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+	{ .type = EV_ABS, .code = ABS_Z, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
diff --git a/test/tablet.c b/test/tablet.c
index 367c4db..c52ae43 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -354,16 +354,19 @@ START_TEST(normalization)
 	struct libinput_event *event;
 	double pressure,
 	       tilt_vertical,
-	       tilt_horizontal;
+	       tilt_horizontal,
+	       twist;
 	const struct input_absinfo *pressure_absinfo,
                                    *tilt_vertical_absinfo,
-                                   *tilt_horizontal_absinfo;
+                                   *tilt_horizontal_absinfo,
+                                   *twist_absinfo;
 
 	litest_drain_events(dev->libinput);
 
 	pressure_absinfo = libevdev_get_abs_info(dev->evdev, ABS_PRESSURE);
 	tilt_vertical_absinfo = libevdev_get_abs_info(dev->evdev, ABS_TILT_X);
 	tilt_horizontal_absinfo = libevdev_get_abs_info(dev->evdev, ABS_TILT_Y);
+	twist_absinfo = libevdev_get_abs_info(dev->evdev, ABS_Z);
 
 	/* Test minimum */
 	if (pressure_absinfo != NULL)
@@ -384,6 +387,12 @@ START_TEST(normalization)
 			     ABS_TILT_Y,
 			     tilt_horizontal_absinfo->minimum);
 
+	if (twist_absinfo != NULL)
+		litest_event(dev,
+			     EV_ABS,
+			     ABS_Z,
+			     twist_absinfo->minimum);
+
 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
 
 	libinput_dispatch(li);
@@ -422,6 +431,17 @@ START_TEST(normalization)
 
 				litest_assert_double_eq(tilt_horizontal, -1);
 			}
+
+			if (libinput_event_tablet_axis_has_changed(
+				tablet_event,
+				LIBINPUT_TABLET_AXIS_TWIST)) {
+				twist =
+					libinput_event_tablet_get_axis_value(
+					    tablet_event,
+					    LIBINPUT_TABLET_AXIS_TWIST);
+
+				litest_assert_double_eq(twist, -1);
+			}
 		}
 
 		libinput_event_destroy(event);
@@ -446,6 +466,12 @@ START_TEST(normalization)
 			     ABS_TILT_Y,
 			     tilt_horizontal_absinfo->maximum);
 
+	if (twist_absinfo != NULL)
+		litest_event(dev,
+			     EV_ABS,
+			     ABS_Z,
+			     twist_absinfo->maximum);
+
 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
 
 	libinput_dispatch(li);
@@ -484,6 +510,17 @@ START_TEST(normalization)
 
 				litest_assert_double_eq(tilt_horizontal, 1);
 			}
+
+			if (libinput_event_tablet_axis_has_changed(
+				tablet_event,
+				LIBINPUT_TABLET_AXIS_TWIST)) {
+				twist =
+					libinput_event_tablet_get_axis_value(
+					    tablet_event,
+					    LIBINPUT_TABLET_AXIS_TWIST);
+
+				litest_assert_double_eq(twist, 1);
+			}
 		}
 
 		libinput_event_destroy(event);
-- 
2.1.3



More information about the wayland-devel mailing list