summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/litest.c34
-rw-r--r--test/litest.h4
-rw-r--r--test/trackpoint.c40
3 files changed, 45 insertions, 33 deletions
diff --git a/test/litest.c b/test/litest.c
index 69c386f5..e2ec90d6 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -798,6 +798,34 @@ litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
}
void
+litest_button_scroll(struct litest_device *dev,
+ unsigned int button,
+ double dx, double dy)
+{
+ struct libinput *li = dev->libinput;
+
+ litest_button_click(dev, button, 1);
+
+ libinput_dispatch(li);
+ litest_timeout_buttonscroll();
+ libinput_dispatch(li);
+
+ /* Send two deltas, as the first one may be eaten up by an
+ * acceleration filter. */
+ litest_event(dev, EV_REL, REL_X, dx);
+ litest_event(dev, EV_REL, REL_Y, dy);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+ litest_event(dev, EV_REL, REL_X, dx);
+ litest_event(dev, EV_REL, REL_Y, dy);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+ litest_button_click(dev, button, 0);
+
+ libinput_dispatch(li);
+}
+
+void
litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
{
litest_button_click(d, key, is_press);
@@ -1157,6 +1185,12 @@ litest_timeout_softbuttons(void)
}
void
+litest_timeout_buttonscroll(void)
+{
+ msleep(300);
+}
+
+void
litest_push_event_frame(struct litest_device *dev)
{
assert(!dev->skip_ev_syn);
diff --git a/test/litest.h b/test/litest.h
index 8132d517..99c6ae3b 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -146,6 +146,9 @@ void litest_touch_move_to(struct litest_device *d,
void litest_button_click(struct litest_device *d,
unsigned int button,
bool is_press);
+void litest_button_scroll(struct litest_device *d,
+ unsigned int button,
+ double dx, double dy);
void litest_keyboard_key(struct litest_device *d,
unsigned int key,
bool is_press);
@@ -170,6 +173,7 @@ struct libevdev_uinput * litest_create_uinput_abs_device(const char *name,
void litest_timeout_tap(void);
void litest_timeout_softbuttons(void);
+void litest_timeout_buttonscroll(void);
void litest_push_event_frame(struct litest_device *dev);
void litest_pop_event_frame(struct litest_device *dev);
diff --git a/test/trackpoint.c b/test/trackpoint.c
index 2e2caba0..3d965d44 100644
--- a/test/trackpoint.c
+++ b/test/trackpoint.c
@@ -49,32 +49,6 @@ START_TEST(trackpoint_middlebutton)
}
END_TEST
-static void
-test_trackpoint_scroll(struct litest_device *dev, double dx, double dy)
-{
- struct libinput *li = dev->libinput;
-
- litest_button_click(dev, BTN_MIDDLE, 1);
-
- libinput_dispatch(li);
- msleep(300);
- libinput_dispatch(li);
-
- /* Send two deltas, as the first one may be eaten up by an
- * acceleration filter. */
- litest_event(dev, EV_REL, REL_X, dx);
- litest_event(dev, EV_REL, REL_Y, dy);
- litest_event(dev, EV_SYN, SYN_REPORT, 0);
-
- litest_event(dev, EV_REL, REL_X, dx);
- litest_event(dev, EV_REL, REL_Y, dy);
- litest_event(dev, EV_SYN, SYN_REPORT, 0);
-
- litest_button_click(dev, BTN_MIDDLE, 0);
-
- libinput_dispatch(li);
-}
-
START_TEST(trackpoint_scroll)
{
struct litest_device *dev = litest_current_device();
@@ -82,19 +56,19 @@ START_TEST(trackpoint_scroll)
litest_drain_events(li);
- test_trackpoint_scroll(dev, 1, 6);
+ litest_button_scroll(dev, BTN_MIDDLE, 1, 6);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 6);
- test_trackpoint_scroll(dev, 1, -7);
+ litest_button_scroll(dev, BTN_MIDDLE, 1, -7);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -7);
- test_trackpoint_scroll(dev, 8, 1);
+ litest_button_scroll(dev, BTN_MIDDLE, 8, 1);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 8);
- test_trackpoint_scroll(dev, -9, 1);
+ litest_button_scroll(dev, BTN_MIDDLE, -9, 1);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
/* scroll smaller than the threshold should not generate events */
- test_trackpoint_scroll(dev, 1, 1);
+ litest_button_scroll(dev, BTN_MIDDLE, 1, 1);
/* long middle press without movement should not generate events */
- test_trackpoint_scroll(dev, 0, 0);
+ litest_button_scroll(dev, BTN_MIDDLE, 0, 0);
litest_assert_empty_queue(li);
}
@@ -113,7 +87,7 @@ START_TEST(trackpoint_middlebutton_noscroll)
litest_drain_events(li);
/* A long middle button click + motion should get reported normally now */
- test_trackpoint_scroll(dev, 0, 10);
+ litest_button_scroll(dev, BTN_MIDDLE, 0, 10);
litest_assert_button_event(li, BTN_MIDDLE, 1);