mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-05 02:00:15 +01:00
test: Add litest_button_scroll helper function
Turn test_trackpoint_scroll into a generic helper function for testing "button scrolling". Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
cb66ca1692
commit
365141ec60
3 changed files with 45 additions and 33 deletions
|
|
@ -797,6 +797,34 @@ litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
|
|||
litest_event(d, ev->type, ev->code, ev->value);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -1156,6 +1184,12 @@ litest_timeout_softbuttons(void)
|
|||
msleep(300);
|
||||
}
|
||||
|
||||
void
|
||||
litest_timeout_buttonscroll(void)
|
||||
{
|
||||
msleep(300);
|
||||
}
|
||||
|
||||
void
|
||||
litest_push_event_frame(struct litest_device *dev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue