Align the flutter_gallery test to the middle for better results (#8015)
This commit is contained in:
@@ -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',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user