Commit 36c63e70 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Align the flutter_gallery test to the middle for better results (#8015)

parent 4f05643c
......@@ -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<String> demoCategories = <String>[
'Demos',
'Components',
'Style'
];
// Warning: this list must be kept in sync with the value of
// kAllGalleryItems.map((GalleryItem item) => item.title).toList();
final List<String> demoTitles = <String>[
......@@ -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<Null>.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<Null>.delayed(kWaitBetweenActions);
for(int i = 0; i < 2; i += 1) {
......
......@@ -357,8 +357,8 @@ class FlutterDriver {
/// Scrolls the Scrollable ancestor of the widget located by [finder]
/// until the widget is completely visible.
Future<Null> scrollIntoView(SerializableFinder finder) async {
return await _sendCommand(new ScrollIntoView(finder)).then((Map<String, dynamic> _) => null);
Future<Null> scrollIntoView(SerializableFinder finder, { double alignment: 0.0 }) async {
return await _sendCommand(new ScrollIntoView(finder, alignment: alignment)).then((Map<String, dynamic> _) => null);
}
/// Returns the text in the `Text` widget located by [finder].
......
......@@ -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();
}
......
......@@ -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<String, String> 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<String, String> serialize() => super.serialize();
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
'alignment': '$alignment',
});
}
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