memory_nav_test.dart 1.34 KB
Newer Older
1 2 3 4 5
import 'dart:async';

import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

6 7
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);

8 9 10 11 12 13 14 15 16 17 18 19 20
void main() {
  group('flutter gallery transitions', () {
    FlutterDriver driver;
    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    tearDownAll(() async {
      if (driver != null)
        await driver.close();
    });

    test('navigation', () async {
21
      final Completer<Null> completer = new Completer<Null>();
22
      bool scroll = true;
23
      final SerializableFinder menuItem = find.text('Text fields');
24 25
      driver.waitFor(menuItem).then<Null>((Null value) async {
        scroll = false;
26
        await new Future<Null>.delayed(kWaitBetweenActions);
27 28 29 30 31 32 33 34 35 36
        for (int i = 0; i < 15; i++) {
          await driver.tap(menuItem);
          await new Future<Null>.delayed(kWaitBetweenActions);
          await driver.tap(find.byTooltip('Back'));
          await new Future<Null>.delayed(kWaitBetweenActions);
        }
        completer.complete();
      });
      while (scroll) {
        await driver.scroll(find.text('Flutter Gallery'), 0.0, -500.0, const Duration(milliseconds: 80));
37
        await new Future<Null>.delayed(kWaitBetweenActions);
38
      }
39
      await completer.future;
40
    }, timeout: const Timeout(const Duration(minutes: 1)));
41 42
  });
}