Updated memory_nav_test with FlutterDriver.scrollUntilVisible() (#16009)
diff --git a/examples/flutter_gallery/test_driver/memory_nav_test.dart b/examples/flutter_gallery/test_driver/memory_nav_test.dart
index 6925cee..29390de 100644
--- a/examples/flutter_gallery/test_driver/memory_nav_test.dart
+++ b/examples/flutter_gallery/test_driver/memory_nav_test.dart
@@ -1,10 +1,6 @@
-import 'dart:async';
-
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
-const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
-
void main() {
group('flutter gallery transitions', () {
FlutterDriver driver;
@@ -18,21 +14,16 @@
});
test('navigation', () async {
- final Completer<Null> completer = new Completer<Null>();
- bool scroll = true;
final SerializableFinder menuItem = find.text('Text fields');
- driver.waitFor(menuItem).then<Null>((Null value) async {
- scroll = false;
- for (int i = 0; i < 15; i++) {
- await driver.tap(menuItem);
- await driver.tap(find.byTooltip('Back'));
- }
- completer.complete();
- });
- while (scroll) {
- await driver.scroll(find.text('Flutter Gallery'), 0.0, -500.0, const Duration(milliseconds: 80));
+ await driver.scrollUntilVisible(find.byType('CustomScrollView'), menuItem,
+ dyScroll: -300.0,
+ alignment: 0.5,
+ timeout: const Duration(minutes: 1),
+ );
+ for (int i = 0; i < 15; i++) {
+ await driver.tap(menuItem);
+ await driver.tap(find.byTooltip('Back'));
}
- await completer.future;
- }, timeout: const Timeout(const Duration(minutes: 1)));
+ });
});
}
diff --git a/examples/flutter_gallery/test_driver/scroll_perf_test.dart b/examples/flutter_gallery/test_driver/scroll_perf_test.dart
index d69662e..48368fb 100644
--- a/examples/flutter_gallery/test_driver/scroll_perf_test.dart
+++ b/examples/flutter_gallery/test_driver/scroll_perf_test.dart
@@ -22,9 +22,8 @@
test('measure', () async {
final Timeline timeline = await driver.traceAction(() async {
- // Find the scrollable stock list
- final SerializableFinder stockList = find.byValueKey('Gallery List');
- expect(stockList, isNotNull);
+ final SerializableFinder home = find.byValueKey('Gallery List');
+ expect(home, isNotNull);
await driver.tap(find.text('Vignettes'));
await driver.tap(find.text('Components'));
@@ -34,13 +33,13 @@
// https://github.com/flutter/flutter/issues/3316
// Scroll down
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));
}
// Scroll up
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));
}
});