summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-06-16 14:50:19 -0700
committerJason Gerecke <killertofu@gmail.com>2017-06-19 09:32:18 -0700
commit7bfbf8ed5a82e78a8235275c15e8934b02879f37 (patch)
treedce10e582a6279ab60903e7dc9c3026ad245edd4
parentd958ab79d21b57141415650daac88f9369a1c861 (diff)
downloadxf86-input-wacom-7bfbf8ed5a82e78a8235275c15e8934b02879f37.tar.gz
test: Update test_normalize_pressure to work with maxCurve
Commit d958ab79d2 changes the driver's pressure normalization functions to use a variable "maxCurve" which defines the upper limit of pressure values to be emitted by the driver, rather than using FILTER_PRESSURE_RES directly. The tests were never updated to take this into account and fail due to maxCurve never being set. This patch has the normalize_pressure test set the value of maxCurve. While we're at it, we have the test verify that multiple values of maxCurve work as expected. Fixes: d958ab79d2 (Introduce "Pressure2K" config option for incompatible software) Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r--test/wacom-tests.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/test/wacom-tests.c b/test/wacom-tests.c
index 486454d..80ce5bb 100644
--- a/test/wacom-tests.c
+++ b/test/wacom-tests.c
@@ -179,8 +179,9 @@ test_normalize_pressure(void)
InputInfoRec pInfo = {0};
WacomDeviceRec priv = {0};
WacomCommonRec common = {0};
+ int normalized_max = 65536;
int pressure, prev_pressure = -1;
- int i, j;
+ int i, j, k;
priv.common = &common;
priv.pInfo = &pInfo;
@@ -189,33 +190,39 @@ test_normalize_pressure(void)
priv.minPressure = 0;
- /* Some random loop to check various maxZ pressure values. Starting at
- * 1, because if wcmMaxZ is 0 we have other problems. */
- for (j = 1; j <= 256; j += 17)
- {
- common.wcmMaxZ = j;
- prev_pressure = -1;
+ /* Check various maxCurve values */
+ for (k = 512; k <= normalized_max; k += 239) {
+ priv.maxCurve = k;
- for (i = 0; i <= common.wcmMaxZ; i++)
+ /* Some random loop to check various maxZ pressure values. Starting at
+ * 1, because if wcmMaxZ is 0 we have other problems. */
+ for (j = 1; j <= 256; j += 17)
{
- pressure = i;
+ common.wcmMaxZ = j;
+ prev_pressure = -1;
- pressure = normalizePressure(&priv, pressure);
- assert(pressure >= 0);
- assert(pressure <= FILTER_PRESSURE_RES);
+ for (i = 0; i <= common.wcmMaxZ; i++)
+ {
+ pressure = i;
- /* we count up, so assume normalised pressure goes up too */
- assert(prev_pressure < pressure);
- prev_pressure = pressure;
- }
+ pressure = normalizePressure(&priv, pressure);
+ assert(pressure >= 0);
+ assert(pressure <= k);
- assert(pressure == FILTER_PRESSURE_RES);
+ /* we count up, so assume normalised pressure goes up too */
+ assert(prev_pressure < pressure);
+ prev_pressure = pressure;
+ }
+
+ assert(pressure == k);
+ }
}
/* If minPressure is higher than ds->pressure, normalizePressure takes
* minPressure and ignores actual pressure. This would be a bug in the
* driver code, but we might as well test for it. */
priv.minPressure = 10;
+ priv.maxCurve = normalized_max;
prev_pressure = normalizePressure(&priv, 0);
for (i = 0; i < priv.minPressure; i++)
@@ -224,7 +231,7 @@ test_normalize_pressure(void)
pressure = normalizePressure(&priv, i);
assert(pressure >= 0);
- assert(pressure < FILTER_PRESSURE_RES);
+ assert(pressure < normalized_max);
/* we count up, so assume normalised pressure goes up too */
assert(prev_pressure == pressure);