From b5a47d71cb2d74a1eeba5b8b391282259b42fa91 Mon Sep 17 00:00:00 2001 From: Yegor Date: Fri, 9 Sep 2016 10:34:55 -0700 Subject: [PATCH] driver: fix covariant closures; make them private (#5782) --- .../flutter_driver/lib/src/extension.dart | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/packages/flutter_driver/lib/src/extension.dart b/packages/flutter_driver/lib/src/extension.dart index bc5ebbb9b8..80bc827423 100644 --- a/packages/flutter_driver/lib/src/extension.dart +++ b/packages/flutter_driver/lib/src/extension.dart @@ -60,14 +60,14 @@ class FlutterDriverExtension { FlutterDriverExtension() { _commandHandlers.addAll({ - 'get_health': getHealth, // ignore: map_value_type_not_assignable, #5771 - 'tap': tap, // ignore: map_value_type_not_assignable, #5771 - 'get_text': getText, // ignore: map_value_type_not_assignable, #5771 - 'scroll': scroll, // ignore: map_value_type_not_assignable, #5771 - 'scrollIntoView': scrollIntoView, // ignore: map_value_type_not_assignable, #5771 - 'setInputText': _setInputText, // ignore: map_value_type_not_assignable, #5771 - 'submitInputText': _submitInputText, // ignore: map_value_type_not_assignable, #5771 - 'waitFor': waitFor, // ignore: map_value_type_not_assignable, #5771 + 'get_health': _getHealth, + 'tap': _tap, + 'get_text': _getText, + 'scroll': _scroll, + 'scrollIntoView': _scrollIntoView, + 'setInputText': _setInputText, + 'submitInputText': _submitInputText, + 'waitFor': _waitFor, }); _commandDeserializers.addAll({ @@ -123,7 +123,7 @@ class FlutterDriverExtension { return _onFrameReadyStream; } - Future getHealth(GetHealth command) async => new Health(HealthStatus.ok); + Future _getHealth(Command command) async => new Health(HealthStatus.ok); /// Runs `finder` repeatedly until it finds one or more [Element]s, or times out. /// @@ -179,23 +179,26 @@ class FlutterDriverExtension { return constructor(finder); } - Future tap(Tap command) async { - prober.tap(await _waitForElement(_createFinder(command.finder))); + Future _tap(Command command) async { + Tap tapCommand = command; + prober.tap(await _waitForElement(_createFinder(tapCommand.finder))); return new TapResult(); } - Future waitFor(WaitFor command) async { - if ((await _waitForElement(_createFinder(command.finder))).evaluate().isNotEmpty) + Future _waitFor(Command command) async { + WaitFor waitForCommand = command; + if ((await _waitForElement(_createFinder(waitForCommand.finder))).evaluate().isNotEmpty) return new WaitForResult(); else return null; } - Future scroll(Scroll command) async { - Finder target = await _waitForElement(_createFinder(command.finder)); - final int totalMoves = command.duration.inMicroseconds * command.frequency ~/ Duration.MICROSECONDS_PER_SECOND; - Offset delta = new Offset(command.dx, command.dy) / totalMoves.toDouble(); - Duration pause = command.duration ~/ totalMoves; + Future _scroll(Command command) async { + Scroll scrollCommand = command; + Finder target = await _waitForElement(_createFinder(scrollCommand.finder)); + final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.MICROSECONDS_PER_SECOND; + Offset delta = new Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble(); + Duration pause = scrollCommand.duration ~/ totalMoves; Point startLocation = prober.getCenter(target); Point currentLocation = startLocation; TestPointer pointer = new TestPointer(1); @@ -214,28 +217,32 @@ class FlutterDriverExtension { return new ScrollResult(); } - Future scrollIntoView(ScrollIntoView command) async { - Finder target = await _waitForElement(_createFinder(command.finder)); + Future _scrollIntoView(Command command) async { + ScrollIntoView scrollIntoViewCommand = command; + Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder)); await Scrollable.ensureVisible(target.evaluate().single); return new ScrollResult(); } - Future _setInputText(SetInputText command) async { - Finder target = await _waitForElement(_createFinder(command.finder)); + Future _setInputText(Command command) async { + SetInputText setInputTextCommand = command; + Finder target = await _waitForElement(_createFinder(setInputTextCommand.finder)); Input input = target.evaluate().single.widget; - input.onChanged(new InputValue(text: command.text)); + input.onChanged(new InputValue(text: setInputTextCommand.text)); return new SetInputTextResult(); } - Future _submitInputText(SubmitInputText command) async { - Finder target = await _waitForElement(_createFinder(command.finder)); + Future _submitInputText(Command command) async { + SubmitInputText submitInputTextCommand = command; + Finder target = await _waitForElement(_createFinder(submitInputTextCommand.finder)); Input input = target.evaluate().single.widget; input.onSubmitted(input.value); return new SubmitInputTextResult(input.value.text); } - Future getText(GetText command) async { - Finder target = await _waitForElement(_createFinder(command.finder)); + Future _getText(Command command) async { + GetText getTextCommand = command; + Finder target = await _waitForElement(_createFinder(getTextCommand.finder)); // TODO(yjbanov): support more ways to read text Text text = target.evaluate().single.widget; return new GetTextResult(text.data);