Unverified Commit 4226bff7 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Updated memory_nav_test with FlutterDriver.scrollUntilVisible() (#16009)

parent c5288c73
import 'dart:async';
import 'package:flutter_driver/flutter_driver.dart'; import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
void main() { void main() {
group('flutter gallery transitions', () { group('flutter gallery transitions', () {
FlutterDriver driver; FlutterDriver driver;
...@@ -18,21 +14,16 @@ void main() { ...@@ -18,21 +14,16 @@ void main() {
}); });
test('navigation', () async { test('navigation', () async {
final Completer<Null> completer = new Completer<Null>();
bool scroll = true;
final SerializableFinder menuItem = find.text('Text fields'); final SerializableFinder menuItem = find.text('Text fields');
driver.waitFor(menuItem).then<Null>((Null value) async { await driver.scrollUntilVisible(find.byType('CustomScrollView'), menuItem,
scroll = false; dyScroll: -300.0,
for (int i = 0; i < 15; i++) { alignment: 0.5,
await driver.tap(menuItem); timeout: const Duration(minutes: 1),
await driver.tap(find.byTooltip('Back')); );
} for (int i = 0; i < 15; i++) {
completer.complete(); await driver.tap(menuItem);
}); await driver.tap(find.byTooltip('Back'));
while (scroll) {
await driver.scroll(find.text('Flutter Gallery'), 0.0, -500.0, const Duration(milliseconds: 80));
} }
await completer.future; });
}, timeout: const Timeout(const Duration(minutes: 1)));
}); });
} }
...@@ -22,9 +22,8 @@ void main() { ...@@ -22,9 +22,8 @@ void main() {
test('measure', () async { test('measure', () async {
final Timeline timeline = await driver.traceAction(() async { final Timeline timeline = await driver.traceAction(() async {
// Find the scrollable stock list final SerializableFinder home = find.byValueKey('Gallery List');
final SerializableFinder stockList = find.byValueKey('Gallery List'); expect(home, isNotNull);
expect(stockList, isNotNull);
await driver.tap(find.text('Vignettes')); await driver.tap(find.text('Vignettes'));
await driver.tap(find.text('Components')); await driver.tap(find.text('Components'));
...@@ -34,13 +33,13 @@ void main() { ...@@ -34,13 +33,13 @@ void main() {
// https://github.com/flutter/flutter/issues/3316 // https://github.com/flutter/flutter/issues/3316
// Scroll down // Scroll down
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
await driver.scroll(stockList, 0.0, -300.0, const Duration(milliseconds: 300)); await driver.scroll(home, 0.0, -300.0, const Duration(milliseconds: 300));
await new Future<Null>.delayed(const Duration(milliseconds: 500)); await new Future<Null>.delayed(const Duration(milliseconds: 500));
} }
// Scroll up // Scroll up
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
await driver.scroll(stockList, 0.0, 300.0, const Duration(milliseconds: 300)); await driver.scroll(home, 0.0, 300.0, const Duration(milliseconds: 300));
await new Future<Null>.delayed(const Duration(milliseconds: 500)); await new Future<Null>.delayed(const Duration(milliseconds: 500));
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment