summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2020-02-07 13:09:58 -0800
committerJason Gerecke <killertofu@gmail.com>2020-02-07 13:13:04 -0800
commit10cacabcd46fcac9cccc9e4802e42d3ad2a80ebe (patch)
treed38863dea2cb801dd1963f5af299090d43681da9 /test
parent134166f52749f6aa5ce4f86e85c6954f4b6a8f6e (diff)
downloadlibwacom-10cacabcd46fcac9cccc9e4802e42d3ad2a80ebe.tar.gz
test: Validate the VID:PID of all matches, not just the first
We should walk over the list of matches that is associated with each device to ensure that they are all valid. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'test')
-rw-r--r--test/test-tablet-validity.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/test/test-tablet-validity.c b/test/test-tablet-validity.c
index d06f4db..8ee41e2 100644
--- a/test/test-tablet-validity.c
+++ b/test/test-tablet-validity.c
@@ -159,23 +159,21 @@ test_name(gconstpointer data)
}
static void
-test_vidpid(gconstpointer data)
+assert_vidpid(WacomBusType bus, int vid, int pid)
{
- WacomDevice *device = (WacomDevice*)data;
-
- switch (libwacom_get_bustype(device)) {
+ switch (bus) {
case WBUSTYPE_SERIAL:
- g_assert_cmpint(libwacom_get_vendor_id(device), >=, 0);
- g_assert_cmpint(libwacom_get_product_id(device), >=, 0);
+ g_assert_cmpint(vid, >=, 0);
+ g_assert_cmpint(pid, >=, 0);
break;
case WBUSTYPE_USB:
- if (libwacom_get_vendor_id(device) == 0x056A)
- g_assert_cmpint(libwacom_get_product_id(device), !=, 0x84); /* wireless dongle */
+ if (vid == 0x056A)
+ g_assert_cmpint(pid, !=, 0x84); /* wireless dongle */
/* fall through */
case WBUSTYPE_BLUETOOTH:
case WBUSTYPE_I2C:
- g_assert_cmpint(libwacom_get_vendor_id(device), >, 0);
- g_assert_cmpint(libwacom_get_product_id(device), >, 0);
+ g_assert_cmpint(vid, >, 0);
+ g_assert_cmpint(pid, >, 0);
break;
case WBUSTYPE_UNKNOWN:
default:
@@ -185,6 +183,15 @@ test_vidpid(gconstpointer data)
}
static void
+test_vidpid(gconstpointer data)
+{
+ WacomDevice *device = (WacomDevice*)data;
+ WacomBusType bus = libwacom_get_bustype(device);
+
+ assert_vidpid(bus, libwacom_get_vendor_id(device), libwacom_get_product_id(device));
+}
+
+static void
test_matches(gconstpointer data)
{
WacomDevice *device = (WacomDevice*)data;
@@ -194,6 +201,19 @@ test_matches(gconstpointer data)
}
static void
+test_matches_vidpid(gconstpointer data)
+{
+ WacomDevice *device = (WacomDevice*)data;
+ const WacomMatch **match = libwacom_get_matches(device);
+
+ while (*match) {
+ WacomBusType bus = libwacom_match_get_bustype(*match);
+ assert_vidpid(bus, libwacom_match_get_vendor_id(*match), libwacom_match_get_product_id(*match));
+ match++;
+ }
+}
+
+static void
test_dimensions(gconstpointer data)
{
WacomDevice *device = (WacomDevice*)data;
@@ -308,6 +328,7 @@ static void setup_tests(WacomDevice *device)
add_test(device, test_name);
add_test(device, test_vidpid);
add_test(device, test_matches);
+ add_test(device, test_matches_vidpid);
add_test(device, test_buttons);
add_test(device, test_styli);
add_test(device, test_rings);