test: add some tests for udev tagging
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 2 Jul 2015 22:13:24 +0000 (08:13 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 2 Jul 2015 23:44:04 +0000 (09:44 +1000)
We can't easily test for DMI matches, but anything that hooks onto pid/vid is
easy to verify for correctness.

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

index f9ce5d3..3f61f08 100644 (file)
@@ -947,6 +947,65 @@ START_TEST(device_wheel_only)
 }
 END_TEST
 
+START_TEST(device_udev_tag_alps)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput_device *device = dev->libinput_device;
+       struct udev_device *d;
+       const char *prop;
+
+       d = libinput_device_get_udev_device(device);
+       prop = udev_device_get_property_value(d,
+                                             "LIBINPUT_MODEL_ALPS_TOUCHPAD");
+
+       if (strstr(libinput_device_get_name(device), "ALPS"))
+               ck_assert_notnull(prop);
+       else
+               ck_assert(prop == NULL);
+
+       udev_device_unref(d);
+}
+END_TEST
+
+START_TEST(device_udev_tag_wacom)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput_device *device = dev->libinput_device;
+       struct udev_device *d;
+       const char *prop;
+
+       d = libinput_device_get_udev_device(device);
+       prop = udev_device_get_property_value(d,
+                                             "LIBINPUT_MODEL_WACOM_TOUCHPAD");
+
+       if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_WACOM)
+               ck_assert_notnull(prop);
+       else
+               ck_assert(prop == NULL);
+
+       udev_device_unref(d);
+}
+END_TEST
+
+START_TEST(device_udev_tag_apple)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput_device *device = dev->libinput_device;
+       struct udev_device *d;
+       const char *prop;
+
+       d = libinput_device_get_udev_device(device);
+       prop = udev_device_get_property_value(d,
+                                             "LIBINPUT_MODEL_WACOM_TOUCHPAD");
+
+       if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_WACOM)
+               ck_assert_notnull(prop);
+       else
+               ck_assert(prop == NULL);
+
+       udev_device_unref(d);
+}
+END_TEST
 void
 litest_setup_tests(void)
 {
@@ -989,4 +1048,8 @@ litest_setup_tests(void)
        litest_add_no_device("device:invalid devices", abs_mt_device_missing_res);
 
        litest_add("device:wheel", device_wheel_only, LITEST_WHEEL, LITEST_RELATIVE|LITEST_ABSOLUTE);
+
+       litest_add("device:udev tags", device_udev_tag_alps, LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("device:udev tags", device_udev_tag_wacom, LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("device:udev tags", device_udev_tag_apple, LITEST_TOUCHPAD, LITEST_ANY);
 }