Repository: flutter
Issue: [Widget test] Tapping DropdownMenuItem fails hit test
Labels: a: tests,framework,f: material design,a: quality,has reproducible steps,P2,found in release: 2.2,team-design,triaged-design

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

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();
  });
}
```
3. Run the test

**Expected results:** 
The test is expected to succeed without any warnings or errors being thrown around

**Actual results:** <!-- what did you see? -->
The test fails because the hit test for the line `await tester.tap(find.byKey(Key('2')));` fails.

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
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
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
PS C:\Users\basro\Desktop\test\flutter_application_1> flutter analyze
Analyzing flutter_application_1...                                      
No issues found! (ran in 1.0s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
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!
```

</details>