test: fix ev_rep test for new uinput implementation
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 29 Jul 2013 02:15:07 +0000 (12:15 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 29 Aug 2013 03:54:49 +0000 (13:54 +1000)
We can actually set EV_REP values now, though with limitations

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
test/test-libevdev-has-event.c

index 31a46ab..d74c92e 100644 (file)
@@ -195,15 +195,38 @@ END_TEST
 
 START_TEST(test_ev_rep)
 {
+       struct libevdev *dev;
        struct uinput_device* uidev;
        int rc;
+       int rep, delay;
+       const int KERNEL_DEFAULT_REP = 250;
+       const int KERNEL_DEFAULT_DELAY = 33;
 
        /* EV_REP is special, it's always fully set if set at all,
           can't test this through uinput though */
-       rc = uinput_device_new_with_events(&uidev, TEST_DEVICE_NAME, DEFAULT_IDS,
-                                          EV_REP, 0,
-                                          -1);
-       ck_assert_int_eq(rc, -EINVAL);
+       uidev = uinput_device_new(TEST_DEVICE_NAME);
+       ck_assert(uidev != NULL);
+       rc = uinput_device_set_bit(uidev, EV_REP);
+       ck_assert_int_eq(rc, 0);
+
+       rc = uinput_device_create(uidev);
+       ck_assert_int_eq(rc, 0);
+
+       rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
+       ck_assert_int_eq(rc, 0);
+
+       ck_assert_int_eq(libevdev_has_event_type(dev, EV_REP), 1);
+       ck_assert_int_eq(libevdev_has_event_code(dev, EV_REP, REP_DELAY), 1);
+       ck_assert_int_eq(libevdev_has_event_code(dev, EV_REP, REP_PERIOD), 1);
+
+       ck_assert_int_eq(libevdev_get_repeat(dev, &rep, &delay), 0);
+       /* default values as set by the kernel,
+          see drivers/input/input.c:input_register_device() */
+       ck_assert_int_eq(rep, KERNEL_DEFAULT_REP);
+       ck_assert_int_eq(delay, KERNEL_DEFAULT_DELAY);
+
+       libevdev_free(dev);
+       uinput_device_free(uidev);
 }
 END_TEST