Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Widget test] Tapping DropdownMenuItem fails hit test #82908

Open
Tregan opened this issue May 19, 2021 · 9 comments
Open

[Widget test] Tapping DropdownMenuItem fails hit test #82908

Tregan opened this issue May 19, 2021 · 9 comments
Labels
a: quality A truly polished experience a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@Tregan
Copy link

Tregan commented May 19, 2021

Steps to Reproduce

  1. Create a new application project
  2. change widget_test.dart to
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  WidgetController.hitTestWarningShouldBeFatal = true;

  testWidgets('Clicking DropdownMenuItem should not fail', (WidgetTester tester) async {
    await tester.pumpWidget(MaterialApp(
      home: Scaffold(
        body: Builder(
          builder: (context) => DropdownButton<int>(
            key: Key('dropdown'),
            items: [
              DropdownMenuItem(key: Key('1'), value: 1, child: Text('1')),
              DropdownMenuItem(key: Key('2'), value: 2, child: Text('2')),
            ],
          ),
        ),
      ),
    ));

    await tester.tap(find.byKey(Key('dropdown')));
    await tester.pumpAndSettle();

    await tester.tap(find.byKey(Key('2')));
    await tester.pumpAndSettle();
  });
}
  1. Run the test

Expected results:
The test is expected to succeed without any warnings or errors being thrown around

Actual results:
The test fails because the hit test for the line await tester.tap(find.byKey(Key('2'))); fails.

Logs
PS C:\Users\basro\Desktop\test\flutter_application_1> flutter test --verbose
[  +55 ms] executing: [C:\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +56 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] b22742018b3edf16c6cadd7b76d9db5e7f9064b5
[        ] executing: [C:\flutter/] git tag --points-at b22742018b3edf16c6cadd7b76d9db5e7f9064b5
[  +71 ms] Exit code 0 from: git tag --points-at b22742018b3edf16c6cadd7b76d9db5e7f9064b5
[        ] 2.2.0
[   +4 ms] executing: [C:\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +29 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [C:\flutter/] git ls-remote --get-url origin
[  +25 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +100 ms] executing: [C:\flutter/] git rev-parse --abbrev-ref HEAD
[  +29 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +80 ms] Found 1 files which will be executed as Widget Tests.
[   +6 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +47 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +35 ms] Skipping pub get: version match.
[  +86 ms] Generating C:\Users\basro\Desktop\test\flutter_application_1\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +33 ms] running test package with arguments: [-r, compact, --timeout, 30s, --concurrency=14, --, C:\Users\basro\Desktop\test\flutter_application_1\test\widget_test.dart]
00:00 +0: loading C:\Users\basro\Desktop\test\flutter_application_1\test\widget_test.dart                                                                                                                                                                                                                             [ +148 ms] test 0: starting test C:\Users\basro\Desktop\test\flutter_application_1\test\widget_test.dart
[   +5 ms] Stopping scan for flutter_test_config.dart; found project root at C:\Users\basro\Desktop\test\flutter_application_1
[   +2 ms] Compiler will use the following file as its incremental dill file: C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_compiler.e574d54\output.dill
[        ] Listening to compiler controller...
[   +8 ms] Compiling file:///C:/Users/basro/AppData/Local/Temp/flutter_tools.9fdf716/flutter_test_listener.6bec8238/listener.dart
[   +7 ms] C:\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev C:\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root C:\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --no-print-incremental-dependencies --target=flutter
--debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_compiler.e574d54\output.dill --packages C:\Users\basro\Desktop\test\flutter_application_1\.dart_tool\package_config.json
-Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --initialize-from-dill C:\Users\basro\Desktop\test\flutter_application_1\build\test_cache\build\c075001b96339384a97db4862b8ab8db.cache.dill.track.dill
[  +14 ms] <- compile file:///C:/Users/basro/AppData/Local/Temp/flutter_tools.9fdf716/flutter_test_listener.6bec8238/listener.dart
00:05 +0: loading C:\Users\basro\Desktop\test\flutter_application_1\test\widget_test.dart                                                                                                                                                                                                                             [+5569 ms] <- accept
[        ] <- reset
[        ] Compiling C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_listener.6bec8238\listener.dart took 5591ms
[        ] test 0: starting test device
[   +4 ms] test 0: awaiting connection to test device
[   +1 ms] test 0: Observatory uri is not available
[   +6 ms] test 0: test harness socket server is running at port:56662
[   +1 ms] Using this directory for fonts configuration: C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_fonts.cf36d146
[   +1 ms] test 0: Starting flutter_tester process with command=[C:\flutter\bin\cache\artifacts\engine\windows-x64\flutter_tester.exe, --disable-observatory, --enable-checked-mode, --verify-entry-points, --enable-software-rendering, --skia-deterministic-rendering, --enable-dart-profiling, --non-interactive,   
--use-test-fonts, --packages=C:\Users\basro\Desktop\test\flutter_application_1\.dart_tool\package_config.json, C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_listener.6bec8238\listener.dart.dill], environment={FLUTTER_TEST: true, FONTCONFIG_FILE:
C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_fonts.cf36d146/fonts.conf, SERVER_PORT: 56662, APP_NAME: flutter_application_1, UNIT_TEST_ASSETS: C:\Users\basro\Desktop\test\flutter_application_1\build\unit_test_assets}
[   +5 ms] test 0: Started flutter_tester process at pid 13132
[ +252 ms] test 0: connected to test device, now awaiting test result
[        ] test 0: Waiting for test harness or tests to finish
00:06 +0: Clicking DropdownMenuItem should not fail
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
Finder specifies a widget that would not receive pointer events.
A call to tap() with finder "exactly one widget with key [<'2'>] (ignoring offstage widgets):
DropdownMenuItem<int>-[<'2'>]" derived an Offset (Offset(8.0, 24.0)) that would not hit test on the
specified widget.
Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot
receive pointer events.
The finder corresponds to this RenderBox: RenderConstrainedBox#a92ad relayoutBoundary=up10 NEEDS-PAINT(creator: ConstrainedBox ← Container ← DropdownMenuItem<int>-[<'2'>] ← SizedBox ← IndexedStack ← Row ← Padding ← Container ← DefaultTextStyle ← Stack ← Listener ← _GestureSemantics ← ⋯, parentData: <none> (can use size), constraints: BoxConstraints(0.0<=w<=Infinity, h=48.0), size: Size(16.0, 48.0), additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 48.0<=h<=Infinity))
The hit test result at that offset is: HitTestResult(RenderPointerListener#4ffa3@Offset(8.0, 24.0),
RenderSemanticsGestureHandler#36632@Offset(8.0, 24.0), RenderSemanticsAnnotations#b1bfe@Offset(8.0,
24.0), RenderSemanticsAnnotations#c0919@Offset(8.0, 24.0),
RenderCustomMultiChildLayoutBox#295fe@Offset(8.0, 24.0), _RenderInkFeatures#ee8e8@Offset(8.0, 24.0),
RenderPhysicalModel#5cd86@Offset(8.0, 24.0), RenderSemanticsAnnotations#b0f1e@Offset(8.0, 24.0),
RenderRepaintBoundary#066cf@Offset(8.0, 24.0), RenderIgnorePointer#4f73e@Offset(8.0, 24.0),
RenderAnimatedOpacity#b7673@Offset(8.0, 24.0), RenderRepaintBoundary#e2a32@Offset(8.0, 24.0),
RenderSemanticsAnnotations#241e3@Offset(8.0, 24.0), RenderOffstage#84140@Offset(8.0, 24.0),
RenderSemanticsAnnotations#59452@Offset(8.0, 24.0), _RenderTheatre#0aa69@Offset(8.0, 24.0),
RenderSemanticsAnnotations#66eaf@Offset(8.0, 24.0), RenderAbsorbPointer#c4c50@Offset(8.0, 24.0),
RenderPointerListener#533ad@Offset(8.0, 24.0), RenderCustomPaint#91e3b@Offset(8.0, 24.0),
RenderSemanticsAnnotations#7d419@Offset(8.0, 24.0), RenderSemanticsAnnotations#99934@Offset(8.0,
24.0), RenderSemanticsAnnotations#91061@Offset(8.0, 24.0), HitTestEntry#062cb(RenderView#eb2b7),
HitTestEntry#d0def(<AutomatedTestWidgetsFlutterBinding>))
If you expected this target not to be able to receive pointer events, pass "warnIfMissed: false" to
"tap()".
To make this error into a non-fatal warning, set WidgetController.hitTestWarningShouldBeFatal to
false.

When the exception was thrown, this was the stack:
#0      WidgetController._getElementPoint (package:flutter_test/src/controller.dart:934:11)
#1      WidgetController.getCenter (package:flutter_test/src/controller.dart:836:12)
#2      WidgetController.tap (package:flutter_test/src/controller.dart:271:18)
#3      main.<anonymous closure> (file:///C:/Users/basro/Desktop/test/flutter_application_1/test/widget_test.dart:32:18)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  Clicking DropdownMenuItem should not fail
════════════════════════════════════════════════════════════════════════════════════════════════════
00:06 +0 -1: Clicking DropdownMenuItem should not fail [E]
  Test failed. See exception logs above.
  The test description was: Clicking DropdownMenuItem should not fail

