pesto_test.dart 2.13 KB
Newer Older
Hans Muller's avatar
Hans Muller committed
1 2 3 4 5 6
// 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';
7
import 'package:flutter_gallery/gallery/app.dart';
Hans Muller's avatar
Hans Muller committed
8 9

void main() {
10
  final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
11
  if (binding is LiveTestWidgetsFlutterBinding)
12
    binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
Hans Muller's avatar
Hans Muller committed
13

14 15 16
  // Regression test for https://github.com/flutter/flutter/pull/5168
  testWidgets('Pesto appbar heroics', (WidgetTester tester) async {
    await tester.pumpWidget(
17
      // The bug only manifests itself when the screen's orientation is portrait
18
      const Center(
19
        child: SizedBox(
20
          width: 450.0,
21
          height: 800.0,
22 23
          child: GalleryApp(testMode: true),
        ),
24 25 26 27 28
      )
    );
    await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
    await tester.pump(); // triggers a frame

29
    await tester.tap(find.text('Studies'));
30 31
    await tester.pumpAndSettle();

32
    await tester.tap(find.text('Pesto'));
33
    await tester.pumpAndSettle();
34

35
    await tester.tap(find.text('Roasted Chicken'));
36
    await tester.pumpAndSettle();
37

38
    await tester.drag(find.text('Roasted Chicken'), const Offset(0.0, -300.0));
39
    await tester.pumpAndSettle();
40 41

    Navigator.pop(find.byType(Scaffold).evaluate().single);
42
    await tester.pumpAndSettle();
43
  });
Ian Hickson's avatar
Ian Hickson committed
44 45

  testWidgets('Pesto can be scrolled all the way down', (WidgetTester tester) async {
46
    await tester.pumpWidget(const GalleryApp(testMode: true));
Ian Hickson's avatar
Ian Hickson committed
47
    await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
48 49
    await tester.pump(); // triggers a frame

50
    await tester.tap(find.text('Studies'));
51
    await tester.pumpAndSettle();
Ian Hickson's avatar
Ian Hickson committed
52 53

    await tester.tap(find.text('Pesto'));
54
    await tester.pumpAndSettle();
Ian Hickson's avatar
Ian Hickson committed
55

56
    await tester.fling(find.text('Roasted Chicken'), const Offset(0.0, -200.0), 10000.0);
57
    await tester.pumpAndSettle(); // start and finish fling
58
    expect(find.text('Spanakopita'), findsOneWidget);
Ian Hickson's avatar
Ian Hickson committed
59
  });
Hans Muller's avatar
Hans Muller committed
60
}