Fix Pesto appbar heroics (#5447)

This commit is contained in:
Hans Muller
2016-08-17 10:38:38 -07:00
committed by GitHub
parent ade895de4a
commit 96ec30b8af
2 changed files with 43 additions and 17 deletions

View File

@@ -4,7 +4,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_gallery/main.dart' as flutter_gallery_main;
import 'package:flutter_gallery/gallery/app.dart';
Finder byTooltip(WidgetTester tester, String message) {
return find.byWidgetPredicate((Widget widget) {
@@ -17,14 +17,13 @@ Finder findNavigationMenuButton(WidgetTester tester) {
}
void main() {
TestWidgetsFlutterBinding binding =
TestWidgetsFlutterBinding.ensureInitialized();
if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true;
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
if (binding is LiveTestWidgetsFlutterBinding)
binding.allowAllFrames = true;
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets('Pesto route management', (WidgetTester tester) async {
flutter_gallery_main
.main(); // builds the app and schedules a frame but doesn't trigger one
await tester.pumpWidget(new GalleryApp());
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame
@@ -52,4 +51,35 @@ void main() {
expect(find.text('Flutter Gallery'), findsOneWidget);
});
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets('Pesto appbar heroics', (WidgetTester tester) async {
await tester.pumpWidget(
// The bug only manifests itself when the screen's orientation is portait
new Center(
child: new SizedBox(
width: 400.0,
height: 800.0,
child: new GalleryApp()
)
)
);
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame
await tester.tap(find.text('Pesto'));
await tester.pump(); // Launch pesto
await tester.pump(const Duration(seconds: 1)); // transition is complete
await tester.tap(find.text('Pesto Bruchetta'));
await tester.pump(); // Launch the recipe page
await tester.pump(const Duration(seconds: 1)); // transition is complete
await tester.scroll(find.text('Pesto Bruchetta'), const Offset(0.0, -300.0));
await tester.pump();
Navigator.pop(find.byType(Scaffold).evaluate().single);
await tester.pump();
await tester.pump(const Duration(seconds: 1)); // transition is complete
});
}