From 6f10f01af280b567e6b6d23ced6fefe0111e080e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 13 Jun 2023 15:22:26 +1000 Subject: [PATCH] test: check that the pressure offset is reduced during motion events too 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 --- test/test-tablet.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test-tablet.c b/test/test-tablet.c index 8f2d37dd..354d5d9e 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -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 -- 2.34.1