Commit ea7d5bf2 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

When a list is scrolling, children can't be tapped (#5222)

parent 260cfcdb
...@@ -43,8 +43,9 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async { ...@@ -43,8 +43,9 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
await tester.tap(menuItem); await tester.tap(menuItem);
await tester.pump(); // Launch the demo. await tester.pump(); // Launch the demo.
await tester await tester.pump(const Duration(seconds: 1)); // Wait until the demo has opened.
.pump(const Duration(seconds: 1)); // Wait until the demo has opened.
expect(find.text('Flutter Gallery'), findsNothing);
// Go back // Go back
if (routeName == '/pesto') { if (routeName == '/pesto') {
...@@ -64,9 +65,9 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async { ...@@ -64,9 +65,9 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
} }
void main() { void main() {
TestWidgetsFlutterBinding binding = // TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
TestWidgetsFlutterBinding.ensureInitialized(); // if (binding is LiveTestWidgetsFlutterBinding)
if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true; // binding.allowAllFrames = true;
testWidgets('Flutter Gallery app smoke test', (WidgetTester tester) async { testWidgets('Flutter Gallery app smoke test', (WidgetTester tester) async {
flutter_gallery_main flutter_gallery_main
...@@ -87,15 +88,17 @@ void main() { ...@@ -87,15 +88,17 @@ void main() {
final String routeName = routeNames[i]; final String routeName = routeNames[i];
await smokeDemo(tester, routeName); await smokeDemo(tester, routeName);
await tester.scroll(findGalleryItemByRouteName(tester, routeName), new Offset(0.0, scrollDeltas[i])); await tester.scroll(findGalleryItemByRouteName(tester, routeName), new Offset(0.0, scrollDeltas[i]));
await tester.pump(); await tester.pump(); // start the scroll
await tester.pump(const Duration(milliseconds: 500)); // wait for overscroll to timeout, if necessary
await tester.pump(const Duration(milliseconds: 2000)); // wait for overscroll to fade away, if necessary
tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after leaving route $routeName');
} }
Finder navigationMenuButton = findNavigationMenuButton(tester); Finder navigationMenuButton = findNavigationMenuButton(tester);
expect(navigationMenuButton, findsOneWidget); expect(navigationMenuButton, findsOneWidget);
await tester.tap(navigationMenuButton); await tester.tap(navigationMenuButton);
await tester.pump(); // Start opening drawer. await tester.pump(); // Start opening drawer.
await tester await tester.pump(const Duration(seconds: 1)); // Wait until it's really opened.
.pump(const Duration(seconds: 1)); // Wait until it's really opened.
// switch theme // switch theme
await tester.tap(find.text('Dark')); await tester.tap(find.text('Dark'));
......
...@@ -652,7 +652,10 @@ class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -652,7 +652,10 @@ class ScrollableState<T extends Scrollable> extends State<T> {
key: _gestureDetectorKey, key: _gestureDetectorKey,
gestures: buildGestureDetectors(), gestures: buildGestureDetectors(),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: buildContent(context) child: new IgnorePointer(
ignoring: _controller.isAnimating,
child: buildContent(context)
)
); );
} }
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
void main() {
testWidgets('fling and tap', (WidgetTester tester) async {
List<String> log = <String>[];
List<Widget> textWidgets = <Widget>[];
for (int i = 0; i < 250; i++)
textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i')));
await tester.pumpWidget(new Block(children: textWidgets));
expect(log, equals(<String>[]));
await tester.tap(find.byType(Scrollable));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.fling(find.byType(Scrollable), new Offset(0.0, -200.0), 1000.0);
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.tap(find.byType(Scrollable));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment