test: check the libinput device for BTN_MIDDLE, not the libevdev device
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 17 Feb 2017 00:38:09 +0000 (10:38 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 20 Feb 2017 02:16:02 +0000 (12:16 +1000)
We don't have the same libevdev context that libinput has so if libinput
disables/enables event codes we don't see that and may get unexpected
behavior in the test.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
test/test-pointer.c

index 6485258e553c8e3ea687144facccaf643c8568a5..986ec8b797ce3a720d0cf3431b51ea582fbf4693 100644 (file)
@@ -371,13 +371,15 @@ START_TEST(pointer_button)
        test_button_event(dev, BTN_LEFT, 1);
        test_button_event(dev, BTN_LEFT, 0);
 
-       if (libevdev_has_event_code(dev->evdev, EV_KEY, BTN_RIGHT)) {
+       if (libinput_device_pointer_has_button(dev->libinput_device,
+                                              BTN_RIGHT)) {
                test_button_event(dev, BTN_RIGHT, 1);
                test_button_event(dev, BTN_RIGHT, 0);
        }
 
        /* Skip middle button test on trackpoints (used for scrolling) */
-       if (libevdev_has_event_code(dev->evdev, EV_KEY, BTN_MIDDLE)) {
+       if (libinput_device_pointer_has_button(dev->libinput_device,
+                                              BTN_MIDDLE)) {
                test_button_event(dev, BTN_MIDDLE, 1);
                test_button_event(dev, BTN_MIDDLE, 0);
        }
@@ -904,9 +906,7 @@ START_TEST(pointer_left_handed)
                                   BTN_LEFT,
                                   LIBINPUT_BUTTON_STATE_RELEASED);
 
-       if (libevdev_has_event_code(dev->evdev,
-                                   EV_KEY,
-                                   BTN_MIDDLE)) {
+       if (libinput_device_pointer_has_button(d, BTN_MIDDLE)) {
                litest_button_click(dev, BTN_MIDDLE, 1);
                litest_button_click(dev, BTN_MIDDLE, 0);
                litest_assert_button_event(li,
@@ -1614,7 +1614,8 @@ START_TEST(middlebutton_middleclick)
 
        disable_button_scrolling(device);
 
-       if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE))
+       if (!libinput_device_pointer_has_button(device->libinput_device,
+                                              BTN_MIDDLE))
                return;
 
        status = libinput_device_config_middle_emulation_set_enabled(
@@ -1678,7 +1679,8 @@ START_TEST(middlebutton_middleclick_during)
 
        disable_button_scrolling(device);
 
-       if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE))
+       if (!libinput_device_pointer_has_button(device->libinput_device,
+                                               BTN_MIDDLE))
                return;
 
        status = libinput_device_config_middle_emulation_set_enabled(
@@ -1745,7 +1747,7 @@ START_TEST(middlebutton_default_enabled)
        available = libinput_device_config_middle_emulation_is_available(device);
        ck_assert(available);
 
-       if (libevdev_has_event_code(dev->evdev, EV_KEY, BTN_MIDDLE))
+       if (libinput_device_pointer_has_button(device, BTN_MIDDLE))
                deflt = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
        else
                deflt = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
@@ -1815,7 +1817,7 @@ START_TEST(middlebutton_default_touchpad)
        available = libinput_device_config_middle_emulation_is_available(device);
        ck_assert(!available);
 
-       if (libevdev_has_event_code(dev->evdev, EV_KEY, BTN_MIDDLE))
+       if (libinput_device_pointer_has_button(device, BTN_MIDDLE))
                return;
 
        state = libinput_device_config_middle_emulation_get_enabled(