main_test.dart 2.31 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
  late 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
  test('MotionEvent recomposition', () async {
    final SerializableFinder motionEventsListTile =
    find.byValueKey('MotionEventsListTile');
    await driver.tap(motionEventsListTile);
25 26 27
    await driver.runUnsynchronized(() async {
      driver.waitFor(find.byValueKey('PlatformView'));
    });
28 29
    final String errorMessage = await driver.requestData('run test');
    expect(errorMessage, '');
Chris Yang's avatar
Chris Yang committed
30 31
    final SerializableFinder backButton = find.byValueKey('back');
    await driver.tap(backButton);
32
  }, timeout: Timeout.none);
33

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  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');
54
    }, timeout: Timeout.none);
55 56 57 58 59 60 61

    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);
62 63 64
      final String windowClickCount = await driver.getText(
        find.byValueKey('WindowClickCount'),
      );
65
      expect(windowClickCount, 'Click count: 1');
66
    }, timeout: Timeout.none, skip: true); // TODO(garyq): Skipped, see https://github.com/flutter/flutter/issues/88479
67
  });
68
}