pesto_test.dart 2.13 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Hans Muller's avatar
Hans Muller committed
2 3 4 5
// 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';
6
import 'package:flutter_gallery/gallery/app.dart';
7
import 'package:flutter_test/flutter_test.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;
13
  }
Hans Muller's avatar
Hans Muller committed
14

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

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

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

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

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

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

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

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

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

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