test: create a new device during the disable test to change fds
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 10 Dec 2014 01:01:08 +0000 (11:01 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 10 Dec 2014 03:52:25 +0000 (13:52 +1000)
In the current test, disable followed by enable would result in the same fd
number for the new device, not exposing a bug fixed by
"evdev: Ensure the libevdev object receives the new fd on resume"

Create a keyboard device after suspending the first device, then re-enable the
device. This changes the fd to a different number, so we pick up on internal
bugs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/device.c

index 28cdb06cda7eb2905be102d17a13b95c0fbfd5a5..16bb99c97640c8b078f5f49fbdc041a6e79e8a4a 100644 (file)
@@ -121,6 +121,8 @@ START_TEST(device_disable)
        struct libinput *li = dev->libinput;
        struct libinput_device *device;
        enum libinput_config_status status;
+       struct libinput_event *event;
+       struct litest_device *tmp;
 
        device = dev->libinput_device;
 
@@ -138,11 +140,30 @@ START_TEST(device_disable)
        litest_event(dev, EV_SYN, SYN_REPORT, 0);
        litest_assert_empty_queue(li);
 
+       /* create a new device so the resumed fd isn't the same as the
+          suspended one */
+       tmp = litest_add_device(li, LITEST_KEYBOARD);
+       ck_assert_notnull(tmp);
+       litest_drain_events(li);
+
        /* no event from resuming */
        status = libinput_device_config_send_events_set_mode(device,
                        LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
        ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
        litest_assert_empty_queue(li);
+
+       /* event from renabled device */
+       litest_event(dev, EV_REL, REL_X, 10);
+       litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+       libinput_dispatch(li);
+       event = libinput_get_event(li);
+       ck_assert_notnull(event);
+       ck_assert_int_eq(libinput_event_get_type(event),
+                        LIBINPUT_EVENT_POINTER_MOTION);
+       libinput_event_destroy(event);
+
+       litest_delete_device(tmp);
 }
 END_TEST