diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-02-06 11:00:43 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-02-06 11:00:43 +1000 |
commit | f954b8f8530a9288b6ccb5151f6f44480a71158a (patch) | |
tree | 6af911bbfc3be2665d6b7e777702754df3cdc52d /test | |
parent | e5f8ac757952296ce467cf4dc47cd5522afb9dc8 (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/test-pad.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/test-pad.c b/test/test-pad.c index 7048570..5bce7e0 100644 --- a/test/test-pad.c +++ b/test/test-pad.c @@ -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); |