[PATCH libinput 3/5] test: adjust scroll wheel test for HWHEEL-only devices

Peter Hutterer peter.hutterer at who-t.net
Tue Apr 7 16:54:31 PDT 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/pointer.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/test/pointer.c b/test/pointer.c
index 745af63..a39cb2c 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -396,11 +396,17 @@ START_TEST(pointer_scroll_wheel)
 
 	litest_drain_events(dev->libinput);
 
-	test_wheel_event(dev, REL_WHEEL, -1);
-	test_wheel_event(dev, REL_WHEEL, 1);
+	/* make sure we hit at least one of the below two conditions */
+	ck_assert(libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL) ||
+		  libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL));
 
-	test_wheel_event(dev, REL_WHEEL, -5);
-	test_wheel_event(dev, REL_WHEEL, 6);
+	if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL)) {
+		test_wheel_event(dev, REL_WHEEL, -1);
+		test_wheel_event(dev, REL_WHEEL, 1);
+
+		test_wheel_event(dev, REL_WHEEL, -5);
+		test_wheel_event(dev, REL_WHEEL, 6);
+	}
 
 	if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL)) {
 		test_wheel_event(dev, REL_HWHEEL, -1);
@@ -446,11 +452,17 @@ START_TEST(pointer_scroll_natural_wheel)
 
 	libinput_device_config_scroll_set_natural_scroll_enabled(device, 1);
 
-	test_wheel_event(dev, REL_WHEEL, -1);
-	test_wheel_event(dev, REL_WHEEL, 1);
+	/* make sure we hit at least one of the below two conditions */
+	ck_assert(libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL) ||
+		  libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL));
 
-	test_wheel_event(dev, REL_WHEEL, -5);
-	test_wheel_event(dev, REL_WHEEL, 6);
+	if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL)) {
+		test_wheel_event(dev, REL_WHEEL, -1);
+		test_wheel_event(dev, REL_WHEEL, 1);
+
+		test_wheel_event(dev, REL_WHEEL, -5);
+		test_wheel_event(dev, REL_WHEEL, 6);
+	}
 
 	if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL)) {
 		test_wheel_event(dev, REL_HWHEEL, -1);
-- 
2.3.4



More information about the wayland-devel mailing list