diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index adfe94569c..ccb2171262 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -11,14 +11,6 @@ import 'package:flutter_driver/flutter_driver.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; -// Warning: this list must be kept in sync with the value of -// kAllGalleryItems.map((GalleryItem item) => item.category)).toList(); -final List demoCategories = [ - 'Demos', - 'Components', - 'Style' -]; - // Warning: this list must be kept in sync with the value of // kAllGalleryItems.map((GalleryItem item) => item.title).toList(); final List demoTitles = [ @@ -148,17 +140,12 @@ void main() { test('all demos', () async { Timeline timeline = await driver.traceAction(() async { - // Expand the demo category submenus. - for (String category in demoCategories.reversed) { - await driver.tap(find.text(category)); - await new Future.delayed(kWaitBetweenActions); - } // Scroll each demo menu item into view, launch the demo and // return to the demo menu 2x. for(String demoTitle in demoTitles) { print('Testing "$demoTitle" demo'); SerializableFinder menuItem = find.text(demoTitle); - await driver.scrollIntoView(menuItem); + await driver.scrollIntoView(menuItem, alignment: 0.5); await new Future.delayed(kWaitBetweenActions); for(int i = 0; i < 2; i += 1) { diff --git a/packages/flutter_driver/lib/src/driver.dart b/packages/flutter_driver/lib/src/driver.dart index a283e7ca16..204475c72f 100644 --- a/packages/flutter_driver/lib/src/driver.dart +++ b/packages/flutter_driver/lib/src/driver.dart @@ -357,8 +357,8 @@ class FlutterDriver { /// Scrolls the Scrollable ancestor of the widget located by [finder] /// until the widget is completely visible. - Future scrollIntoView(SerializableFinder finder) async { - return await _sendCommand(new ScrollIntoView(finder)).then((Map _) => null); + Future scrollIntoView(SerializableFinder finder, { double alignment: 0.0 }) async { + return await _sendCommand(new ScrollIntoView(finder, alignment: alignment)).then((Map _) => null); } /// Returns the text in the `Text` widget located by [finder]. diff --git a/packages/flutter_driver/lib/src/extension.dart b/packages/flutter_driver/lib/src/extension.dart index 225b6513ed..309d2c7df9 100644 --- a/packages/flutter_driver/lib/src/extension.dart +++ b/packages/flutter_driver/lib/src/extension.dart @@ -249,7 +249,7 @@ class _FlutterDriverExtension { ScrollIntoView scrollIntoViewCommand = command; Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder)); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100)); - await Scrollable2.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100)); + await Scrollable2.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0); return new ScrollResult(); } diff --git a/packages/flutter_driver/lib/src/gesture.dart b/packages/flutter_driver/lib/src/gesture.dart index 04a83050f9..4e0e7ec93a 100644 --- a/packages/flutter_driver/lib/src/gesture.dart +++ b/packages/flutter_driver/lib/src/gesture.dart @@ -95,14 +95,17 @@ class ScrollIntoView extends CommandWithTarget { /// Creates this command given a [finder] used to locate the widget to be /// scrolled into view. - ScrollIntoView(SerializableFinder finder) : super(finder); + ScrollIntoView(SerializableFinder finder, { this.alignment: 0.0 }) : super(finder); /// Deserializes this command from JSON generated by [serialize]. ScrollIntoView.deserialize(Map json) - : super.deserialize(json); + : this.alignment = double.parse(json['alignment']), + super.deserialize(json); + + final double alignment; - // This is here just to be clear that this command isn't adding any extra - // fields. @override - Map serialize() => super.serialize(); + Map serialize() => super.serialize()..addAll({ + 'alignment': '$alignment', + }); }