2016-08-01 22:09:50 +00:00
|
|
|
// 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/material.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2016-08-17 17:38:38 +00:00
|
|
|
import 'package:flutter_gallery/gallery/app.dart';
|
2016-08-01 22:09:50 +00:00
|
|
|
|
|
|
|
void main() {
|
2017-03-04 01:51:21 +00:00
|
|
|
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
2016-08-17 17:38:38 +00:00
|
|
|
if (binding is LiveTestWidgetsFlutterBinding)
|
2017-04-12 20:33:02 +00:00
|
|
|
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
2016-08-01 22:09:50 +00:00
|
|
|
|
2016-08-17 17:38:38 +00:00
|
|
|
// Regression test for https://github.com/flutter/flutter/pull/5168
|
|
|
|
testWidgets('Pesto appbar heroics', (WidgetTester tester) async {
|
|
|
|
await tester.pumpWidget(
|
2016-08-29 17:05:22 +00:00
|
|
|
// The bug only manifests itself when the screen's orientation is portrait
|
2017-04-21 21:09:42 +00:00
|
|
|
const Center(
|
|
|
|
child: const SizedBox(
|
2018-04-25 21:15:34 +00:00
|
|
|
width: 450.0,
|
2016-08-17 17:38:38 +00:00
|
|
|
height: 800.0,
|
2017-04-21 21:09:42 +00:00
|
|
|
child: const GalleryApp()
|
2016-08-17 17:38:38 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
|
|
|
await tester.pump(); // triggers a frame
|
|
|
|
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.tap(find.text('Vignettes'));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
2016-08-17 17:38:38 +00:00
|
|
|
await tester.tap(find.text('Pesto'));
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pumpAndSettle();
|
2016-08-17 17:38:38 +00:00
|
|
|
|
2016-10-27 21:18:12 +00:00
|
|
|
await tester.tap(find.text('Pesto Bruschetta'));
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pumpAndSettle();
|
2016-08-17 17:38:38 +00:00
|
|
|
|
2017-03-13 23:27:15 +00:00
|
|
|
await tester.drag(find.text('Pesto Bruschetta'), const Offset(0.0, -300.0));
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pumpAndSettle();
|
2016-08-17 17:38:38 +00:00
|
|
|
|
|
|
|
Navigator.pop(find.byType(Scaffold).evaluate().single);
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pumpAndSettle();
|
2016-08-17 17:38:38 +00:00
|
|
|
});
|
2017-02-17 04:44:33 +00:00
|
|
|
|
|
|
|
testWidgets('Pesto can be scrolled all the way down', (WidgetTester tester) async {
|
2017-04-21 21:09:42 +00:00
|
|
|
await tester.pumpWidget(const GalleryApp());
|
2017-02-17 04:44:33 +00:00
|
|
|
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pump(); // triggers a frame
|
|
|
|
|
|
|
|
await tester.tap(find.text('Vignettes'));
|
|
|
|
await tester.pumpAndSettle();
|
2017-02-17 04:44:33 +00:00
|
|
|
|
|
|
|
await tester.tap(find.text('Pesto'));
|
2018-04-25 21:15:34 +00:00
|
|
|
await tester.pumpAndSettle();
|
2017-02-17 04:44:33 +00:00
|
|
|
|
|
|
|
await tester.fling(find.text('Pesto Bruschetta'), const Offset(0.0, -200.0), 10000.0);
|
2017-03-13 23:27:15 +00:00
|
|
|
await tester.pumpAndSettle(); // start and finish fling
|
2017-02-17 04:44:33 +00:00
|
|
|
expect(find.text('Sicilian-Style sardines'), findsOneWidget);
|
|
|
|
});
|
2016-08-01 22:09:50 +00:00
|
|
|
}
|