Unverified Commit 4956bcc2 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false in flutter_driver (#45175)

* implicit-casts:false in flutter_driver

* address review comments
parent a5f9b3b0
# Override the parent analysis_options until all the repo has implicit-casts: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
...@@ -33,7 +33,7 @@ class GetDiagnosticsTree extends CommandWithTarget { ...@@ -33,7 +33,7 @@ class GetDiagnosticsTree extends CommandWithTarget {
super(finder, timeout: timeout); super(finder, timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
GetDiagnosticsTree.deserialize(Map<String, dynamic> json) GetDiagnosticsTree.deserialize(Map<String, String> json)
: subtreeDepth = int.parse(json['subtreeDepth']), : subtreeDepth = int.parse(json['subtreeDepth']),
includeProperties = json['includeProperties'] == 'true', includeProperties = json['includeProperties'] == 'true',
diagnosticsType = _diagnosticsTypeIndex.lookupBySimpleName(json['diagnosticsType']), diagnosticsType = _diagnosticsTypeIndex.lookupBySimpleName(json['diagnosticsType']),
......
...@@ -185,14 +185,14 @@ class BySemanticsLabel extends SerializableFinder { ...@@ -185,14 +185,14 @@ class BySemanticsLabel extends SerializableFinder {
@override @override
Map<String, String> serialize() { Map<String, String> serialize() {
if (label is RegExp) { if (label is RegExp) {
final RegExp regExp = label; final RegExp regExp = label as RegExp;
return super.serialize()..addAll(<String, String>{ return super.serialize()..addAll(<String, String>{
'label': regExp.pattern, 'label': regExp.pattern,
'isRegExp': 'true', 'isRegExp': 'true',
}); });
} else { } else {
return super.serialize()..addAll(<String, String>{ return super.serialize()..addAll(<String, String>{
'label': label, 'label': label as String,
}); });
} }
} }
...@@ -351,9 +351,9 @@ class Descendant extends SerializableFinder { ...@@ -351,9 +351,9 @@ class Descendant extends SerializableFinder {
/// Deserializes the finder from JSON generated by [serialize]. /// Deserializes the finder from JSON generated by [serialize].
static Descendant deserialize(Map<String, String> json) { static Descendant deserialize(Map<String, String> json) {
final Map<String, String> jsonOfMatcher = final Map<String, String> jsonOfMatcher =
Map<String, String>.from(jsonDecode(json['of'])); Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>);
final Map<String, String> jsonMatchingMatcher = final Map<String, String> jsonMatchingMatcher =
Map<String, String>.from(jsonDecode(json['matching'])); Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
return Descendant( return Descendant(
of: SerializableFinder.deserialize(jsonOfMatcher), of: SerializableFinder.deserialize(jsonOfMatcher),
matching: SerializableFinder.deserialize(jsonMatchingMatcher), matching: SerializableFinder.deserialize(jsonMatchingMatcher),
...@@ -406,9 +406,9 @@ class Ancestor extends SerializableFinder { ...@@ -406,9 +406,9 @@ class Ancestor extends SerializableFinder {
/// Deserializes the finder from JSON generated by [serialize]. /// Deserializes the finder from JSON generated by [serialize].
static Ancestor deserialize(Map<String, String> json) { static Ancestor deserialize(Map<String, String> json) {
final Map<String, String> jsonOfMatcher = final Map<String, String> jsonOfMatcher =
Map<String, String>.from(jsonDecode(json['of'])); Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>);
final Map<String, String> jsonMatchingMatcher = final Map<String, String> jsonMatchingMatcher =
Map<String, String>.from(jsonDecode(json['matching'])); Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
return Ancestor( return Ancestor(
of: SerializableFinder.deserialize(jsonOfMatcher), of: SerializableFinder.deserialize(jsonOfMatcher),
matching: SerializableFinder.deserialize(jsonMatchingMatcher), matching: SerializableFinder.deserialize(jsonMatchingMatcher),
...@@ -454,7 +454,7 @@ class GetSemanticsIdResult extends Result { ...@@ -454,7 +454,7 @@ class GetSemanticsIdResult extends Result {
/// Deserializes this result from JSON. /// Deserializes this result from JSON.
static GetSemanticsIdResult fromJson(Map<String, dynamic> json) { static GetSemanticsIdResult fromJson(Map<String, dynamic> json) {
return GetSemanticsIdResult(json['id']); return GetSemanticsIdResult(json['id'] as int);
} }
@override @override
......
...@@ -58,7 +58,7 @@ class _DummySshCommandRunner implements SshCommandRunner { ...@@ -58,7 +58,7 @@ class _DummySshCommandRunner implements SshCommandRunner {
// will wait indefinitely for the `out` directory to be serviced, causing // will wait indefinitely for the `out` directory to be serviced, causing
// a deadlock. // a deadlock.
final ProcessResult r = await Process.run(exe, args); final ProcessResult r = await Process.run(exe, args);
return r.stdout.split('\n'); return (r.stdout as String).split('\n');
} on ProcessException catch (e) { } on ProcessException catch (e) {
_log("Error running '$command': $e"); _log("Error running '$command': $e");
} }
......
...@@ -36,7 +36,7 @@ class GetOffset extends CommandWithTarget { ...@@ -36,7 +36,7 @@ class GetOffset extends CommandWithTarget {
GetOffset(SerializableFinder finder, this.offsetType, { Duration timeout }) : super(finder, timeout: timeout); GetOffset(SerializableFinder finder, this.offsetType, { Duration timeout }) : super(finder, timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
GetOffset.deserialize(Map<String, dynamic> json) GetOffset.deserialize(Map<String, String> json)
: offsetType = _offsetTypeIndex.lookupBySimpleName(json['offsetType']), : offsetType = _offsetTypeIndex.lookupBySimpleName(json['offsetType']),
super.deserialize(json); super.deserialize(json);
...@@ -75,8 +75,8 @@ class GetOffsetResult extends Result { ...@@ -75,8 +75,8 @@ class GetOffsetResult extends Result {
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static GetOffsetResult fromJson(Map<String, dynamic> json) { static GetOffsetResult fromJson(Map<String, dynamic> json) {
return GetOffsetResult( return GetOffsetResult(
dx: json['dx'], dx: json['dx'] as double,
dy: json['dy'], dy: json['dy'] as double,
); );
} }
......
...@@ -46,7 +46,7 @@ class Health extends Result { ...@@ -46,7 +46,7 @@ class Health extends Result {
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static Health fromJson(Map<String, dynamic> json) { static Health fromJson(Map<String, dynamic> json) {
return Health(_healthStatusIndex.lookupBySimpleName(json['status'])); return Health(_healthStatusIndex.lookupBySimpleName(json['status'] as String));
} }
@override @override
......
...@@ -27,7 +27,7 @@ class RenderTree extends Result { ...@@ -27,7 +27,7 @@ class RenderTree extends Result {
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static RenderTree fromJson(Map<String, dynamic> json) { static RenderTree fromJson(Map<String, dynamic> json) {
return RenderTree(json['tree']); return RenderTree(json['tree'] as String);
} }
@override @override
......
...@@ -40,7 +40,7 @@ class RequestDataResult extends Result { ...@@ -40,7 +40,7 @@ class RequestDataResult extends Result {
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static RequestDataResult fromJson(Map<String, dynamic> json) { static RequestDataResult fromJson(Map<String, dynamic> json) {
return RequestDataResult(json['message']); return RequestDataResult(json['message'] as String);
} }
@override @override
......
...@@ -37,7 +37,7 @@ class SetSemanticsResult extends Result { ...@@ -37,7 +37,7 @@ class SetSemanticsResult extends Result {
/// Deserializes this result from JSON. /// Deserializes this result from JSON.
static SetSemanticsResult fromJson(Map<String, dynamic> json) { static SetSemanticsResult fromJson(Map<String, dynamic> json) {
return SetSemanticsResult(json['changedState']); return SetSemanticsResult(json['changedState'] as bool);
} }
@override @override
......
...@@ -11,7 +11,7 @@ class GetText extends CommandWithTarget { ...@@ -11,7 +11,7 @@ class GetText extends CommandWithTarget {
GetText(SerializableFinder finder, { Duration timeout }) : super(finder, timeout: timeout); GetText(SerializableFinder finder, { Duration timeout }) : super(finder, timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
GetText.deserialize(Map<String, dynamic> json) : super.deserialize(json); GetText.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
String get kind => 'get_text'; String get kind => 'get_text';
...@@ -27,7 +27,7 @@ class GetTextResult extends Result { ...@@ -27,7 +27,7 @@ class GetTextResult extends Result {
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static GetTextResult fromJson(Map<String, dynamic> json) { static GetTextResult fromJson(Map<String, dynamic> json) {
return GetTextResult(json['text']); return GetTextResult(json['text'] as String);
} }
@override @override
...@@ -42,7 +42,7 @@ class EnterText extends Command { ...@@ -42,7 +42,7 @@ class EnterText extends Command {
const EnterText(this.text, { Duration timeout }) : super(timeout: timeout); const EnterText(this.text, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
EnterText.deserialize(Map<String, dynamic> json) EnterText.deserialize(Map<String, String> json)
: text = json['text'], : text = json['text'],
super.deserialize(json); super.deserialize(json);
...@@ -78,7 +78,7 @@ class SetTextEntryEmulation extends Command { ...@@ -78,7 +78,7 @@ class SetTextEntryEmulation extends Command {
const SetTextEntryEmulation(this.enabled, { Duration timeout }) : super(timeout: timeout); const SetTextEntryEmulation(this.enabled, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
SetTextEntryEmulation.deserialize(Map<String, dynamic> json) SetTextEntryEmulation.deserialize(Map<String, String> json)
: enabled = json['enabled'] == 'true', : enabled = json['enabled'] == 'true',
super.deserialize(json); super.deserialize(json);
......
...@@ -159,7 +159,7 @@ class NoTransientCallbacks extends SerializableWaitCondition { ...@@ -159,7 +159,7 @@ class NoTransientCallbacks extends SerializableWaitCondition {
/// given JSON map. /// given JSON map.
/// ///
/// The [json] argument must not be null. /// The [json] argument must not be null.
factory NoTransientCallbacks.deserialize(Map<String, dynamic> json) { factory NoTransientCallbacks.deserialize(Map<String, String> json) {
assert(json != null); assert(json != null);
if (json['conditionName'] != 'NoTransientCallbacksCondition') if (json['conditionName'] != 'NoTransientCallbacksCondition')
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
...@@ -179,7 +179,7 @@ class NoPendingFrame extends SerializableWaitCondition { ...@@ -179,7 +179,7 @@ class NoPendingFrame extends SerializableWaitCondition {
/// JSON map. /// JSON map.
/// ///
/// The [json] argument must not be null. /// The [json] argument must not be null.
factory NoPendingFrame.deserialize(Map<String, dynamic> json) { factory NoPendingFrame.deserialize(Map<String, String> json) {
assert(json != null); assert(json != null);
if (json['conditionName'] != 'NoPendingFrameCondition') if (json['conditionName'] != 'NoPendingFrameCondition')
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
...@@ -199,7 +199,7 @@ class FirstFrameRasterized extends SerializableWaitCondition { ...@@ -199,7 +199,7 @@ class FirstFrameRasterized extends SerializableWaitCondition {
/// given JSON map. /// given JSON map.
/// ///
/// The [json] argument must not be null. /// The [json] argument must not be null.
factory FirstFrameRasterized.deserialize(Map<String, dynamic> json) { factory FirstFrameRasterized.deserialize(Map<String, String> json) {
assert(json != null); assert(json != null);
if (json['conditionName'] != 'FirstFrameRasterizedCondition') if (json['conditionName'] != 'FirstFrameRasterizedCondition')
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
...@@ -219,7 +219,7 @@ class NoPendingPlatformMessages extends SerializableWaitCondition { ...@@ -219,7 +219,7 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
/// given JSON map. /// given JSON map.
/// ///
/// The [json] argument must not be null. /// The [json] argument must not be null.
factory NoPendingPlatformMessages.deserialize(Map<String, dynamic> json) { factory NoPendingPlatformMessages.deserialize(Map<String, String> json) {
assert(json != null); assert(json != null);
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') if (json['conditionName'] != 'NoPendingPlatformMessagesCondition')
throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json'); throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json');
...@@ -242,7 +242,7 @@ class CombinedCondition extends SerializableWaitCondition { ...@@ -242,7 +242,7 @@ class CombinedCondition extends SerializableWaitCondition {
/// given JSON map. /// given JSON map.
/// ///
/// The [jsonMap] argument must not be null. /// The [jsonMap] argument must not be null.
factory CombinedCondition.deserialize(Map<String, dynamic> jsonMap) { factory CombinedCondition.deserialize(Map<String, String> jsonMap) {
assert(jsonMap != null); assert(jsonMap != null);
if (jsonMap['conditionName'] != 'CombinedCondition') if (jsonMap['conditionName'] != 'CombinedCondition')
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap'); throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
...@@ -252,7 +252,7 @@ class CombinedCondition extends SerializableWaitCondition { ...@@ -252,7 +252,7 @@ class CombinedCondition extends SerializableWaitCondition {
final List<SerializableWaitCondition> conditions = <SerializableWaitCondition>[]; final List<SerializableWaitCondition> conditions = <SerializableWaitCondition>[];
for (Map<String, dynamic> condition in json.decode(jsonMap['conditions'])) { for (Map<String, dynamic> condition in json.decode(jsonMap['conditions'])) {
conditions.add(_deserialize(condition)); conditions.add(_deserialize(condition.cast<String, String>()));
} }
return CombinedCondition(conditions); return CombinedCondition(conditions);
} }
...@@ -279,7 +279,7 @@ class CombinedCondition extends SerializableWaitCondition { ...@@ -279,7 +279,7 @@ class CombinedCondition extends SerializableWaitCondition {
/// Parses a [SerializableWaitCondition] or its subclass from the given [json] map. /// Parses a [SerializableWaitCondition] or its subclass from the given [json] map.
/// ///
/// The [json] argument must not be null. /// The [json] argument must not be null.
SerializableWaitCondition _deserialize(Map<String, dynamic> json) { SerializableWaitCondition _deserialize(Map<String, String> json) {
assert(json != null); assert(json != null);
final String conditionName = json['conditionName']; final String conditionName = json['conditionName'];
switch (conditionName) { switch (conditionName) {
......
...@@ -436,7 +436,7 @@ class FlutterDriver { ...@@ -436,7 +436,7 @@ class FlutterDriver {
final Future<Map<String, dynamic>> future = appIsolate.invokeExtension( final Future<Map<String, dynamic>> future = appIsolate.invokeExtension(
_flutterExtensionMethodName, _flutterExtensionMethodName,
serialized, serialized,
).then<Map<String, dynamic>>((Object value) => value); ).then<Map<String, dynamic>>((Object value) => value as Map<String, dynamic>);
response = await _warnIfSlow<Map<String, dynamic>>( response = await _warnIfSlow<Map<String, dynamic>>(
future: future, future: future,
timeout: command.timeout ?? kUnusuallyLongTimeout, timeout: command.timeout ?? kUnusuallyLongTimeout,
...@@ -450,9 +450,9 @@ class FlutterDriver { ...@@ -450,9 +450,9 @@ class FlutterDriver {
stackTrace, stackTrace,
); );
} }
if (response['isError']) if (response['isError'] as bool)
throw DriverError('Error in Flutter application: ${response['response']}'); throw DriverError('Error in Flutter application: ${response['response']}');
return response['response']; return response['response'] as Map<String, dynamic>;
} }
void _logCommunication(String message) { void _logCommunication(String message) {
...@@ -850,8 +850,8 @@ class FlutterDriver { ...@@ -850,8 +850,8 @@ class FlutterDriver {
// and a source of flakes. // and a source of flakes.
await Future<void>.delayed(const Duration(seconds: 2)); await Future<void>.delayed(const Duration(seconds: 2));
final Map<String, dynamic> result = await _peer.sendRequest('_flutter.screenshot'); final Map<String, dynamic> result = await _peer.sendRequest('_flutter.screenshot') as Map<String, dynamic>;
return base64.decode(result['screenshot']); return base64.decode(result['screenshot'] as String);
} }
/// Returns the Flags set in the Dart VM as JSON. /// Returns the Flags set in the Dart VM as JSON.
...@@ -875,9 +875,9 @@ class FlutterDriver { ...@@ -875,9 +875,9 @@ class FlutterDriver {
/// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist /// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist
Future<List<Map<String, dynamic>>> getVmFlags() async { Future<List<Map<String, dynamic>>> getVmFlags() async {
await _restorePeerConnectionIfNeeded(); await _restorePeerConnectionIfNeeded();
final Map<String, dynamic> result = await _peer.sendRequest('getFlagList'); final Map<String, dynamic> result = await _peer.sendRequest('getFlagList') as Map<String, dynamic>;
return result != null return result != null
? result['flags'].cast<Map<String,dynamic>>() ? (result['flags'] as List<dynamic>).cast<Map<String,dynamic>>()
: const <Map<String, dynamic>>[]; : const <Map<String, dynamic>>[];
} }
...@@ -924,7 +924,7 @@ class FlutterDriver { ...@@ -924,7 +924,7 @@ class FlutterDriver {
timeout: timeout, timeout: timeout,
message: 'VM is taking an unusually long time to respond to being told to stop tracing...', message: 'VM is taking an unusually long time to respond to being told to stop tracing...',
); );
return Timeline.fromJson(await _peer.sendRequest(_getVMTimelineMethodName)); return Timeline.fromJson(await _peer.sendRequest(_getVMTimelineMethodName) as Map<String, dynamic>);
} catch (error, stackTrace) { } catch (error, stackTrace) {
throw DriverError( throw DriverError(
'Failed to stop tracing due to remote error', 'Failed to stop tracing due to remote error',
...@@ -1239,10 +1239,9 @@ class DriverOffset { ...@@ -1239,10 +1239,9 @@ class DriverOffset {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
if (other is! DriverOffset) return other is DriverOffset
return false; && other.dx == dx
final DriverOffset typedOther = other; && other.dy == dy;
return dx == typedOther.dx && dy == typedOther.dy;
} }
@override @override
......
...@@ -29,20 +29,20 @@ class TimelineEvent { ...@@ -29,20 +29,20 @@ class TimelineEvent {
factory TimelineEvent(Map<String, dynamic> json) { factory TimelineEvent(Map<String, dynamic> json) {
return TimelineEvent._( return TimelineEvent._(
json, json,
json['name'], json['name'] as String,
json['cat'], json['cat'] as String,
json['ph'], json['ph'] as String,
json['pid'], json['pid'] as int,
json['tid'], json['tid'] as int,
json['dur'] != null json['dur'] != null
? Duration(microseconds: json['dur']) ? Duration(microseconds: json['dur'] as int)
: null, : null,
json['tdur'] != null json['tdur'] != null
? Duration(microseconds: json['tdur']) ? Duration(microseconds: json['tdur'] as int)
: null, : null,
json['ts'], json['ts'] as int,
json['tts'], json['tts'] as int,
json['args'], json['args'] as Map<String, dynamic>,
); );
} }
...@@ -122,7 +122,7 @@ class TimelineEvent { ...@@ -122,7 +122,7 @@ class TimelineEvent {
} }
List<TimelineEvent> _parseEvents(Map<String, dynamic> json) { List<TimelineEvent> _parseEvents(Map<String, dynamic> json) {
final List<dynamic> jsonEvents = json['traceEvents']; final List<dynamic> jsonEvents = json['traceEvents'] as List<dynamic>;
if (jsonEvents == null) if (jsonEvents == null)
return null; return null;
......
...@@ -152,14 +152,14 @@ class FlutterDriverExtension { ...@@ -152,14 +152,14 @@ class FlutterDriverExtension {
}); });
_finders.addAll(<String, FinderConstructor>{ _finders.addAll(<String, FinderConstructor>{
'ByText': (SerializableFinder finder) => _createByTextFinder(finder), 'ByText': (SerializableFinder finder) => _createByTextFinder(finder as ByText),
'ByTooltipMessage': (SerializableFinder finder) => _createByTooltipMessageFinder(finder), 'ByTooltipMessage': (SerializableFinder finder) => _createByTooltipMessageFinder(finder as ByTooltipMessage),
'BySemanticsLabel': (SerializableFinder finder) => _createBySemanticsLabelFinder(finder), 'BySemanticsLabel': (SerializableFinder finder) => _createBySemanticsLabelFinder(finder as BySemanticsLabel),
'ByValueKey': (SerializableFinder finder) => _createByValueKeyFinder(finder), 'ByValueKey': (SerializableFinder finder) => _createByValueKeyFinder(finder as ByValueKey),
'ByType': (SerializableFinder finder) => _createByTypeFinder(finder), 'ByType': (SerializableFinder finder) => _createByTypeFinder(finder as ByType),
'PageBack': (SerializableFinder finder) => _createPageBackFinder(), 'PageBack': (SerializableFinder finder) => _createPageBackFinder(),
'Ancestor': (SerializableFinder finder) => _createAncestorFinder(finder), 'Ancestor': (SerializableFinder finder) => _createAncestorFinder(finder as Ancestor),
'Descendant': (SerializableFinder finder) => _createDescendantFinder(finder), 'Descendant': (SerializableFinder finder) => _createDescendantFinder(finder as Descendant),
}); });
} }
...@@ -314,9 +314,9 @@ class FlutterDriverExtension { ...@@ -314,9 +314,9 @@ class FlutterDriverExtension {
Finder _createByValueKeyFinder(ByValueKey arguments) { Finder _createByValueKeyFinder(ByValueKey arguments) {
switch (arguments.keyValueType) { switch (arguments.keyValueType) {
case 'int': case 'int':
return find.byKey(ValueKey<int>(arguments.keyValue)); return find.byKey(ValueKey<int>(arguments.keyValue as int));
case 'String': case 'String':
return find.byKey(ValueKey<String>(arguments.keyValue)); return find.byKey(ValueKey<String>(arguments.keyValue as String));
default: default:
throw 'Unsupported ByValueKey type: ${arguments.keyValueType}'; throw 'Unsupported ByValueKey type: ${arguments.keyValueType}';
} }
...@@ -367,7 +367,7 @@ class FlutterDriverExtension { ...@@ -367,7 +367,7 @@ class FlutterDriverExtension {
} }
Future<TapResult> _tap(Command command) async { Future<TapResult> _tap(Command command) async {
final Tap tapCommand = command; final Tap tapCommand = command as Tap;
final Finder computedFinder = await _waitForElement( final Finder computedFinder = await _waitForElement(
_createFinder(tapCommand.finder).hitTestable() _createFinder(tapCommand.finder).hitTestable()
); );
...@@ -376,20 +376,20 @@ class FlutterDriverExtension { ...@@ -376,20 +376,20 @@ class FlutterDriverExtension {
} }
Future<WaitForResult> _waitFor(Command command) async { Future<WaitForResult> _waitFor(Command command) async {
final WaitFor waitForCommand = command; final WaitFor waitForCommand = command as WaitFor;
await _waitForElement(_createFinder(waitForCommand.finder)); await _waitForElement(_createFinder(waitForCommand.finder));
return const WaitForResult(); return const WaitForResult();
} }
Future<WaitForAbsentResult> _waitForAbsent(Command command) async { Future<WaitForAbsentResult> _waitForAbsent(Command command) async {
final WaitForAbsent waitForAbsentCommand = command; final WaitForAbsent waitForAbsentCommand = command as WaitForAbsent;
await _waitForAbsentElement(_createFinder(waitForAbsentCommand.finder)); await _waitForAbsentElement(_createFinder(waitForAbsentCommand.finder));
return const WaitForAbsentResult(); return const WaitForAbsentResult();
} }
Future<Result> _waitForCondition(Command command) async { Future<Result> _waitForCondition(Command command) async {
assert(command != null); assert(command != null);
final WaitForCondition waitForConditionCommand = command; final WaitForCondition waitForConditionCommand = command as WaitForCondition;
final WaitCondition condition = deserializeCondition(waitForConditionCommand.condition); final WaitCondition condition = deserializeCondition(waitForConditionCommand.condition);
await condition.wait(); await condition.wait();
return null; return null;
...@@ -437,7 +437,7 @@ class FlutterDriverExtension { ...@@ -437,7 +437,7 @@ class FlutterDriverExtension {
} }
Future<GetSemanticsIdResult> _getSemanticsId(Command command) async { Future<GetSemanticsIdResult> _getSemanticsId(Command command) async {
final GetSemanticsId semanticsCommand = command; final GetSemanticsId semanticsCommand = command as GetSemanticsId;
final Finder target = await _waitForElement(_createFinder(semanticsCommand.finder)); final Finder target = await _waitForElement(_createFinder(semanticsCommand.finder));
final Iterable<Element> elements = target.evaluate(); final Iterable<Element> elements = target.evaluate();
if (elements.length > 1) { if (elements.length > 1) {
...@@ -448,7 +448,7 @@ class FlutterDriverExtension { ...@@ -448,7 +448,7 @@ class FlutterDriverExtension {
SemanticsNode node; SemanticsNode node;
while (renderObject != null && node == null) { while (renderObject != null && node == null) {
node = renderObject.debugSemantics; node = renderObject.debugSemantics;
renderObject = renderObject.parent; renderObject = renderObject.parent as RenderObject;
} }
if (node == null) if (node == null)
throw StateError('No semantics data found'); throw StateError('No semantics data found');
...@@ -456,10 +456,10 @@ class FlutterDriverExtension { ...@@ -456,10 +456,10 @@ class FlutterDriverExtension {
} }
Future<GetOffsetResult> _getOffset(Command command) async { Future<GetOffsetResult> _getOffset(Command command) async {
final GetOffset getOffsetCommand = command; final GetOffset getOffsetCommand = command as GetOffset;
final Finder finder = await _waitForElement(_createFinder(getOffsetCommand.finder)); final Finder finder = await _waitForElement(_createFinder(getOffsetCommand.finder));
final Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
final RenderBox box = element.renderObject; final RenderBox box = element.renderObject as RenderBox;
Offset localPoint; Offset localPoint;
switch (getOffsetCommand.offsetType) { switch (getOffsetCommand.offsetType) {
case OffsetType.topLeft: case OffsetType.topLeft:
...@@ -483,7 +483,7 @@ class FlutterDriverExtension { ...@@ -483,7 +483,7 @@ class FlutterDriverExtension {
} }
Future<DiagnosticsTreeResult> _getDiagnosticsTree(Command command) async { Future<DiagnosticsTreeResult> _getDiagnosticsTree(Command command) async {
final GetDiagnosticsTree diagnosticsCommand = command; final GetDiagnosticsTree diagnosticsCommand = command as GetDiagnosticsTree;
final Finder finder = await _waitForElement(_createFinder(diagnosticsCommand.finder)); final Finder finder = await _waitForElement(_createFinder(diagnosticsCommand.finder));
final Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
DiagnosticsNode diagnosticsNode; DiagnosticsNode diagnosticsNode;
...@@ -502,7 +502,7 @@ class FlutterDriverExtension { ...@@ -502,7 +502,7 @@ class FlutterDriverExtension {
} }
Future<ScrollResult> _scroll(Command command) async { Future<ScrollResult> _scroll(Command command) async {
final Scroll scrollCommand = command; final Scroll scrollCommand = command as Scroll;
final Finder target = await _waitForElement(_createFinder(scrollCommand.finder)); final Finder target = await _waitForElement(_createFinder(scrollCommand.finder));
final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.microsecondsPerSecond; final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.microsecondsPerSecond;
final Offset delta = Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble(); final Offset delta = Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble();
...@@ -526,22 +526,22 @@ class FlutterDriverExtension { ...@@ -526,22 +526,22 @@ class FlutterDriverExtension {
} }
Future<ScrollResult> _scrollIntoView(Command command) async { Future<ScrollResult> _scrollIntoView(Command command) async {
final ScrollIntoView scrollIntoViewCommand = command; final ScrollIntoView scrollIntoViewCommand = command as ScrollIntoView;
final Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder)); final Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder));
await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0);
return const ScrollResult(); return const ScrollResult();
} }
Future<GetTextResult> _getText(Command command) async { Future<GetTextResult> _getText(Command command) async {
final GetText getTextCommand = command; final GetText getTextCommand = command as GetText;
final Finder target = await _waitForElement(_createFinder(getTextCommand.finder)); final Finder target = await _waitForElement(_createFinder(getTextCommand.finder));
// TODO(yjbanov): support more ways to read text // TODO(yjbanov): support more ways to read text
final Text text = target.evaluate().single.widget; final Text text = target.evaluate().single.widget as Text;
return GetTextResult(text.data); return GetTextResult(text.data);
} }
Future<SetTextEntryEmulationResult> _setTextEntryEmulation(Command command) async { Future<SetTextEntryEmulationResult> _setTextEntryEmulation(Command command) async {
final SetTextEntryEmulation setTextEntryEmulationCommand = command; final SetTextEntryEmulation setTextEntryEmulationCommand = command as SetTextEntryEmulation;
if (setTextEntryEmulationCommand.enabled) { if (setTextEntryEmulationCommand.enabled) {
_testTextInput.register(); _testTextInput.register();
} else { } else {
...@@ -555,18 +555,18 @@ class FlutterDriverExtension { ...@@ -555,18 +555,18 @@ class FlutterDriverExtension {
throw 'Unable to fulfill `FlutterDriver.enterText`. Text emulation is ' throw 'Unable to fulfill `FlutterDriver.enterText`. Text emulation is '
'disabled. You can enable it using `FlutterDriver.setTextEntryEmulation`.'; 'disabled. You can enable it using `FlutterDriver.setTextEntryEmulation`.';
} }
final EnterText enterTextCommand = command; final EnterText enterTextCommand = command as EnterText;
_testTextInput.enterText(enterTextCommand.text); _testTextInput.enterText(enterTextCommand.text);
return const EnterTextResult(); return const EnterTextResult();
} }
Future<RequestDataResult> _requestData(Command command) async { Future<RequestDataResult> _requestData(Command command) async {
final RequestData requestDataCommand = command; final RequestData requestDataCommand = command as RequestData;
return RequestDataResult(_requestDataHandler == null ? 'No requestData Extension registered' : await _requestDataHandler(requestDataCommand.message)); return RequestDataResult(_requestDataHandler == null ? 'No requestData Extension registered' : await _requestDataHandler(requestDataCommand.message));
} }
Future<SetFrameSyncResult> _setFrameSync(Command command) async { Future<SetFrameSyncResult> _setFrameSync(Command command) async {
final SetFrameSync setFrameSyncCommand = command; final SetFrameSync setFrameSyncCommand = command as SetFrameSync;
_frameSync = setFrameSyncCommand.enabled; _frameSync = setFrameSyncCommand.enabled;
return const SetFrameSyncResult(); return const SetFrameSyncResult();
} }
...@@ -575,7 +575,7 @@ class FlutterDriverExtension { ...@@ -575,7 +575,7 @@ class FlutterDriverExtension {
bool get _semanticsIsEnabled => RendererBinding.instance.pipelineOwner.semanticsOwner != null; bool get _semanticsIsEnabled => RendererBinding.instance.pipelineOwner.semanticsOwner != null;
Future<SetSemanticsResult> _setSemantics(Command command) async { Future<SetSemanticsResult> _setSemantics(Command command) async {
final SetSemantics setSemanticsCommand = command; final SetSemantics setSemanticsCommand = command as SetSemantics;
final bool semanticsWasEnabled = _semanticsIsEnabled; final bool semanticsWasEnabled = _semanticsIsEnabled;
if (setSemanticsCommand.enabled && _semantics == null) { if (setSemanticsCommand.enabled && _semantics == null) {
_semantics = RendererBinding.instance.pipelineOwner.ensureSemantics(); _semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
......
...@@ -132,13 +132,13 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition { ...@@ -132,13 +132,13 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
@override @override
bool get condition { bool get condition {
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger; final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger as TestDefaultBinaryMessenger;
return binaryMessenger.pendingMessageCount == 0; return binaryMessenger.pendingMessageCount == 0;
} }
@override @override
Future<void> wait() async { Future<void> wait() async {
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger; final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger as TestDefaultBinaryMessenger;
while (!condition) { while (!condition) {
await binaryMessenger.platformMessagesFinished; await binaryMessenger.platformMessagesFinished;
} }
...@@ -163,7 +163,7 @@ class _InternalCombinedCondition implements WaitCondition { ...@@ -163,7 +163,7 @@ class _InternalCombinedCondition implements WaitCondition {
assert(condition != null); assert(condition != null);
if (condition.conditionName != 'CombinedCondition') if (condition.conditionName != 'CombinedCondition')
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
final CombinedCondition combinedCondition = condition; final CombinedCondition combinedCondition = condition as CombinedCondition;
if (combinedCondition.conditions == null) { if (combinedCondition.conditions == null) {
return const _InternalCombinedCondition(<WaitCondition>[]); return const _InternalCombinedCondition(<WaitCondition>[]);
} }
......
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