passsy / spot

Chainable powerful Flutter widget selector API, screenshots and assertions for awesome widget tests.
https://pub.dev/packages/spot
Apache License 2.0
63 stars 2 forks source link

Detect AbsorbPointer/IgnorePointer #16

Closed passsy closed 1 year ago

passsy commented 1 year ago

Widgets that are wrapped in AbsorbPointer or IgnorePointer do not receive tap events.

Tapping on the position where the widget is located always works. But when spot doesn't reach the expected widgets during hit testing, it will search for AbsorbPointer or IgnorePointer widgets in the tree that might prevent the hit test from reaching the expected widget.

The widget creation location in code is logged (if available) or the breadcrumb.

Errors look like this:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Widget 'ElevatedButton' is wrapped in AbsorbPointer and doesn't receive taps.
AbsorbPointer is created at
file:///Users/pascalwelsch/Projects/passsy/spot/test/act/act_test.dart:117:18
The closest widget reacting to the touch event is:
Center(alignment: Alignment.center, dependencies: [Directionality], renderObject:
RenderPositionedBox#fcf75)
└AbsorbPointer(absorbing: true, renderObject: RenderAbsorbPointer#c2867 relayoutBoundary=up1)
 └ElevatedButton(dependencies: [MediaQuery, _InheritedTheme, _LocalizationsScope-[GlobalKey#0e78c]],
state: _ButtonStyleState#bc613)
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Widget 'ElevatedButton' is wrapped in IgnorePointer and doesn't receive taps. The IgnorePointer is
located at file:///Users/pascalwelsch/Projects/passsy/spot/test/act/act_test.dart:145:18

When the exception was thrown, this was the stack:
#0      Act._detectIgnorePointer (package:spot/src/act/act.dart:172:7)
#1      Act._pokeRenderObject (package:spot/src/act/act.dart:119:5)
#2      Act.tap.<anonymous closure> (package:spot/src/act/act.dart:54:7)
#3      _alwaysPropagateDevicePointerEvents (package:spot/src/act/act.dart:208:17)
#4      Act.tap (package:spot/src/act/act.dart:24:12)
#5      actTests.<anonymous closure> (file:///Users/pascalwelsch/Projects/passsy/spot/test/act/act_test.dart:156:9)