Reland "Flutter Driver - Create widget finders from serialized finders extensions" with null safety (#67711)
* Flutter Driver - Create widget finders from serialized finders extensions
This commit is contained in:
@@ -20,6 +20,9 @@ import 'package:flutter_driver/src/common/wait.dart';
|
||||
import 'package:flutter_driver/src/extension/extension.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'stubs/stub_finder.dart';
|
||||
import 'stubs/stub_finder_extension.dart';
|
||||
|
||||
Future<void> silenceDriverLogger(AsyncCallback callback) async {
|
||||
final DriverLogCallback oldLogger = driverLog;
|
||||
driverLog = (String source, String message) { };
|
||||
@@ -32,18 +35,18 @@ Future<void> silenceDriverLogger(AsyncCallback callback) async {
|
||||
|
||||
void main() {
|
||||
group('waitUntilNoTransientCallbacks', () {
|
||||
FlutterDriverExtension extension;
|
||||
FlutterDriverExtension driverExtension;
|
||||
Map<String, dynamic> result;
|
||||
int messageId = 0;
|
||||
final List<String> log = <String>[];
|
||||
|
||||
setUp(() {
|
||||
result = null;
|
||||
extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
|
||||
driverExtension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
|
||||
});
|
||||
|
||||
testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async {
|
||||
extension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||
driverExtension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -63,7 +66,7 @@ void main() {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
extension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||
driverExtension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -85,7 +88,7 @@ void main() {
|
||||
|
||||
testWidgets('handler', (WidgetTester tester) async {
|
||||
expect(log, isEmpty);
|
||||
final Map<String, dynamic> response = await extension.call(const RequestData('hello').serialize());
|
||||
final Map<String, dynamic> response = await driverExtension.call(const RequestData('hello').serialize());
|
||||
final RequestDataResult result = RequestDataResult.fromJson(response['response'] as Map<String, dynamic>);
|
||||
expect(log, <String>['hello']);
|
||||
expect(result.message, '1');
|
||||
@@ -93,18 +96,18 @@ void main() {
|
||||
});
|
||||
|
||||
group('waitForCondition', () {
|
||||
FlutterDriverExtension extension;
|
||||
FlutterDriverExtension driverExtension;
|
||||
Map<String, dynamic> result;
|
||||
int messageId = 0;
|
||||
final List<String> log = <String>[];
|
||||
|
||||
setUp(() {
|
||||
result = null;
|
||||
extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
|
||||
driverExtension = 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 {
|
||||
extension.call(const WaitForCondition(NoTransientCallbacks()).serialize())
|
||||
driverExtension.call(const WaitForCondition(NoTransientCallbacks()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -124,7 +127,7 @@ void main() {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
extension.call(const WaitForCondition(NoTransientCallbacks()).serialize())
|
||||
driverExtension.call(const WaitForCondition(NoTransientCallbacks()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -146,7 +149,7 @@ void main() {
|
||||
|
||||
testWidgets('waiting for NoPendingFrame returns immediately when frame is synced', (
|
||||
WidgetTester tester) async {
|
||||
extension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -164,7 +167,7 @@ void main() {
|
||||
testWidgets('waiting for NoPendingFrame returns until no pending scheduled frame', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
|
||||
extension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -188,7 +191,7 @@ void main() {
|
||||
'waiting for combined conditions returns immediately', (WidgetTester tester) async {
|
||||
const SerializableWaitCondition combinedCondition =
|
||||
CombinedCondition(<SerializableWaitCondition>[NoTransientCallbacks(), NoPendingFrame()]);
|
||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
driverExtension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -212,7 +215,7 @@ void main() {
|
||||
|
||||
const SerializableWaitCondition combinedCondition =
|
||||
CombinedCondition(<SerializableWaitCondition>[NoTransientCallbacks(), NoPendingFrame()]);
|
||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
driverExtension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -241,7 +244,7 @@ void main() {
|
||||
|
||||
const SerializableWaitCondition combinedCondition =
|
||||
CombinedCondition(<SerializableWaitCondition>[NoPendingFrame(), NoTransientCallbacks()]);
|
||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
driverExtension.call(const WaitForCondition(combinedCondition).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -263,7 +266,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
"waiting for NoPendingPlatformMessages returns immediately when there're no platform messages", (WidgetTester tester) async {
|
||||
extension
|
||||
driverExtension
|
||||
.call(const WaitForCondition(NoPendingPlatformMessages()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
@@ -291,7 +294,7 @@ void main() {
|
||||
});
|
||||
channel.invokeMethod<String>('sayHello', 'hello');
|
||||
|
||||
extension
|
||||
driverExtension
|
||||
.call(const WaitForCondition(NoPendingPlatformMessages()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
@@ -336,7 +339,7 @@ void main() {
|
||||
channel1.invokeMethod<String>('sayHello', 'hello');
|
||||
channel2.invokeMethod<String>('sayHello', 'hello');
|
||||
|
||||
extension
|
||||
driverExtension
|
||||
.call(const WaitForCondition(NoPendingPlatformMessages()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
@@ -385,7 +388,7 @@ void main() {
|
||||
channel1.invokeMethod<String>('sayHello', 'hello');
|
||||
|
||||
// Calls the waiting API before the second channel message is sent.
|
||||
extension
|
||||
driverExtension
|
||||
.call(const WaitForCondition(NoPendingPlatformMessages()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
@@ -435,7 +438,7 @@ void main() {
|
||||
|
||||
channel1.invokeMethod<String>('sayHello', 'hello');
|
||||
|
||||
extension
|
||||
driverExtension
|
||||
.call(const WaitForCondition(NoPendingPlatformMessages()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
@@ -464,9 +467,9 @@ void main() {
|
||||
});
|
||||
|
||||
group('getSemanticsId', () {
|
||||
FlutterDriverExtension extension;
|
||||
FlutterDriverExtension driverExtension;
|
||||
setUp(() {
|
||||
extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
});
|
||||
|
||||
testWidgets('works when semantics are enabled', (WidgetTester tester) async {
|
||||
@@ -475,7 +478,7 @@ void main() {
|
||||
const Text('hello', textDirection: TextDirection.ltr));
|
||||
|
||||
final Map<String, String> arguments = GetSemanticsId(const ByText('hello')).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson(response['response'] as Map<String, dynamic>);
|
||||
|
||||
expect(result.id, 1);
|
||||
@@ -487,7 +490,7 @@ void main() {
|
||||
const Text('hello', textDirection: TextDirection.ltr));
|
||||
|
||||
final Map<String, String> arguments = GetSemanticsId(const ByText('hello')).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
|
||||
expect(response['isError'], true);
|
||||
expect(response['response'], contains('Bad state: No semantics data found'));
|
||||
@@ -506,7 +509,7 @@ void main() {
|
||||
);
|
||||
|
||||
final Map<String, String> arguments = GetSemanticsId(const ByText('hello')).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
|
||||
expect(response['isError'], true);
|
||||
expect(response['response'], contains('Bad state: Found more than one element with the same ID'));
|
||||
@@ -515,11 +518,11 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('getOffset', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<Offset> getOffset(OffsetType offset) async {
|
||||
final Map<String, String> arguments = GetOffset(ByValueKey(1), offset).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
final GetOffsetResult result = GetOffsetResult.fromJson(response['response'] as Map<String, dynamic>);
|
||||
return Offset(result.dx, result.dy);
|
||||
}
|
||||
@@ -547,11 +550,11 @@ void main() {
|
||||
|
||||
testWidgets('getText', (WidgetTester tester) async {
|
||||
await silenceDriverLogger(() async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<String> getTextInternal(SerializableFinder search) async {
|
||||
final Map<String, String> arguments = GetText(search, timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> result = await extension.call(arguments);
|
||||
final Map<String, dynamic> result = await driverExtension.call(arguments);
|
||||
if (result['isError'] as bool) {
|
||||
return null;
|
||||
}
|
||||
@@ -609,7 +612,7 @@ void main() {
|
||||
|
||||
// Check if error thrown for other types
|
||||
final Map<String, String> arguments = GetText(ByValueKey('column'), timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
expect(response['isError'], true);
|
||||
expect(response['response'], contains('is currently not supported by getText'));
|
||||
});
|
||||
@@ -617,7 +620,7 @@ void main() {
|
||||
|
||||
testWidgets('descendant finder', (WidgetTester tester) async {
|
||||
await silenceDriverLogger(() async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<String> getDescendantText({ String of, bool matchRoot = false}) async {
|
||||
final Map<String, String> arguments = GetText(Descendant(
|
||||
@@ -625,7 +628,7 @@ void main() {
|
||||
matching: ByValueKey('text2'),
|
||||
matchRoot: matchRoot,
|
||||
), timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> result = await extension.call(arguments);
|
||||
final Map<String, dynamic> result = await driverExtension.call(arguments);
|
||||
if (result['isError'] as bool) {
|
||||
return null;
|
||||
}
|
||||
@@ -662,7 +665,7 @@ void main() {
|
||||
|
||||
testWidgets('descendant finder firstMatchOnly', (WidgetTester tester) async {
|
||||
await silenceDriverLogger(() async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<String> getDescendantText() async {
|
||||
final Map<String, String> arguments = GetText(Descendant(
|
||||
@@ -670,7 +673,7 @@ void main() {
|
||||
matching: const ByType('Text'),
|
||||
firstMatchOnly: true,
|
||||
), timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> result = await extension.call(arguments);
|
||||
final Map<String, dynamic> result = await driverExtension.call(arguments);
|
||||
if (result['isError'] as bool) {
|
||||
return null;
|
||||
}
|
||||
@@ -696,7 +699,7 @@ void main() {
|
||||
|
||||
testWidgets('ancestor finder', (WidgetTester tester) async {
|
||||
await silenceDriverLogger(() async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<Offset> getAncestorTopLeft({ String of, String matching, bool matchRoot = false}) async {
|
||||
final Map<String, String> arguments = GetOffset(Ancestor(
|
||||
@@ -704,7 +707,7 @@ void main() {
|
||||
matching: ByValueKey(matching),
|
||||
matchRoot: matchRoot,
|
||||
), OffsetType.topLeft, timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
if (response['isError'] as bool) {
|
||||
return null;
|
||||
}
|
||||
@@ -766,7 +769,7 @@ void main() {
|
||||
|
||||
testWidgets('ancestor finder firstMatchOnly', (WidgetTester tester) async {
|
||||
await silenceDriverLogger(() async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
Future<Offset> getAncestorTopLeft() async {
|
||||
final Map<String, String> arguments = GetOffset(Ancestor(
|
||||
@@ -774,7 +777,7 @@ void main() {
|
||||
matching: const ByType('Container'),
|
||||
firstMatchOnly: true,
|
||||
), OffsetType.topLeft, timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
if (response['isError'] as bool) {
|
||||
return null;
|
||||
}
|
||||
@@ -814,11 +817,11 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('GetDiagnosticsTree', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
|
||||
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, dynamic> response = await extension.call(arguments);
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
final DiagnosticsTreeResult result = DiagnosticsTreeResult(response['response'] as Map<String, dynamic>);
|
||||
return result.json;
|
||||
}
|
||||
@@ -879,18 +882,120 @@ void main() {
|
||||
expect(children.single['children'], isEmpty);
|
||||
});
|
||||
|
||||
group('extension finders', () {
|
||||
final Widget debugTree = Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: Column(
|
||||
key: const ValueKey<String>('Column'),
|
||||
children: <Widget>[
|
||||
const Text('Foo', key: ValueKey<String>('Text1')),
|
||||
const Text('Bar', key: ValueKey<String>('Text2')),
|
||||
FlatButton(
|
||||
child: const Text('Whatever'),
|
||||
key: const ValueKey<String>('Button'),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('unknown extension finder', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
||||
(String arg) async => '',
|
||||
true,
|
||||
finders: <FinderExtension>[],
|
||||
);
|
||||
|
||||
Future<Map<String, dynamic>> getText(SerializableFinder finder) async {
|
||||
final Map<String, String> arguments = GetText(finder, timeout: const Duration(seconds: 1)).serialize();
|
||||
return await driverExtension.call(arguments);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(debugTree);
|
||||
|
||||
final Map<String, dynamic> result = await getText(StubFinder('Text1'));
|
||||
expect(result['isError'], true);
|
||||
expect(result['response'] is String, true);
|
||||
expect(result['response'] as String, contains('Unsupported search specification type Stub'));
|
||||
});
|
||||
|
||||
testWidgets('simple extension finder', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
||||
(String arg) async => '',
|
||||
true,
|
||||
finders: <FinderExtension>[
|
||||
StubFinderExtension(),
|
||||
],
|
||||
);
|
||||
|
||||
Future<GetTextResult> getText(SerializableFinder finder) async {
|
||||
final Map<String, String> arguments = GetText(finder, timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
return GetTextResult.fromJson(response['response'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(debugTree);
|
||||
|
||||
final GetTextResult result = await getText(StubFinder('Text1'));
|
||||
expect(result.text, 'Foo');
|
||||
});
|
||||
|
||||
testWidgets('complex extension finder', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
||||
(String arg) async => '',
|
||||
true,
|
||||
finders: <FinderExtension>[
|
||||
StubFinderExtension(),
|
||||
],
|
||||
);
|
||||
|
||||
Future<GetTextResult> getText(SerializableFinder finder) async {
|
||||
final Map<String, String> arguments = GetText(finder, timeout: const Duration(seconds: 1)).serialize();
|
||||
final Map<String, dynamic> response = await driverExtension.call(arguments);
|
||||
return GetTextResult.fromJson(response['response'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(debugTree);
|
||||
|
||||
final GetTextResult result = await getText(Descendant(of: StubFinder('Column'), matching: StubFinder('Text1')));
|
||||
expect(result.text, 'Foo');
|
||||
});
|
||||
|
||||
testWidgets('extension finder with command', (WidgetTester tester) async {
|
||||
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
||||
(String arg) async => '',
|
||||
true,
|
||||
finders: <FinderExtension>[
|
||||
StubFinderExtension(),
|
||||
],
|
||||
);
|
||||
|
||||
Future<Map<String, dynamic>> tap(SerializableFinder finder) async {
|
||||
final Map<String, String> arguments = Tap(finder, timeout: const Duration(seconds: 1)).serialize();
|
||||
return await driverExtension.call(arguments);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(debugTree);
|
||||
|
||||
final Map<String, dynamic> result = await tap(StubFinder('Button'));
|
||||
expect(result['isError'], false);
|
||||
});
|
||||
});
|
||||
|
||||
group('waitUntilFrameSync', () {
|
||||
FlutterDriverExtension extension;
|
||||
FlutterDriverExtension driverExtension;
|
||||
Map<String, dynamic> result;
|
||||
|
||||
setUp(() {
|
||||
extension = FlutterDriverExtension((String arg) async => '', true);
|
||||
driverExtension = FlutterDriverExtension((String arg) async => '', true);
|
||||
result = null;
|
||||
});
|
||||
|
||||
testWidgets('returns immediately when frame is synced', (
|
||||
WidgetTester tester) async {
|
||||
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
driverExtension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -911,7 +1016,7 @@ void main() {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
driverExtension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
@@ -935,7 +1040,7 @@ void main() {
|
||||
'waits until no pending scheduled frame', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
|
||||
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
driverExtension.call(const WaitUntilNoPendingFrame().serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
result = r;
|
||||
}));
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
|
||||
class StubFinder extends SerializableFinder {
|
||||
StubFinder(this.keyString);
|
||||
|
||||
final String keyString;
|
||||
|
||||
@override
|
||||
String get finderType => 'Stub';
|
||||
|
||||
@override
|
||||
Map<String, String> serialize() {
|
||||
return super.serialize()..addAll(<String, String>{'keyString': keyString});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_driver/src/common/create_finder_factory.dart';
|
||||
import 'package:flutter_test/src/finders.dart';
|
||||
import 'package:flutter_driver/src/common/find.dart';
|
||||
|
||||
import 'stub_finder.dart';
|
||||
|
||||
class StubFinderExtension extends FinderExtension {
|
||||
@override
|
||||
Finder createFinder(
|
||||
SerializableFinder finder,
|
||||
CreateFinderFactory finderFactory,
|
||||
) {
|
||||
return find.byWidgetPredicate((Widget widget) {
|
||||
final Key? key = widget.key;
|
||||
if (key is! ValueKey<String>) {
|
||||
return false;
|
||||
}
|
||||
return key.value == (finder as StubFinder).keyString;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
SerializableFinder deserialize(
|
||||
Map<String, String> params,
|
||||
DeserializeFinderFactory finderFactory,
|
||||
) {
|
||||
return StubFinder(params['keyString']!);
|
||||
}
|
||||
|
||||
@override
|
||||
String get finderType => 'Stub';
|
||||
}
|
||||
Reference in New Issue
Block a user