test: check that the pressure offset is reduced during motion events too
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 13 Jun 2023 05:22:26 +0000 (15:22 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 14 Jun 2023 00:46:24 +0000 (10:46 +1000)
Ensure that if we do get pressure < offset that that offset is reduced
to the current pressure value.

The implementation for this is arguably buggy, reducing the pressure
means we get a tip up event since we now reach 0% of pressure. Arguably
we should enforce the tip staying down and releasing it later but since
this should typically never happen more than once per tool per context
and working around this is a lot of effort, we live with it.

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

index 8f2d37dd95dd2af3721a649d2a0ebcad25e2ae63..354d5d9ebb16f5bd7dc3be4d83d2ba51c58bacb2 100644 (file)
@@ -3921,6 +3921,26 @@ START_TEST(tablet_pressure_offset_decrease)
         * account it's closer to 5% into the remaining effective 89% range
         */
        assert_pressure(li, LIBINPUT_EVENT_TABLET_TOOL_TIP, 0.05);
+
+       /* a reduced pressure value during motion events must reduce the offset
+        * - here back down to 5%.
+        * FIXME: this causes a tip up event which is a bug but working around
+        * this is more effort than it's worth for what should be quite a niche
+        * case.
+        */
+       litest_axis_set_value(axes, ABS_PRESSURE, 5);
+       litest_tablet_motion(dev, 75, 75, axes);
+       libinput_dispatch(li);
+       assert_pressure(li, LIBINPUT_EVENT_TABLET_TOOL_TIP, 0.0);
+       litest_drain_events(li);
+
+       /* back to 10% should now give us 5% pressure because we reduced the
+        * offset */
+        litest_axis_set_value(axes, ABS_PRESSURE, 10);
+       litest_tablet_motion(dev, 75, 75, axes);
+       libinput_dispatch(li);
+       assert_pressure(li, LIBINPUT_EVENT_TABLET_TOOL_TIP, 0.05);
+       litest_drain_events(li);
 }
 END_TEST