mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 21:40:40 +01:00
test: add test for pad event mode groups
Not much we can do here, our virtual devices don't have the sysfs files required, so they have 0 modes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
e5f8ac7579
commit
f954b8f853
1 changed files with 63 additions and 0 deletions
|
|
@ -189,6 +189,68 @@ START_TEST(pad_button)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(pad_button_mode_groups)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
unsigned int code;
|
||||
unsigned int expected_number = 0;
|
||||
struct libinput_event *ev;
|
||||
struct libinput_event_tablet_pad *pev;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
for (code = BTN_0; code < KEY_MAX; code++) {
|
||||
unsigned int mode, index;
|
||||
struct libinput_tablet_pad_mode_group *group;
|
||||
|
||||
if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
|
||||
continue;
|
||||
|
||||
litest_button_click(dev, code, 1);
|
||||
litest_button_click(dev, code, 0);
|
||||
libinput_dispatch(li);
|
||||
|
||||
switch (code) {
|
||||
case BTN_STYLUS:
|
||||
litest_assert_empty_queue(li);
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ev = libinput_get_event(li);
|
||||
pev = litest_is_pad_button_event(ev,
|
||||
expected_number,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
|
||||
/* litest virtual devices don't have modes */
|
||||
mode = libinput_event_tablet_pad_get_mode(pev);
|
||||
ck_assert_int_eq(mode, 0);
|
||||
group = libinput_event_tablet_pad_get_mode_group(pev);
|
||||
index = libinput_tablet_pad_mode_group_get_index(group);
|
||||
ck_assert_int_eq(index, 0);
|
||||
|
||||
libinput_event_destroy(ev);
|
||||
|
||||
ev = libinput_get_event(li);
|
||||
pev = litest_is_pad_button_event(ev,
|
||||
expected_number,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
mode = libinput_event_tablet_pad_get_mode(pev);
|
||||
ck_assert_int_eq(mode, 0);
|
||||
group = libinput_event_tablet_pad_get_mode_group(pev);
|
||||
index = libinput_tablet_pad_mode_group_get_index(group);
|
||||
ck_assert_int_eq(index, 0);
|
||||
libinput_event_destroy(ev);
|
||||
|
||||
expected_number++;
|
||||
}
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(pad_has_ring)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
|
|
@ -707,6 +769,7 @@ litest_setup_tests_pad(void)
|
|||
|
||||
litest_add("pad:button", pad_num_buttons, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
litest_add("pad:button", pad_button, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
litest_add("pad:button", pad_button_mode_groups, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
|
||||
litest_add("pad:ring", pad_has_ring, LITEST_RING, LITEST_ANY);
|
||||
litest_add("pad:ring", pad_ring, LITEST_RING, LITEST_ANY);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue