Fix the test error of "Add finders for enableFlutterDriverExtension" and resubmit (#65276)
This commit is contained in:
@@ -33,11 +33,11 @@ class GetDiagnosticsTree extends CommandWithTarget {
|
||||
super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
GetDiagnosticsTree.deserialize(Map<String, String> json)
|
||||
GetDiagnosticsTree.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: subtreeDepth = int.parse(json['subtreeDepth']),
|
||||
includeProperties = json['includeProperties'] == 'true',
|
||||
diagnosticsType = _diagnosticsTypeIndex.lookupBySimpleName(json['diagnosticsType']),
|
||||
super.deserialize(json);
|
||||
super.deserialize(json, finderFactory);
|
||||
|
||||
/// How many levels of children to include in the JSON result.
|
||||
///
|
||||
|
||||
@@ -9,6 +9,25 @@ import 'package:meta/meta.dart';
|
||||
import 'error.dart';
|
||||
import 'message.dart';
|
||||
|
||||
/// A factory for deserializing [Finder]s.
|
||||
mixin DeserializeFinderFactory {
|
||||
/// Deserializes the finder from JSON generated by [SerializableFinder.serialize].
|
||||
SerializableFinder deserializeFinder(Map<String, String> json) {
|
||||
final String finderType = json['finderType'];
|
||||
switch (finderType) {
|
||||
case 'ByType': return ByType.deserialize(json);
|
||||
case 'ByValueKey': return ByValueKey.deserialize(json);
|
||||
case 'ByTooltipMessage': return ByTooltipMessage.deserialize(json);
|
||||
case 'BySemanticsLabel': return BySemanticsLabel.deserialize(json);
|
||||
case 'ByText': return ByText.deserialize(json);
|
||||
case 'PageBack': return const PageBack();
|
||||
case 'Descendant': return Descendant.deserialize(json, this);
|
||||
case 'Ancestor': return Ancestor.deserialize(json, this);
|
||||
}
|
||||
throw DriverError('Unsupported search specification type $finderType');
|
||||
}
|
||||
}
|
||||
|
||||
const List<Type> _supportedKeyValueTypes = <Type>[String, int];
|
||||
|
||||
DriverError _createInvalidKeyValueTypeError(String invalidType) {
|
||||
@@ -28,8 +47,8 @@ abstract class CommandWithTarget extends Command {
|
||||
}
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
CommandWithTarget.deserialize(Map<String, String> json)
|
||||
: finder = SerializableFinder.deserialize(json),
|
||||
CommandWithTarget.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: finder = finderFactory.deserializeFinder(json),
|
||||
super.deserialize(json);
|
||||
|
||||
/// Locates the object or objects targeted by this command.
|
||||
@@ -58,7 +77,7 @@ class WaitFor extends CommandWithTarget {
|
||||
: super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
WaitFor.deserialize(Map<String, String> json) : super.deserialize(json);
|
||||
WaitFor.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'waitFor';
|
||||
@@ -88,7 +107,7 @@ class WaitForAbsent extends CommandWithTarget {
|
||||
: super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
WaitForAbsent.deserialize(Map<String, String> json) : super.deserialize(json);
|
||||
WaitForAbsent.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'waitForAbsent';
|
||||
@@ -126,22 +145,6 @@ abstract class SerializableFinder {
|
||||
Map<String, String> serialize() => <String, String>{
|
||||
'finderType': finderType,
|
||||
};
|
||||
|
||||
/// Deserializes a finder from JSON generated by [serialize].
|
||||
static SerializableFinder deserialize(Map<String, String> json) {
|
||||
final String finderType = json['finderType'];
|
||||
switch (finderType) {
|
||||
case 'ByType': return ByType.deserialize(json);
|
||||
case 'ByValueKey': return ByValueKey.deserialize(json);
|
||||
case 'ByTooltipMessage': return ByTooltipMessage.deserialize(json);
|
||||
case 'BySemanticsLabel': return BySemanticsLabel.deserialize(json);
|
||||
case 'ByText': return ByText.deserialize(json);
|
||||
case 'PageBack': return const PageBack();
|
||||
case 'Descendant': return Descendant.deserialize(json);
|
||||
case 'Ancestor': return Ancestor.deserialize(json);
|
||||
}
|
||||
throw DriverError('Unsupported search specification type $finderType');
|
||||
}
|
||||
}
|
||||
|
||||
/// A Flutter Driver finder that finds widgets by tooltip text.
|
||||
@@ -349,14 +352,14 @@ class Descendant extends SerializableFinder {
|
||||
}
|
||||
|
||||
/// Deserializes the finder from JSON generated by [serialize].
|
||||
static Descendant deserialize(Map<String, String> json) {
|
||||
static Descendant deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) {
|
||||
final Map<String, String> jsonOfMatcher =
|
||||
Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>);
|
||||
final Map<String, String> jsonMatchingMatcher =
|
||||
Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
|
||||
return Descendant(
|
||||
of: SerializableFinder.deserialize(jsonOfMatcher),
|
||||
matching: SerializableFinder.deserialize(jsonMatchingMatcher),
|
||||
of: finderFactory.deserializeFinder(jsonOfMatcher),
|
||||
matching: finderFactory.deserializeFinder(jsonMatchingMatcher),
|
||||
matchRoot: json['matchRoot'] == 'true',
|
||||
firstMatchOnly: json['firstMatchOnly'] == 'true',
|
||||
);
|
||||
@@ -404,14 +407,14 @@ class Ancestor extends SerializableFinder {
|
||||
}
|
||||
|
||||
/// Deserializes the finder from JSON generated by [serialize].
|
||||
static Ancestor deserialize(Map<String, String> json) {
|
||||
static Ancestor deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) {
|
||||
final Map<String, String> jsonOfMatcher =
|
||||
Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>);
|
||||
final Map<String, String> jsonMatchingMatcher =
|
||||
Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
|
||||
return Ancestor(
|
||||
of: SerializableFinder.deserialize(jsonOfMatcher),
|
||||
matching: SerializableFinder.deserialize(jsonMatchingMatcher),
|
||||
of: finderFactory.deserializeFinder(jsonOfMatcher),
|
||||
matching: finderFactory.deserializeFinder(jsonMatchingMatcher),
|
||||
matchRoot: json['matchRoot'] == 'true',
|
||||
firstMatchOnly: json['firstMatchOnly'] == 'true',
|
||||
);
|
||||
@@ -436,8 +439,8 @@ class GetSemanticsId extends CommandWithTarget {
|
||||
GetSemanticsId(SerializableFinder finder, {Duration timeout}) : super(finder, timeout: timeout);
|
||||
|
||||
/// Creates a command from a JSON map.
|
||||
GetSemanticsId.deserialize(Map<String, String> json)
|
||||
: super.deserialize(json);
|
||||
GetSemanticsId.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'get_semantics_id';
|
||||
|
||||
@@ -36,9 +36,9 @@ class GetOffset extends CommandWithTarget {
|
||||
GetOffset(SerializableFinder finder, this.offsetType, { Duration timeout }) : super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
GetOffset.deserialize(Map<String, String> json)
|
||||
GetOffset.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: offsetType = _offsetTypeIndex.lookupBySimpleName(json['offsetType']),
|
||||
super.deserialize(json);
|
||||
super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
|
||||
|
||||
@@ -11,7 +11,7 @@ class Tap extends CommandWithTarget {
|
||||
Tap(SerializableFinder finder, { Duration timeout }) : super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
Tap.deserialize(Map<String, String> json) : super.deserialize(json);
|
||||
Tap.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'tap';
|
||||
@@ -46,12 +46,12 @@ class Scroll extends CommandWithTarget {
|
||||
}) : super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
Scroll.deserialize(Map<String, String> json)
|
||||
Scroll.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: dx = double.parse(json['dx']),
|
||||
dy = double.parse(json['dy']),
|
||||
duration = Duration(microseconds: int.parse(json['duration'])),
|
||||
frequency = int.parse(json['frequency']),
|
||||
super.deserialize(json);
|
||||
super.deserialize(json, finderFactory);
|
||||
|
||||
/// Delta X offset per move event.
|
||||
final double dx;
|
||||
@@ -99,9 +99,9 @@ class ScrollIntoView extends CommandWithTarget {
|
||||
ScrollIntoView(SerializableFinder finder, { this.alignment = 0.0, Duration timeout }) : super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
ScrollIntoView.deserialize(Map<String, String> json)
|
||||
ScrollIntoView.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: alignment = double.parse(json['alignment']),
|
||||
super.deserialize(json);
|
||||
super.deserialize(json, finderFactory);
|
||||
|
||||
/// How the widget should be aligned.
|
||||
///
|
||||
|
||||
@@ -11,7 +11,7 @@ class GetText extends CommandWithTarget {
|
||||
GetText(SerializableFinder finder, { Duration timeout }) : super(finder, timeout: timeout);
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
GetText.deserialize(Map<String, String> json) : super.deserialize(json);
|
||||
GetText.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'get_text';
|
||||
|
||||
Reference in New Issue
Block a user