main_test.dart 2.15 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_driver/flutter_driver.dart';
6
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
7 8

Future<void> main() async {
9
  FlutterDriver driver;
10

11 12 13 14 15 16
  setUpAll(() async {
    driver = await FlutterDriver.connect();
  });

  tearDownAll(() {
    driver.close();
17 18
  });

Chris Yang's avatar
Chris Yang committed
19 20
  // Each test below must return back to the home page after finishing.

21 22 23 24 25 26 27
  test('MotionEvent recomposition', () async {
    final SerializableFinder motionEventsListTile =
    find.byValueKey('MotionEventsListTile');
    await driver.tap(motionEventsListTile);
    await driver.waitFor(find.byValueKey('PlatformView'));
    final String errorMessage = await driver.requestData('run test');
    expect(errorMessage, '');
Chris Yang's avatar
Chris Yang committed
28 29 30
    final SerializableFinder backButton = find.byValueKey('back');
    await driver.tap(backButton);
  });
31

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  group('WindowManager', ()
  {
    setUpAll(() async {
      final SerializableFinder wmListTile =
      find.byValueKey('WmIntegrationsListTile');
      await driver.tap(wmListTile);
    });

    tearDownAll(() async {
      await driver.waitFor(find.pageBack());
      await driver.tap(find.pageBack());
    });

    test('AlertDialog from platform view context', () async {
      final SerializableFinder showAlertDialog = find.byValueKey(
          'ShowAlertDialog');
      await driver.waitFor(showAlertDialog);
      await driver.tap(showAlertDialog);
      final String status = await driver.getText(find.byValueKey('Status'));
      expect(status, 'Success');
    });

    test('Child windows can handle touches', () async {
      final SerializableFinder addWindow = find.byValueKey('AddWindow');
      await driver.waitFor(addWindow);
      await driver.tap(addWindow);
      final SerializableFinder tapWindow = find.byValueKey('TapWindow');
      await driver.tap(tapWindow);
60 61 62 63
      final String windowClickCount = await driver.getText(
        find.byValueKey('WindowClickCount'),
        timeout: const Duration(seconds: 5),
      );
64
      expect(windowClickCount, 'Click count: 1');
65
    });
66
  });
67
}