Repository: flutter
Issue: Widget testing is failed when tapping outside of the display area
Labels: a: tests,framework,f: gestures,has reproducible steps,P2,found in release: 3.3,found in release: 3.6,team-framework,triaged-framework

<!-- 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 our the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!--
     Please tell us exactly how to reproduce the problem you are running into.

     Please attach a small application (ideally just one main.dart file) that
     reproduces the problem. You could use https://gist.github.com/ for this.

     If the problem is with your application's rendering, then please attach
     a screenshot and explain what the problem is.
-->

This test will be failed without scroll the scroll view and displaying the button before `tester.tap`. `Finder` finds the button but `onPressed` event is not happened.

`Finder` finds widgets from tree of widgets and NOT depends on display state, but `tester.tap` depends on display state.

Currently, it is difficult to know why `onPressed` event is not happened, because `Finder` finds the button successfully.

``` dart
// main.dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: TestPage(),
    );
  }
}

class TestPage extends StatefulWidget {
  static const scrollViewKey = Key('scrollView');
  static const buttonKey = Key('button');

  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        key: TestPage.scrollViewKey,
        child: Column(
          children: <Widget>[
            // Push out [Text] and [RaisedButton] with a long widget.
            SizedBox(height: 800),
            Text(count.toString()),
            RaisedButton(
              key: TestPage.buttonKey,
              onPressed: () {
                setState(() {
                  count = 1;
                });
              },
            )
          ],
        ),
      ),
    );
  }
}
```

``` dart
// widget_test.dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:scrollview_issue_example/main.dart';

void main() {
  testWidgets('out of display test', (WidgetTester tester) async {
    await tester.pumpWidget(MyApp());

    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // This test will be failed without dragging.
    // await tester.drag(
    //  find.byKey(TestPage.scrollViewKey),
    //  const Offset(0.0, -300),
    // );
    // await tester.pump();

    await tester.tap(find.byKey(TestPage.buttonKey));
    await tester.pump();

    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });
}
```


<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
$ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.5 18F203, locale ja-JP)
    • Flutter version 1.12.13+hotfix.5 at /Users/hiroki_matsue/work/flutter/flutter
    • Framework revision 27321ebbad (4 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

...

• No issues found!
```