[ +568 ms] test 0: Test harness is no longer needed by test process
[        ] test 0: finished
[   +1 ms] test 0: cleaning up...
[        ] test 0: ensuring test device is terminated.
[        ] test 0: Terminating flutter_tester process
[        ] test 0: Shutting down test harness socket server
[        ] test 0: Test process is no longer needed by test harness
[   +9 ms] test 0: flutter_tester process at pid 13132 exited with code=-1
[        ] test 0: deleting temporary directory
[   +2 ms] test 0: finished
00:06 +0 -1: Some tests failed.
[   +7 ms] Deleting C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_compiler.e574d54...
[   +3 ms] killing pid 21820
[  +43 ms] Deleting C:\Users\basro\AppData\Local\Temp\flutter_tools.9fdf716\flutter_test_fonts.cf36d146...
[   +2 ms] test package returned with exit code 1
[   +6 ms] "flutter test" took 6.909ms.
[   +3 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      TestCommand.runCommand (package:flutter_tools/src/commands/test.dart:468:7)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>


[   +4 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
PS C:\Users\basro\Desktop\test\flutter_application_1> flutter analyze
Analyzing flutter_application_1...                                      
No issues found! (ran in 1.0s)
PS C:\Users\basro\Desktop\test\flutter_application_1> flutter doctor -v
[√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19042.985], locale nl-NL)
    • Flutter version 2.2.0 at C:\flutter
    • Framework revision b22742018b (4 days ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\basro\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 51.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.56.2)
    • VS Code at C:\Users\basro\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.22.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 90.0.818.62

• No issues found!
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 19, 2021
@darshankawar
Copy link
Member

@Tregan
I am getting compile error on the setter : WidgetController.hitTestWarningShouldBeFatal = true;
Where is it coming from ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 19, 2021
@Tregan
Copy link
Author

Tregan commented May 19, 2021

@darshankawar This is included in the flutter_test package (Flutter 2.2.0) and makes it so that any hit test failures during tests fail the test, instead of just printing the warning.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 19, 2021
@darshankawar
Copy link
Member

Ah. Thanks. I was on 2.0.6 on which it gives that error. Running the test fails with below log:

console error log


Testing started at 7:05 PM ...
/Users/dhs/Documents/Fluttersdk/flutter/bin/flutter --no-color test --machine --start-paused test/widget_test.dart
Running "flutter pub get" in bug_test...                         1,686ms

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
Finder specifies a widget that would not receive pointer events.
A call to tap() with finder "exactly one widget with key [<'2'>] (ignoring offstage widgets):
DropdownMenuItem<int>-[<'2'>]" derived an Offset (Offset(8.0, 24.0)) that would not hit test on the
specified widget.
Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot
receive pointer events.
The finder corresponds to this RenderBox: RenderConstrainedBox#747ec relayoutBoundary=up10 NEEDS-PAINT(creator: ConstrainedBox ← Container ← DropdownMenuItem<int>-[<'2'>] ← SizedBox ← IndexedStack ← Row ← Padding ← Container ← DefaultTextStyle ← Stack ← Listener ← _GestureSemantics ← ⋯, parentData: <none> (can use size), constraints: BoxConstraints(0.0<=w<=Infinity, h=48.0), size: Size(16.0, 48.0), additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 48.0<=h<=Infinity))
The hit test result at that offset is: HitTestResult(RenderPointerListener#8a870@Offset(8.0, 24.0),
RenderSemanticsGestureHandler#4c3d5@Offset(8.0, 24.0), RenderSemanticsAnnotations#dd5dd@Offset(8.0,
24.0), RenderSemanticsAnnotations#07230@Offset(8.0, 24.0),
RenderCustomMultiChildLayoutBox#367d5@Offset(8.0, 24.0), _RenderInkFeatures#50a91@Offset(8.0, 24.0),
RenderPhysicalModel#cbd4c@Offset(8.0, 24.0), RenderSemanticsAnnotations#45167@Offset(8.0, 24.0),
RenderRepaintBoundary#d808f@Offset(8.0, 24.0), RenderIgnorePointer#54611@Offset(8.0, 24.0),
RenderAnimatedOpacity#fd893@Offset(8.0, 24.0), RenderRepaintBoundary#7a168@Offset(8.0, 24.0),
RenderSemanticsAnnotations#12f36@Offset(8.0, 24.0), RenderOffstage#438a3@Offset(8.0, 24.0),
RenderSemanticsAnnotations#444d1@Offset(8.0, 24.0), _RenderTheatre#347ca@Offset(8.0, 24.0),
RenderSemanticsAnnotations#634ac@Offset(8.0, 24.0), RenderAbsorbPointer#7ba4e@Offset(8.0, 24.0),
RenderPointerListener#884aa@Offset(8.0, 24.0), RenderCustomPaint#d470b@Offset(8.0, 24.0),
RenderSemanticsAnnotations#54475@Offset(8.0, 24.0), RenderSemanticsAnnotations#66c57@Offset(8.0,
24.0), RenderSemanticsAnnotations#779f3@Offset(8.0, 24.0), HitTestEntry#5e9fe(RenderView#2b2ee),
HitTestEntry#f9f39(<AutomatedTestWidgetsFlutterBinding>))
If you expected this target not to be able to receive pointer events, pass "warnIfMissed: false" to
"tap()".
To make this error into a non-fatal warning, set WidgetController.hitTestWarningShouldBeFatal to
false.

