smoke_test.dart 1.29 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
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/demo/calculator_demo.dart';
7 8 9
import 'package:flutter_test/flutter_test.dart';

void main() {
10
  final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
11
  if (binding is LiveTestWidgetsFlutterBinding) {
12
    binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
13
  }
14 15 16

  // We press the "1" and the "2" buttons and check that the display
  // reads "12".
17
  testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async {
18
    await tester.pumpWidget(const MaterialApp(home: CalculatorDemo()));
19

20
    final Finder oneButton = find.widgetWithText(InkResponse, '1');
21 22
    expect(oneButton, findsOneWidget);

23
    final Finder twoButton = find.widgetWithText(InkResponse, '2');
24 25 26 27 28 29 30 31
    expect(twoButton, findsOneWidget);

    await tester.tap(oneButton);
    await tester.pump();
    await tester.tap(twoButton);
    await tester.pump();
    await tester.pump(const Duration(seconds: 1)); // Wait until it has finished.

32
    final Finder display = find.widgetWithText(Expanded, '12');
33 34 35
    expect(display, findsOneWidget);
  });
}