On Mon, Jun 19, 2017 at 09:35:27AM -0700, Jason Gerecke wrote:
> 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.gere...@wacom.com>

Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net>

Cheers,
   Peter
> ---
>  test/wacom-tests.c | 43 +++++++++++++++++++++++++------------------
>  1 file 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);
> -- 
> 2.13.1
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to