flutter/examples/flutter_gallery/test/pesto_test.dart

61 lines
2.1 KiB
Dart
Raw Normal View History

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() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
2016-08-17 17:38:38 +00:00
if (binding is LiveTestWidgetsFlutterBinding)
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(
// The bug only manifests itself when the screen's orientation is portrait
const Center(
child: const SizedBox(
width: 450.0,
2016-08-17 17:38:38 +00:00
height: 800.0,
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
await tester.tap(find.text('Vignettes'));
await tester.pumpAndSettle();
2016-08-17 17:38:38 +00:00
await tester.tap(find.text('Pesto'));
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'));
await tester.pumpAndSettle();
2016-08-17 17:38:38 +00:00
await tester.drag(find.text('Pesto Bruschetta'), const Offset(0.0, -300.0));
await tester.pumpAndSettle();
2016-08-17 17:38:38 +00:00
Navigator.pop(find.byType(Scaffold).evaluate().single);
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 {
await tester.pumpWidget(const GalleryApp());
2017-02-17 04:44:33 +00:00
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
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'));
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);
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
}