When the exception was thrown, this was the stack:
#0      WidgetController._getElementPoint (package:flutter_test/src/controller.dart:934:11)
#1      WidgetController.getCenter (package:flutter_test/src/controller.dart:836:12)
#2      WidgetController.tap (package:flutter_test/src/controller.dart:271:18)
#3      main.<anonymous closure> (file:///Users/dhs/Documents/NCFlutter/bug_test/test/widget_test.dart:25:18)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  Clicking DropdownMenuItem should not fail
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.
The test description was: Clicking DropdownMenuItem should not fail



flutter doctor -v
[✓] Flutter (Channel stable, 2.2.0, on Mac OS X 10.15.4 19E2269 darwin-x64,
    locale en-GB)
    • Flutter version 2.2.0 at /Users/dhs/documents/fluttersdk/flutter
    • Framework revision b22742018b (4 days ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.55.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (3 available)
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 90.0.4430.212

! Doctor found issues in 1 category.



@darshankawar darshankawar added a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on and removed in triage Presently being triaged by the triage team labels May 19, 2021
@kuhnroyal
Copy link

I have a lot of false positives for hit test failures after 2.2.0 upgrade, in Dropdowns, in Dialogs and in TextInputs.
Adding warnIfMissed doesn't seem right.

@Tregan
Copy link
Author

Tregan commented Sep 10, 2021

This is still the case in Flutter 2.5.0 (stable) as well as master (2.6.0), even after these fixes: #80856 #86449

Logs
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
Finder specifies a widget that would not receive pointer events.
A call to tap() with finder "exactly one widget with key [<'2'>] (ignoring offstage widgets):
DropdownMenuItem<int>-[<'2'>]" derived an Offset (Offset(8.0, 24.0)) that would not hit test on the
specified widget.
Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot
receive pointer events.
The finder corresponds to this RenderBox: RenderConstrainedBox#56326 relayoutBoundary=up11 NEEDS-PAINT(creator: ConstrainedBox ← Container ← DropdownMenuItem<int>-[<'2'>] ← SizedBox ← IndexedStack ← Row ← Padding ← Container ← DefaultTextStyle ← Stack ← Listener ← _GestureSemantics ← ⋯, parentData: <none> (can use size), constraints: BoxConstraints(0.0<=w<=Infinity, h=48.0), size: Size(16.0, 48.0), additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 48.0<=h<=Infinity))
The hit test result at that offset is: HitTestResult(RenderPointerListener#87fae@Offset(8.0, 24.0),
RenderSemanticsGestureHandler#30e25@Offset(8.0, 24.0), RenderMouseRegion#7436b@Offset(8.0, 24.0),
RenderSemanticsAnnotations#1af09@Offset(8.0, 24.0), RenderSemanticsAnnotations#88f0a@Offset(8.0,
24.0), RenderCustomMultiChildLayoutBox#f3440@Offset(8.0, 24.0), _RenderInkFeatures#2e86b@Offset(8.0,
24.0), RenderPhysicalModel#951c6@Offset(8.0, 24.0), RenderSemanticsAnnotations#768e8@Offset(8.0,
24.0), RenderRepaintBoundary#57e0a@Offset(8.0, 24.0), RenderIgnorePointer#6a967@Offset(8.0, 24.0),
RenderAnimatedOpacity#6514a@Offset(8.0, 24.0), RenderRepaintBoundary#a7174@Offset(8.0, 24.0),
_RenderFocusTrap#3f33a@Offset(8.0, 24.0), RenderSemanticsAnnotations#efb3d@Offset(8.0, 24.0),
RenderOffstage#604f5@Offset(8.0, 24.0), RenderSemanticsAnnotations#a6aa5@Offset(8.0, 24.0),
_RenderTheatre#3d8e8@Offset(8.0, 24.0), RenderSemanticsAnnotations#d19e7@Offset(8.0, 24.0),
RenderAbsorbPointer#24d5d@Offset(8.0, 24.0), RenderPointerListener#07cc4@Offset(8.0, 24.0),
RenderCustomPaint#ef1f3@Offset(8.0, 24.0), RenderSemanticsAnnotations#c5d6e@Offset(8.0, 24.0),
RenderSemanticsAnnotations#181df@Offset(8.0, 24.0), RenderSemanticsAnnotations#766c5@Offset(8.0,
24.0), RenderSemanticsAnnotations#e27c6@Offset(8.0, 24.0), HitTestEntry#cefd4(RenderView#c994c),
HitTestEntry#b7a91(<AutomatedTestWidgetsFlutterBinding>))
If you expected this target not to be able to receive pointer events, pass "warnIfMissed: false" to
"tap()".
To make this error into a non-fatal warning, set WidgetController.hitTestWarningShouldBeFatal to
false.

