Commit b5a47d71 authored by Yegor's avatar Yegor Committed by GitHub

driver: fix covariant closures; make them private (#5782)

parent 4d80f3cb
...@@ -60,14 +60,14 @@ class FlutterDriverExtension { ...@@ -60,14 +60,14 @@ class FlutterDriverExtension {
FlutterDriverExtension() { FlutterDriverExtension() {
_commandHandlers.addAll(<String, CommandHandlerCallback>{ _commandHandlers.addAll(<String, CommandHandlerCallback>{
'get_health': getHealth, // ignore: map_value_type_not_assignable, #5771 'get_health': _getHealth,
'tap': tap, // ignore: map_value_type_not_assignable, #5771 'tap': _tap,
'get_text': getText, // ignore: map_value_type_not_assignable, #5771 'get_text': _getText,
'scroll': scroll, // ignore: map_value_type_not_assignable, #5771 'scroll': _scroll,
'scrollIntoView': scrollIntoView, // ignore: map_value_type_not_assignable, #5771 'scrollIntoView': _scrollIntoView,
'setInputText': _setInputText, // ignore: map_value_type_not_assignable, #5771 'setInputText': _setInputText,
'submitInputText': _submitInputText, // ignore: map_value_type_not_assignable, #5771 'submitInputText': _submitInputText,
'waitFor': waitFor, // ignore: map_value_type_not_assignable, #5771 'waitFor': _waitFor,
}); });
_commandDeserializers.addAll(<String, CommandDeserializerCallback>{ _commandDeserializers.addAll(<String, CommandDeserializerCallback>{
...@@ -123,7 +123,7 @@ class FlutterDriverExtension { ...@@ -123,7 +123,7 @@ class FlutterDriverExtension {
return _onFrameReadyStream; return _onFrameReadyStream;
} }
Future<Health> getHealth(GetHealth command) async => new Health(HealthStatus.ok); Future<Health> _getHealth(Command command) async => new Health(HealthStatus.ok);
/// Runs `finder` repeatedly until it finds one or more [Element]s, or times out. /// Runs `finder` repeatedly until it finds one or more [Element]s, or times out.
/// ///
...@@ -179,23 +179,26 @@ class FlutterDriverExtension { ...@@ -179,23 +179,26 @@ class FlutterDriverExtension {
return constructor(finder); return constructor(finder);
} }
Future<TapResult> tap(Tap command) async { Future<TapResult> _tap(Command command) async {
prober.tap(await _waitForElement(_createFinder(command.finder))); Tap tapCommand = command;
prober.tap(await _waitForElement(_createFinder(tapCommand.finder)));
return new TapResult(); return new TapResult();
} }
Future<WaitForResult> waitFor(WaitFor command) async { Future<WaitForResult> _waitFor(Command command) async {
if ((await _waitForElement(_createFinder(command.finder))).evaluate().isNotEmpty) WaitFor waitForCommand = command;
if ((await _waitForElement(_createFinder(waitForCommand.finder))).evaluate().isNotEmpty)
return new WaitForResult(); return new WaitForResult();
else else
return null; return null;
} }
Future<ScrollResult> scroll(Scroll command) async { Future<ScrollResult> _scroll(Command command) async {
Finder target = await _waitForElement(_createFinder(command.finder)); Scroll scrollCommand = command;
final int totalMoves = command.duration.inMicroseconds * command.frequency ~/ Duration.MICROSECONDS_PER_SECOND; Finder target = await _waitForElement(_createFinder(scrollCommand.finder));
Offset delta = new Offset(command.dx, command.dy) / totalMoves.toDouble(); final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.MICROSECONDS_PER_SECOND;
Duration pause = command.duration ~/ totalMoves; Offset delta = new Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble();
Duration pause = scrollCommand.duration ~/ totalMoves;
Point startLocation = prober.getCenter(target); Point startLocation = prober.getCenter(target);
Point currentLocation = startLocation; Point currentLocation = startLocation;
TestPointer pointer = new TestPointer(1); TestPointer pointer = new TestPointer(1);
...@@ -214,28 +217,32 @@ class FlutterDriverExtension { ...@@ -214,28 +217,32 @@ class FlutterDriverExtension {
return new ScrollResult(); return new ScrollResult();
} }
Future<ScrollResult> scrollIntoView(ScrollIntoView command) async { Future<ScrollResult> _scrollIntoView(Command command) async {
Finder target = await _waitForElement(_createFinder(command.finder)); ScrollIntoView scrollIntoViewCommand = command;
Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder));
await Scrollable.ensureVisible(target.evaluate().single); await Scrollable.ensureVisible(target.evaluate().single);
return new ScrollResult(); return new ScrollResult();
} }
Future<SetInputTextResult> _setInputText(SetInputText command) async { Future<SetInputTextResult> _setInputText(Command command) async {
Finder target = await _waitForElement(_createFinder(command.finder)); SetInputText setInputTextCommand = command;
Finder target = await _waitForElement(_createFinder(setInputTextCommand.finder));
Input input = target.evaluate().single.widget; Input input = target.evaluate().single.widget;
input.onChanged(new InputValue(text: command.text)); input.onChanged(new InputValue(text: setInputTextCommand.text));
return new SetInputTextResult(); return new SetInputTextResult();
} }
Future<SubmitInputTextResult> _submitInputText(SubmitInputText command) async { Future<SubmitInputTextResult> _submitInputText(Command command) async {
Finder target = await _waitForElement(_createFinder(command.finder)); SubmitInputText submitInputTextCommand = command;
Finder target = await _waitForElement(_createFinder(submitInputTextCommand.finder));
Input input = target.evaluate().single.widget; Input input = target.evaluate().single.widget;
input.onSubmitted(input.value); input.onSubmitted(input.value);
return new SubmitInputTextResult(input.value.text); return new SubmitInputTextResult(input.value.text);
} }
Future<GetTextResult> getText(GetText command) async { Future<GetTextResult> _getText(Command command) async {
Finder target = await _waitForElement(_createFinder(command.finder)); GetText getTextCommand = command;
Finder target = await _waitForElement(_createFinder(getTextCommand.finder));
// TODO(yjbanov): support more ways to read text // TODO(yjbanov): support more ways to read text
Text text = target.evaluate().single.widget; Text text = target.evaluate().single.widget;
return new GetTextResult(text.data); return new GetTextResult(text.data);
......
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