[PATCH 11/11] test: Add button scroll test to pointer tests

Hans de Goede hdegoede at redhat.com
Thu Nov 6 07:37:40 PST 2014


Non trackpoint button scrolling is mainly intended for use with trackballs,
but we can test it just as well with any relative pointer device.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 test/pointer.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/test/pointer.c b/test/pointer.c
index 56b6709..100c2f3 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -518,12 +518,52 @@ START_TEST(pointer_left_handed_during_click_multiple_buttons)
 }
 END_TEST
 
+START_TEST(pointer_scroll_button)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+
+	/* Make left button switch to scrolling mode */
+	libinput_device_config_scroll_set_mode(dev->libinput_device,
+					LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
+	libinput_device_config_scroll_set_button(dev->libinput_device,
+					BTN_LEFT);
+
+	litest_drain_events(li);
+
+	litest_button_scroll(dev, BTN_LEFT, 1, 6);
+	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 6);
+	litest_button_scroll(dev, BTN_LEFT, 1, -7);
+	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -7);
+	litest_button_scroll(dev, BTN_LEFT, 8, 1);
+	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 8);
+	litest_button_scroll(dev, BTN_LEFT, -9, 1);
+	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
+
+	/* scroll smaller than the threshold should not generate events */
+	litest_button_scroll(dev, BTN_LEFT, 1, 1);
+	/* left press without movement should not generate events */
+	litest_button_scroll(dev, BTN_LEFT, 0, 0);
+
+	litest_assert_empty_queue(li);
+
+	/* Restore default scroll behavior */
+	libinput_device_config_scroll_set_mode(dev->libinput_device,
+		libinput_device_config_scroll_get_default_mode(
+			dev->libinput_device));
+	libinput_device_config_scroll_set_button(dev->libinput_device,
+		libinput_device_config_scroll_get_default_button(
+			dev->libinput_device));
+}
+END_TEST
+
 int main (int argc, char **argv) {
 
 	litest_add("pointer:motion", pointer_motion_relative, LITEST_POINTER, LITEST_ANY);
 	litest_add("pointer:button", pointer_button, LITEST_BUTTON, LITEST_CLICKPAD);
 	litest_add_no_device("pointer:button_auto_release", pointer_button_auto_release);
 	litest_add("pointer:scroll", pointer_scroll_wheel, LITEST_WHEEL, LITEST_ANY);
+	litest_add("pointer:scroll", pointer_scroll_button, LITEST_POINTER|LITEST_BUTTON, LITEST_ANY);
 	litest_add_no_device("pointer:seat button count", pointer_seat_button_count);
 
 	litest_add("pointer:calibration", pointer_no_calibration, LITEST_ANY, LITEST_TOUCH|LITEST_SINGLE_TOUCH);
-- 
2.1.0



More information about the wayland-devel mailing list