From 50dfd52cd7ea31993d71283f8bdf35d5720233d7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 13 Jan 2017 11:24:14 +1000 Subject: [PATCH] test: add a test for keyboard LED updates Not much we can check for here anyway, but at least we can trigger the code. Signed-off-by: Peter Hutterer --- test/litest-device-keyboard.c | 3 +++ test/litest.h | 1 + test/test-keyboard.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/test/litest-device-keyboard.c b/test/litest-device-keyboard.c index 07819f73..10d8f3ff 100644 --- a/test/litest-device-keyboard.c +++ b/test/litest-device-keyboard.c @@ -191,6 +191,9 @@ static int events[] = { EV_KEY, KEY_SEARCH, EV_KEY, KEY_MEDIA, EV_KEY, KEY_FN, + EV_LED, LED_NUML, + EV_LED, LED_CAPSL, + EV_LED, LED_SCROLLL, -1, -1, }; diff --git a/test/litest.h b/test/litest.h index 43103650..38e3a833 100644 --- a/test/litest.h +++ b/test/litest.h @@ -257,6 +257,7 @@ enum litest_device_feature { LITEST_RING = 1 << 22, LITEST_STRIP = 1 << 23, LITEST_TRACKBALL = 1 << 24, + LITEST_LEDS = 1 << 25, }; struct litest_device { diff --git a/test/test-keyboard.c b/test/test-keyboard.c index 4f52c858..4a679683 100644 --- a/test/test-keyboard.c +++ b/test/test-keyboard.c @@ -366,6 +366,35 @@ START_TEST(keyboard_no_buttons) } END_TEST +START_TEST(keyboard_leds) +{ + struct litest_device *dev = litest_current_device(); + struct libinput_device *device = dev->libinput_device; + + /* we can't actually test the results here without physically + * looking at the LEDs. So all we do is trigger the code for devices + * with and without LEDs and check that it doesn't go boom + */ + + libinput_device_led_update(device, + LIBINPUT_LED_NUM_LOCK); + libinput_device_led_update(device, + LIBINPUT_LED_CAPS_LOCK); + libinput_device_led_update(device, + LIBINPUT_LED_SCROLL_LOCK); + + libinput_device_led_update(device, + LIBINPUT_LED_NUM_LOCK| + LIBINPUT_LED_CAPS_LOCK); + libinput_device_led_update(device, + LIBINPUT_LED_NUM_LOCK| + LIBINPUT_LED_CAPS_LOCK | + LIBINPUT_LED_SCROLL_LOCK); + libinput_device_led_update(device, 0); + libinput_device_led_update(device, -1); +} +END_TEST + void litest_setup_tests_keyboard(void) { @@ -377,4 +406,6 @@ litest_setup_tests_keyboard(void) litest_add("keyboard:time", keyboard_time_usec, LITEST_KEYS, LITEST_ANY); litest_add("keyboard:events", keyboard_no_buttons, LITEST_KEYS, LITEST_ANY); + + litest_add("keyboard:leds", keyboard_leds, LITEST_ANY, LITEST_ANY); }