[PATCH libinput v2] tests: Add negative test for libinput_device_keyboard_has_key()
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 26 16:45:43 PDT 2015
On Fri, Apr 24, 2015 at 05:21:18PM -0500, Derek Foreman wrote:
> Ensure we get a -1 return for non-keyboard devices.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
merged, thanks, though I did a minor change to it to make the line wrapping
nicer:
+ for (code = 0; code < KEY_CNT; code++) {
+ has_key = libinput_device_keyboard_has_key(device, code);
+ ck_assert_int_eq(has_key, -1);
+ }
Cheers,
Peter
> ---
> test/keyboard.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/test/keyboard.c b/test/keyboard.c
> index a477cfb..cf56923 100644
> --- a/test/keyboard.c
> +++ b/test/keyboard.c
> @@ -309,6 +309,22 @@ 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;
> + unsigned int code;
> +
> + if (libinput_device_has_capability(device,
> + LIBINPUT_DEVICE_CAP_KEYBOARD))
> + return;
> +
> + for (code = 0; code < KEY_CNT; code++)
> + ck_assert_int_eq(
> + libinput_device_keyboard_has_key(device, code), -1);
> +}
> +END_TEST
> +
> int
> main(int argc, char **argv)
> {
> @@ -316,6 +332,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", keyboard_keys_bad_device, LITEST_ANY, LITEST_ANY);
>
> return litest_run(argc, argv);
> }
> --
> 2.1.4
More information about the wayland-devel
mailing list