Unverified Commit 14af5bbe authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Add finders for enableFlutterDriverExtension (#64308)" (#65273)

This reverts commit db4dda20.
parent db4dda20
...@@ -33,11 +33,11 @@ class GetDiagnosticsTree extends CommandWithTarget { ...@@ -33,11 +33,11 @@ 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, String> json, DeserializeFinderFactory finderFactory) 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']),
super.deserialize(json, finderFactory); super.deserialize(json);
/// How many levels of children to include in the JSON result. /// How many levels of children to include in the JSON result.
/// ///
......
...@@ -9,25 +9,6 @@ import 'package:meta/meta.dart'; ...@@ -9,25 +9,6 @@ import 'package:meta/meta.dart';
import 'error.dart'; import 'error.dart';
import 'message.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]; const List<Type> _supportedKeyValueTypes = <Type>[String, int];
DriverError _createInvalidKeyValueTypeError(String invalidType) { DriverError _createInvalidKeyValueTypeError(String invalidType) {
...@@ -47,8 +28,8 @@ abstract class CommandWithTarget extends Command { ...@@ -47,8 +28,8 @@ abstract class CommandWithTarget extends Command {
} }
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
CommandWithTarget.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) CommandWithTarget.deserialize(Map<String, String> json)
: finder = finderFactory.deserializeFinder(json), : finder = SerializableFinder.deserialize(json),
super.deserialize(json); super.deserialize(json);
/// Locates the object or objects targeted by this command. /// Locates the object or objects targeted by this command.
...@@ -77,7 +58,7 @@ class WaitFor extends CommandWithTarget { ...@@ -77,7 +58,7 @@ class WaitFor 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].
WaitFor.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory); WaitFor.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
String get kind => 'waitFor'; String get kind => 'waitFor';
...@@ -107,7 +88,7 @@ class WaitForAbsent extends CommandWithTarget { ...@@ -107,7 +88,7 @@ class WaitForAbsent 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].
WaitForAbsent.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory); WaitForAbsent.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
String get kind => 'waitForAbsent'; String get kind => 'waitForAbsent';
...@@ -145,6 +126,22 @@ abstract class SerializableFinder { ...@@ -145,6 +126,22 @@ abstract class SerializableFinder {
Map<String, String> serialize() => <String, String>{ Map<String, String> serialize() => <String, String>{
'finderType': finderType, '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. /// A Flutter Driver finder that finds widgets by tooltip text.
...@@ -352,14 +349,14 @@ class Descendant extends SerializableFinder { ...@@ -352,14 +349,14 @@ 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, DeserializeFinderFactory finderFactory) { static Descendant deserialize(Map<String, String> json) {
final Map<String, String> jsonOfMatcher = final Map<String, String> jsonOfMatcher =
Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>); 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']) as Map<String, dynamic>); Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
return Descendant( return Descendant(
of: finderFactory.deserializeFinder(jsonOfMatcher), of: SerializableFinder.deserialize(jsonOfMatcher),
matching: finderFactory.deserializeFinder(jsonMatchingMatcher), matching: SerializableFinder.deserialize(jsonMatchingMatcher),
matchRoot: json['matchRoot'] == 'true', matchRoot: json['matchRoot'] == 'true',
firstMatchOnly: json['firstMatchOnly'] == 'true', firstMatchOnly: json['firstMatchOnly'] == 'true',
); );
...@@ -407,14 +404,14 @@ class Ancestor extends SerializableFinder { ...@@ -407,14 +404,14 @@ 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, DeserializeFinderFactory finderFactory) { static Ancestor deserialize(Map<String, String> json) {
final Map<String, String> jsonOfMatcher = final Map<String, String> jsonOfMatcher =
Map<String, String>.from(jsonDecode(json['of']) as Map<String, dynamic>); 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']) as Map<String, dynamic>); Map<String, String>.from(jsonDecode(json['matching']) as Map<String, dynamic>);
return Ancestor( return Ancestor(
of: finderFactory.deserializeFinder(jsonOfMatcher), of: SerializableFinder.deserialize(jsonOfMatcher),
matching: finderFactory.deserializeFinder(jsonMatchingMatcher), matching: SerializableFinder.deserialize(jsonMatchingMatcher),
matchRoot: json['matchRoot'] == 'true', matchRoot: json['matchRoot'] == 'true',
firstMatchOnly: json['firstMatchOnly'] == 'true', firstMatchOnly: json['firstMatchOnly'] == 'true',
); );
...@@ -439,8 +436,8 @@ class GetSemanticsId extends CommandWithTarget { ...@@ -439,8 +436,8 @@ class GetSemanticsId extends CommandWithTarget {
GetSemanticsId(SerializableFinder finder, {Duration timeout}) : super(finder, timeout: timeout); GetSemanticsId(SerializableFinder finder, {Duration timeout}) : super(finder, timeout: timeout);
/// Creates a command from a JSON map. /// Creates a command from a JSON map.
GetSemanticsId.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) GetSemanticsId.deserialize(Map<String, String> json)
: super.deserialize(json, finderFactory); : super.deserialize(json);
@override @override
String get kind => 'get_semantics_id'; String get kind => 'get_semantics_id';
......
...@@ -36,9 +36,9 @@ class GetOffset extends CommandWithTarget { ...@@ -36,9 +36,9 @@ 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, String> json, DeserializeFinderFactory finderFactory) GetOffset.deserialize(Map<String, String> json)
: offsetType = _offsetTypeIndex.lookupBySimpleName(json['offsetType']), : offsetType = _offsetTypeIndex.lookupBySimpleName(json['offsetType']),
super.deserialize(json, finderFactory); super.deserialize(json);
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
......
...@@ -11,7 +11,7 @@ class Tap extends CommandWithTarget { ...@@ -11,7 +11,7 @@ class Tap extends CommandWithTarget {
Tap(SerializableFinder finder, { Duration timeout }) : super(finder, timeout: timeout); Tap(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].
Tap.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory); Tap.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
String get kind => 'tap'; String get kind => 'tap';
...@@ -46,12 +46,12 @@ class Scroll extends CommandWithTarget { ...@@ -46,12 +46,12 @@ class Scroll 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].
Scroll.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) Scroll.deserialize(Map<String, String> json)
: dx = double.parse(json['dx']), : dx = double.parse(json['dx']),
dy = double.parse(json['dy']), dy = double.parse(json['dy']),
duration = Duration(microseconds: int.parse(json['duration'])), duration = Duration(microseconds: int.parse(json['duration'])),
frequency = int.parse(json['frequency']), frequency = int.parse(json['frequency']),
super.deserialize(json, finderFactory); super.deserialize(json);
/// Delta X offset per move event. /// Delta X offset per move event.
final double dx; final double dx;
...@@ -99,9 +99,9 @@ class ScrollIntoView extends CommandWithTarget { ...@@ -99,9 +99,9 @@ class ScrollIntoView extends CommandWithTarget {
ScrollIntoView(SerializableFinder finder, { this.alignment = 0.0, Duration timeout }) : super(finder, timeout: timeout); ScrollIntoView(SerializableFinder finder, { this.alignment = 0.0, Duration timeout }) : super(finder, timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
ScrollIntoView.deserialize(Map<String, String> json, DeserializeFinderFactory finderFactory) ScrollIntoView.deserialize(Map<String, String> json)
: alignment = double.parse(json['alignment']), : alignment = double.parse(json['alignment']),
super.deserialize(json, finderFactory); super.deserialize(json);
/// How the widget should be aligned. /// How the widget should be aligned.
/// ///
......
...@@ -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, String> json, DeserializeFinderFactory finderFactory) : super.deserialize(json, finderFactory); GetText.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
String get kind => 'get_text'; String get kind => 'get_text';
......
...@@ -37,7 +37,7 @@ void main() { ...@@ -37,7 +37,7 @@ void main() {
setUp(() { setUp(() {
result = null; result = null;
extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false, <FinderExtension>[]); extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
}); });
testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async { testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async {
...@@ -98,7 +98,7 @@ void main() { ...@@ -98,7 +98,7 @@ void main() {
setUp(() { setUp(() {
result = null; result = null;
extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false, <FinderExtension>[]); extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
}); });
testWidgets('waiting for NoTransientCallbacks returns immediately when transient callback queue is empty', (WidgetTester tester) async { testWidgets('waiting for NoTransientCallbacks returns immediately when transient callback queue is empty', (WidgetTester tester) async {
...@@ -464,7 +464,7 @@ void main() { ...@@ -464,7 +464,7 @@ void main() {
group('getSemanticsId', () { group('getSemanticsId', () {
FlutterDriverExtension extension; FlutterDriverExtension extension;
setUp(() { setUp(() {
extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); extension = FlutterDriverExtension((String arg) async => '', true);
}); });
testWidgets('works when semantics are enabled', (WidgetTester tester) async { testWidgets('works when semantics are enabled', (WidgetTester tester) async {
...@@ -513,7 +513,7 @@ void main() { ...@@ -513,7 +513,7 @@ void main() {
}); });
testWidgets('getOffset', (WidgetTester tester) async { testWidgets('getOffset', (WidgetTester tester) async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<Offset> getOffset(OffsetType offset) async { Future<Offset> getOffset(OffsetType offset) async {
final Map<String, String> arguments = GetOffset(ByValueKey(1), offset).serialize(); final Map<String, String> arguments = GetOffset(ByValueKey(1), offset).serialize();
...@@ -545,7 +545,7 @@ void main() { ...@@ -545,7 +545,7 @@ void main() {
testWidgets('getText', (WidgetTester tester) async { testWidgets('getText', (WidgetTester tester) async {
await silenceDriverLogger(() async { await silenceDriverLogger(() async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<String> getTextInternal(SerializableFinder search) async { Future<String> getTextInternal(SerializableFinder search) async {
final Map<String, String> arguments = GetText(search, timeout: const Duration(seconds: 1)).serialize(); final Map<String, String> arguments = GetText(search, timeout: const Duration(seconds: 1)).serialize();
...@@ -615,7 +615,7 @@ void main() { ...@@ -615,7 +615,7 @@ void main() {
testWidgets('descendant finder', (WidgetTester tester) async { testWidgets('descendant finder', (WidgetTester tester) async {
await silenceDriverLogger(() async { await silenceDriverLogger(() async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<String> getDescendantText({ String of, bool matchRoot = false}) async { Future<String> getDescendantText({ String of, bool matchRoot = false}) async {
final Map<String, String> arguments = GetText(Descendant( final Map<String, String> arguments = GetText(Descendant(
...@@ -660,7 +660,7 @@ void main() { ...@@ -660,7 +660,7 @@ void main() {
testWidgets('descendant finder firstMatchOnly', (WidgetTester tester) async { testWidgets('descendant finder firstMatchOnly', (WidgetTester tester) async {
await silenceDriverLogger(() async { await silenceDriverLogger(() async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<String> getDescendantText() async { Future<String> getDescendantText() async {
final Map<String, String> arguments = GetText(Descendant( final Map<String, String> arguments = GetText(Descendant(
...@@ -694,7 +694,7 @@ void main() { ...@@ -694,7 +694,7 @@ void main() {
testWidgets('ancestor finder', (WidgetTester tester) async { testWidgets('ancestor finder', (WidgetTester tester) async {
await silenceDriverLogger(() async { await silenceDriverLogger(() async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<Offset> getAncestorTopLeft({ String of, String matching, bool matchRoot = false}) async { Future<Offset> getAncestorTopLeft({ String of, String matching, bool matchRoot = false}) async {
final Map<String, String> arguments = GetOffset(Ancestor( final Map<String, String> arguments = GetOffset(Ancestor(
...@@ -764,7 +764,7 @@ void main() { ...@@ -764,7 +764,7 @@ void main() {
testWidgets('ancestor finder firstMatchOnly', (WidgetTester tester) async { testWidgets('ancestor finder firstMatchOnly', (WidgetTester tester) async {
await silenceDriverLogger(() async { await silenceDriverLogger(() async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<Offset> getAncestorTopLeft() async { Future<Offset> getAncestorTopLeft() async {
final Map<String, String> arguments = GetOffset(Ancestor( final Map<String, String> arguments = GetOffset(Ancestor(
...@@ -812,7 +812,7 @@ void main() { ...@@ -812,7 +812,7 @@ void main() {
}); });
testWidgets('GetDiagnosticsTree', (WidgetTester tester) async { testWidgets('GetDiagnosticsTree', (WidgetTester tester) async {
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
Future<Map<String, Object>> getDiagnosticsTree(DiagnosticsType type, SerializableFinder finder, { int depth = 0, bool properties = true }) async { Future<Map<String, Object>> getDiagnosticsTree(DiagnosticsType type, SerializableFinder finder, { int depth = 0, bool properties = true }) async {
final Map<String, String> arguments = GetDiagnosticsTree(finder, type, subtreeDepth: depth, includeProperties: properties).serialize(); final Map<String, String> arguments = GetDiagnosticsTree(finder, type, subtreeDepth: depth, includeProperties: properties).serialize();
...@@ -882,7 +882,7 @@ void main() { ...@@ -882,7 +882,7 @@ void main() {
Map<String, dynamic> result; Map<String, dynamic> result;
setUp(() { setUp(() {
extension = FlutterDriverExtension((String arg) async => '', true, <FinderExtension>[]); extension = FlutterDriverExtension((String arg) async => '', true);
result = null; result = null;
}); });
......
...@@ -2,15 +2,11 @@ ...@@ -2,15 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_driver/flutter_driver.dart';
import 'package:flutter_driver/src/common/find.dart'; import 'package:flutter_driver/src/common/find.dart';
import 'package:mockito/mockito.dart';
import '../../common.dart'; import '../../common.dart';
void main() { void main() {
MockDeserialize mockDeserialize;
test('Ancestor finder serialize', () { test('Ancestor finder serialize', () {
const SerializableFinder of = ByType('Text'); const SerializableFinder of = ByType('Text');
final SerializableFinder matching = ByValueKey('hello'); final SerializableFinder matching = ByValueKey('hello');
...@@ -39,7 +35,7 @@ void main() { ...@@ -39,7 +35,7 @@ void main() {
'firstMatchOnly': 'true', 'firstMatchOnly': 'true',
}; };
final Ancestor a = Ancestor.deserialize(serialized, mockDeserialize); final Ancestor a = Ancestor.deserialize(serialized);
expect(a.of, isA<ByType>()); expect(a.of, isA<ByType>());
expect(a.matching, isA<ByValueKey>()); expect(a.matching, isA<ByValueKey>());
expect(a.matchRoot, isTrue); expect(a.matchRoot, isTrue);
...@@ -74,12 +70,10 @@ void main() { ...@@ -74,12 +70,10 @@ void main() {
'firstMatchOnly': 'true', 'firstMatchOnly': 'true',
}; };
final Descendant a = Descendant.deserialize(serialized, mockDeserialize); final Descendant a = Descendant.deserialize(serialized);
expect(a.of, isA<ByType>()); expect(a.of, isA<ByType>());
expect(a.matching, isA<ByValueKey>()); expect(a.matching, isA<ByValueKey>());
expect(a.matchRoot, isTrue); expect(a.matchRoot, isTrue);
expect(a.firstMatchOnly, isTrue); expect(a.firstMatchOnly, isTrue);
}); });
} }
class MockDeserialize with Mock, DeserializeFinderFactory { }
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