[PATCH libinput 08/10] test: switch the udev tag tests to be quirk tests

Peter Hutterer peter.hutterer at who-t.net
Mon May 28 08:08:34 UTC 2018


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/test-device.c | 85 ------------------------------------------------------
 test/test-quirks.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 85 deletions(-)

diff --git a/test/test-device.c b/test/test-device.c
index 34aa9447..c072e83e 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -1141,87 +1141,6 @@ START_TEST(device_accelerometer)
 }
 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_APPLE_TOUCHPAD");
-
-	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE)
-		ck_assert_notnull(prop);
-	else
-		ck_assert(prop == NULL);
-
-	udev_device_unref(d);
-}
-END_TEST
-
-START_TEST(device_udev_tag_synaptics_serial)
-{
-	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_SYNAPTICS_SERIAL_TOUCHPAD");
-
-	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_SYNAPTICS_SERIAL &&
-	    libevdev_get_id_product(dev->evdev) == PRODUCT_ID_SYNAPTICS_SERIAL)
-		ck_assert_notnull(prop);
-	else
-		ck_assert(prop == NULL);
-
-	udev_device_unref(d);
-}
-END_TEST
-
 START_TEST(device_udev_tag_wacom_tablet)
 {
 	struct litest_device *dev = litest_current_device();
@@ -1627,10 +1546,6 @@ TEST_COLLECTION(device)
 	litest_add("device:wheel", device_wheel_only, LITEST_WHEEL, LITEST_RELATIVE|LITEST_ABSOLUTE|LITEST_TABLET);
 	litest_add_no_device("device:accelerometer", device_accelerometer);
 
-	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);
-	litest_add("device:udev tags", device_udev_tag_synaptics_serial, LITEST_TOUCHPAD, LITEST_ANY);
 	litest_add("device:udev tags", device_udev_tag_wacom_tablet, LITEST_TABLET, LITEST_ANY);
 
 	litest_add_no_device("device:invalid rel events", device_nonpointer_rel);
diff --git a/test/test-quirks.c b/test/test-quirks.c
index 01dc9d3a..2da588fe 100644
--- a/test/test-quirks.c
+++ b/test/test-quirks.c
@@ -401,6 +401,84 @@ START_TEST(quirks_model_zero)
 }
 END_TEST
 
+START_TEST(quirks_model_alps)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput_device *device = dev->libinput_device;
+	struct quirks *q;
+	bool exists, value;
+
+	q = dev->quirks;
+	exists = quirks_get_bool(q, QUIRK_MODEL_ALPS_TOUCHPAD, &value);
+
+	if (strstr(libinput_device_get_name(device), "ALPS")) {
+		ck_assert(exists);
+		ck_assert(value);
+	} else {
+		ck_assert(!exists);
+		ck_assert(!value);
+	}
+}
+END_TEST
+
+START_TEST(quirks_model_wacom)
+{
+	struct litest_device *dev = litest_current_device();
+	struct quirks *q;
+	bool exists, value;
+
+	q = dev->quirks;
+	exists = quirks_get_bool(q, QUIRK_MODEL_WACOM_TOUCHPAD, &value);
+
+	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_WACOM) {
+		ck_assert(exists);
+		ck_assert(value);
+	} else {
+		ck_assert(!exists);
+		ck_assert(!value);
+	}
+}
+END_TEST
+
+START_TEST(quirks_model_apple)
+{
+	struct litest_device *dev = litest_current_device();
+	struct quirks *q;
+	bool exists, value;
+
+	q = dev->quirks;
+	exists = quirks_get_bool(q, QUIRK_MODEL_APPLE_TOUCHPAD, &value);
+
+	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE) {
+		ck_assert(exists);
+		ck_assert(value);
+	} else {
+		ck_assert(!exists);
+		ck_assert(!value);
+	}
+}
+END_TEST
+
+START_TEST(quirks_model_synaptics_serial)
+{
+	struct litest_device *dev = litest_current_device();
+	struct quirks *q;
+	bool exists, value;
+
+	q = dev->quirks;
+	exists = quirks_get_bool(q, QUIRK_MODEL_SYNAPTICS_SERIAL_TOUCHPAD, &value);
+
+	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_SYNAPTICS_SERIAL &&
+	    libevdev_get_id_product(dev->evdev) == PRODUCT_ID_SYNAPTICS_SERIAL) {
+		ck_assert(exists);
+		ck_assert(value);
+	} else {
+		ck_assert(!exists);
+		ck_assert(!value);
+	}
+}
+END_TEST
+
 TEST_COLLECTION(quirks)
 {
 	litest_add_for_device("quirks:datadir", quirks_invalid_dir, LITEST_MOUSE);
@@ -422,4 +500,9 @@ TEST_COLLECTION(quirks)
 
 	litest_add_for_device("quirks:model", quirks_model_one, LITEST_MOUSE);
 	litest_add_for_device("quirks:model", quirks_model_zero, LITEST_MOUSE);
+
+	litest_add("quirks:devices", quirks_model_alps, LITEST_TOUCHPAD, LITEST_ANY);
+	litest_add("quirks:devices", quirks_model_wacom, LITEST_TOUCHPAD, LITEST_ANY);
+	litest_add("quirks:devices", quirks_model_apple, LITEST_TOUCHPAD, LITEST_ANY);
+	litest_add("quirks:devices", quirks_model_synaptics_serial, LITEST_TOUCHPAD, LITEST_ANY);
 }
-- 
2.14.3



More information about the wayland-devel mailing list