When the exception was thrown, this was the stack:
#0      WidgetController._getElementPoint (package:flutter_test/src/controller.dart:939:11)
#1      WidgetController.getCenter (package:flutter_test/src/controller.dart:841:12)
#2      WidgetController.tap (package:flutter_test/src/controller.dart:273:18)
#3      main.<anonymous closure> (file:///C:/Users/basro/Downloads/tmp/flutter_application_1/test/flutter_application_1_test.dart:25:18)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  Clicking DropdownMenuItem should not fail
════════════════════════════════════════════════════════════════════════════════════════════════════
flutter doctor -v
[√] Flutter (Channel master, 2.6.0-1.0.pre.238, on Microsoft Windows [Version 10.0.19043.1165], locale nl-NL)
    • Flutter version 2.6.0-1.0.pre.238 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 53e851162e (5 hours ago), 2021-09-10 01:37:42 -0400
    • Engine revision 825c409164
    • Dart version 2.15.0 (build 2.15.0-93.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\basro\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.60.0)
    • VS Code at C:\Users\basro\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 93.0.961.38

• No issues found!

@Hixie Hixie added the P2 Important issues not at the top of the work list label Nov 8, 2021
@Hixie
Copy link
Contributor

Hixie commented Nov 8, 2021

Trying to hit the text of options in a PopupMenuButton also gets flagged with the warnIfMissed warning sometimes.

@Hixie Hixie added the a: quality A truly polished experience label Nov 8, 2021
@Hixie
Copy link
Contributor

Hixie commented Nov 8, 2021

It's weird, this isn't always reliably a problem. For example, the first case below passes, but the second fails:

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  WidgetController.hitTestWarningShouldBeFatal = true;

   testWidgets('Clicking DropdownMenuItem should not fail', (WidgetTester tester) async {
    await tester.pumpWidget(MaterialApp(
      home: Center(
        child: Material(
          child: DropdownButton<int>(
            key: Key('button'),
            onChanged: (int? result) { },
            items: <DropdownMenuItem<int>>[
              const DropdownMenuItem<int>(
                key: Key('item'),
                value: 1,
                child: Text('111111111111111111'),
              ),
            ],  
          ),
	),
      ),  
    )); 
    await tester.tap(find.byKey(Key('button')));
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));
    await tester.tap(find.byKey(Key('item')).at(1));
  });

  testWidgets('Clicking DropdownMenuItem should not fail', (WidgetTester tester) async {
    await tester.pumpWidget(
      MaterialApp(
        home: Center(
          child: Material(
            child: DropdownButton<int>(
              onChanged: (int? value) { },
              key: Key('button'),
              items: <DropdownMenuItem<int>>[
                DropdownMenuItem(
                  key: Key('item'),
                  value: 1,
                  child: Text('1'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
    await tester.tap(find.byKey(Key('button')));
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));
    await tester.tap(find.byKey(Key('item')).at(1));
  });
}

(I believe the only difference is the length of the text.)

@dowski
Copy link

dowski commented Jun 22, 2022

Still seeing this, and yes, it seems like the length of the text matters. In my test case it failed with the text 'Foo' but passed with 'FooFoo'.

@Tregan
Copy link
Author

Tregan commented Feb 28, 2023

I decided to check this again, and the issue seems to have been fixed.

Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b06b8b2710 (5 weeks ago) • 2023-01-23 16:55:55 -0800
Engine • revision b24591ed32
Tools • Dart 2.19.0 • DevTools 2.20.1

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: quality A truly polished experience a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

No branches or pull requests

5 participants