[PATCH libinput] tests: Add negative test for libinput_device_keyboard_has_key()

Derek Foreman derekf at osg.samsung.com
Thu Apr 23 15:05:49 PDT 2015


Ensure we get a -1 return for non-keyboard devices.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 test/keyboard.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/test/keyboard.c b/test/keyboard.c
index a477cfb..e098dc0 100644
--- a/test/keyboard.c
+++ b/test/keyboard.c
@@ -309,6 +309,20 @@ START_TEST(keyboard_has_key)
 }
 END_TEST
 
+START_TEST(keyboard_keys_bad_device)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput_device *device = dev->libinput_device;
+
+	if (libinput_device_has_capability(device,
+					    LIBINPUT_DEVICE_CAP_KEYBOARD))
+		return;
+
+	ck_assert_int_eq(libinput_device_keyboard_has_key(device, KEY_A),
+			 -1);
+}
+END_TEST
+
 int
 main(int argc, char **argv)
 {
@@ -316,6 +330,7 @@ main(int argc, char **argv)
 	litest_add_no_device("keyboard:key counting", keyboard_ignore_no_pressed_release);
 	litest_add_no_device("keyboard:key counting", keyboard_key_auto_release);
 	litest_add("keyboard:keys", keyboard_has_key, LITEST_KEYS, LITEST_ANY);
+	litest_add("keyboard:keys bad device", keyboard_keys_bad_device, LITEST_ANY, LITEST_ANY);
 
 	return litest_run(argc, argv);
 }
-- 
2.1.4



More information about the wayland-devel mailing list