|
|
|
|
@@ -2,8 +2,6 @@
|
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
// @dart = 2.8
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
|
@@ -37,14 +35,14 @@ Future<void> silenceDriverLogger(AsyncCallback callback) async {
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
group('waitUntilNoTransientCallbacks', () {
|
|
|
|
|
FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic> result;
|
|
|
|
|
late FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic>? result;
|
|
|
|
|
int messageId = 0;
|
|
|
|
|
final List<String> log = <String>[];
|
|
|
|
|
final List<String?> log = <String?>[];
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
result = null;
|
|
|
|
|
driverExtension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false, true);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? message) async { log.add(message); return (messageId += 1).toString(); }, false, true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async {
|
|
|
|
|
@@ -64,7 +62,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('waits until no transient callbacks', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
|
|
|
|
// Intentionally blank. We only care about existence of a callback.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -98,14 +96,14 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('waitForCondition', () {
|
|
|
|
|
FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic> result;
|
|
|
|
|
late FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic>? result;
|
|
|
|
|
int messageId = 0;
|
|
|
|
|
final List<String> log = <String>[];
|
|
|
|
|
final List<String?> log = <String?>[];
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
result = null;
|
|
|
|
|
driverExtension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false, true);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? message) async { log.add(message); return (messageId += 1).toString(); }, false, true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('waiting for NoTransientCallbacks returns immediately when transient callback queue is empty', (WidgetTester tester) async {
|
|
|
|
|
@@ -125,7 +123,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('waiting for NoTransientCallbacks returns until no transient callbacks', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
|
|
|
|
// Intentionally blank. We only care about existence of a callback.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -167,7 +165,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('waiting for NoPendingFrame returns until no pending scheduled frame', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrame();
|
|
|
|
|
|
|
|
|
|
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
|
|
|
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
|
|
|
@@ -210,8 +208,8 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
|
'waiting for combined conditions returns until no transient callbacks', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
|
|
|
|
// Intentionally blank. We only care about existence of a callback.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -239,8 +237,8 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
|
'waiting for combined conditions returns until no pending scheduled frame', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
|
|
|
|
// Intentionally blank. We only care about existence of a callback.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -288,11 +286,11 @@ void main() {
|
|
|
|
|
'waiting for NoPendingPlatformMessages returns until a single method channel call returns', (WidgetTester tester) async {
|
|
|
|
|
const MethodChannel channel = MethodChannel('helloChannel', JSONMethodCodec());
|
|
|
|
|
const MessageCodec<dynamic> jsonMessage = JSONMessageCodec();
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 10),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
channel.invokeMethod<String>('sayHello', 'hello');
|
|
|
|
|
|
|
|
|
|
@@ -322,20 +320,20 @@ void main() {
|
|
|
|
|
const MessageCodec<dynamic> jsonMessage = JSONMessageCodec();
|
|
|
|
|
// Configures channel 1
|
|
|
|
|
const MethodChannel channel1 = MethodChannel('helloChannel1', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 10),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Configures channel 2
|
|
|
|
|
const MethodChannel channel2 = MethodChannel('helloChannel2', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 20),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
channel1.invokeMethod<String>('sayHello', 'hello');
|
|
|
|
|
@@ -371,20 +369,20 @@ void main() {
|
|
|
|
|
const MessageCodec<dynamic> jsonMessage = JSONMessageCodec();
|
|
|
|
|
// Configures channel 1
|
|
|
|
|
const MethodChannel channel1 = MethodChannel('helloChannel1', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 10),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Configures channel 2
|
|
|
|
|
const MethodChannel channel2 = MethodChannel('helloChannel2', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 20),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
channel1.invokeMethod<String>('sayHello', 'hello');
|
|
|
|
|
@@ -422,20 +420,20 @@ void main() {
|
|
|
|
|
const MessageCodec<dynamic> jsonMessage = JSONMessageCodec();
|
|
|
|
|
// Configures channel 1
|
|
|
|
|
const MethodChannel channel1 = MethodChannel('helloChannel1', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel1', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 20),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Configures channel 2
|
|
|
|
|
const MethodChannel channel2 = MethodChannel('helloChannel2', JSONMethodCodec());
|
|
|
|
|
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData message) {
|
|
|
|
|
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(
|
|
|
|
|
'helloChannel2', (ByteData? message) {
|
|
|
|
|
return Future<ByteData>.delayed(
|
|
|
|
|
const Duration(milliseconds: 10),
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world']));
|
|
|
|
|
() => jsonMessage.encodeMessage(<dynamic>['hello world'])!);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
channel1.invokeMethod<String>('sayHello', 'hello');
|
|
|
|
|
@@ -469,13 +467,13 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('getSemanticsId', () {
|
|
|
|
|
FlutterDriverExtension driverExtension;
|
|
|
|
|
late FlutterDriverExtension driverExtension;
|
|
|
|
|
setUp(() {
|
|
|
|
|
driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('works when semantics are enabled', (WidgetTester tester) async {
|
|
|
|
|
final SemanticsHandle semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
|
|
|
|
|
final SemanticsHandle semantics = RendererBinding.instance!.pipelineOwner.ensureSemantics();
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
const Text('hello', textDirection: TextDirection.ltr));
|
|
|
|
|
|
|
|
|
|
@@ -499,7 +497,7 @@ void main() {
|
|
|
|
|
}, semanticsEnabled: false);
|
|
|
|
|
|
|
|
|
|
testWidgets('throws state error multiple matches are found', (WidgetTester tester) async {
|
|
|
|
|
final SemanticsHandle semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
|
|
|
|
|
final SemanticsHandle semantics = RendererBinding.instance!.pipelineOwner.ensureSemantics();
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
Directionality(
|
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
|
@@ -520,7 +518,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('getOffset', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
|
|
|
|
|
Future<Offset> getOffset(OffsetType offset) async {
|
|
|
|
|
final Map<String, String> arguments = GetOffset(ByValueKey(1), offset).serialize();
|
|
|
|
|
@@ -552,9 +550,9 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('getText', (WidgetTester tester) async {
|
|
|
|
|
await silenceDriverLogger(() async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, 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, dynamic> result = await driverExtension.call(arguments);
|
|
|
|
|
if (result['isError'] as bool) {
|
|
|
|
|
@@ -622,9 +620,9 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('descendant finder', (WidgetTester tester) async {
|
|
|
|
|
await silenceDriverLogger(() async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, 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(
|
|
|
|
|
of: ByValueKey(of),
|
|
|
|
|
matching: ByValueKey('text2'),
|
|
|
|
|
@@ -655,7 +653,7 @@ void main() {
|
|
|
|
|
expect(await getDescendantText(of: 'text2', matchRoot: true), 'Hello2');
|
|
|
|
|
|
|
|
|
|
// Find nothing
|
|
|
|
|
Future<String> result = getDescendantText(of: 'text1', matchRoot: true);
|
|
|
|
|
Future<String?> result = getDescendantText(of: 'text1', matchRoot: true);
|
|
|
|
|
await tester.pump(const Duration(seconds: 2));
|
|
|
|
|
expect(await result, null);
|
|
|
|
|
|
|
|
|
|
@@ -667,9 +665,9 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('descendant finder firstMatchOnly', (WidgetTester tester) async {
|
|
|
|
|
await silenceDriverLogger(() async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
|
|
|
|
|
Future<String> getDescendantText() async {
|
|
|
|
|
Future<String?> getDescendantText() async {
|
|
|
|
|
final Map<String, String> arguments = GetText(Descendant(
|
|
|
|
|
of: ByValueKey('column'),
|
|
|
|
|
matching: const ByType('Text'),
|
|
|
|
|
@@ -701,9 +699,9 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('ancestor finder', (WidgetTester tester) async {
|
|
|
|
|
await silenceDriverLogger(() async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, 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(
|
|
|
|
|
of: ByValueKey(of),
|
|
|
|
|
matching: ByValueKey(matching),
|
|
|
|
|
@@ -759,7 +757,7 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Find nothing
|
|
|
|
|
Future<Offset> result = getAncestorTopLeft(of: 'leftchild', matching: 'leftchild');
|
|
|
|
|
Future<Offset?> result = getAncestorTopLeft(of: 'leftchild', matching: 'leftchild');
|
|
|
|
|
await tester.pump(const Duration(seconds: 2));
|
|
|
|
|
expect(await result, null);
|
|
|
|
|
|
|
|
|
|
@@ -771,9 +769,9 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('ancestor finder firstMatchOnly', (WidgetTester tester) async {
|
|
|
|
|
await silenceDriverLogger(() async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
|
|
|
|
|
Future<Offset> getAncestorTopLeft() async {
|
|
|
|
|
Future<Offset?> getAncestorTopLeft() async {
|
|
|
|
|
final Map<String, String> arguments = GetOffset(Ancestor(
|
|
|
|
|
of: ByValueKey('leaf'),
|
|
|
|
|
matching: const ByType('Container'),
|
|
|
|
|
@@ -819,9 +817,9 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('GetDiagnosticsTree', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
|
|
|
|
|
Future<Map<String, Object>> getDiagnosticsTree(DiagnosticsType type, SerializableFinder finder, { int depth = 0, bool properties = true }) async {
|
|
|
|
|
Future<Map<String, dynamic>> 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 driverExtension.call(arguments);
|
|
|
|
|
final DiagnosticsTreeResult result = DiagnosticsTreeResult(response['response'] as Map<String, dynamic>);
|
|
|
|
|
@@ -838,12 +836,12 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Widget
|
|
|
|
|
Map<String, Object> result = await getDiagnosticsTree(DiagnosticsType.widget, ByValueKey('Text'), depth: 0);
|
|
|
|
|
Map<String, dynamic> result = await getDiagnosticsTree(DiagnosticsType.widget, ByValueKey('Text'), depth: 0);
|
|
|
|
|
expect(result['children'], isNull); // depth: 0
|
|
|
|
|
expect(result['widgetRuntimeType'], 'Text');
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> properties = (result['properties'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
Map<String, Object> stringProperty = properties.singleWhere((Map<String, Object> property) => property['name'] == 'data');
|
|
|
|
|
List<Map<String, dynamic>> properties = (result['properties']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
Map<String, dynamic> stringProperty = properties.singleWhere((Map<String, dynamic> property) => property['name'] == 'data');
|
|
|
|
|
expect(stringProperty['description'], '"Hello World"');
|
|
|
|
|
expect(stringProperty['propertyType'], 'String');
|
|
|
|
|
|
|
|
|
|
@@ -852,11 +850,11 @@ void main() {
|
|
|
|
|
expect(result['properties'], isNull); // properties: false
|
|
|
|
|
|
|
|
|
|
result = await getDiagnosticsTree(DiagnosticsType.widget, ByValueKey('Text'), depth: 1);
|
|
|
|
|
List<Map<String, Object>> children = (result['children'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
List<Map<String, dynamic>> children = (result['children']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
expect(children.single['children'], isNull);
|
|
|
|
|
|
|
|
|
|
result = await getDiagnosticsTree(DiagnosticsType.widget, ByValueKey('Text'), depth: 100);
|
|
|
|
|
children = (result['children'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
children = (result['children']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
expect(children.single['children'], isEmpty);
|
|
|
|
|
|
|
|
|
|
// RenderObject
|
|
|
|
|
@@ -870,22 +868,22 @@ void main() {
|
|
|
|
|
expect(result['description'], startsWith('RenderParagraph'));
|
|
|
|
|
|
|
|
|
|
result = await getDiagnosticsTree(DiagnosticsType.renderObject, ByValueKey('Text'), depth: 1);
|
|
|
|
|
children = (result['children'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
final Map<String, Object> textSpan = children.single;
|
|
|
|
|
children = (result['children']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
final Map<String, dynamic> textSpan = children.single;
|
|
|
|
|
expect(textSpan['description'], 'TextSpan');
|
|
|
|
|
properties = (textSpan['properties'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
stringProperty = properties.singleWhere((Map<String, Object> property) => property['name'] == 'text');
|
|
|
|
|
properties = (textSpan['properties']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
stringProperty = properties.singleWhere((Map<String, dynamic> property) => property['name'] == 'text');
|
|
|
|
|
expect(stringProperty['description'], '"Hello World"');
|
|
|
|
|
expect(stringProperty['propertyType'], 'String');
|
|
|
|
|
expect(children.single['children'], isNull);
|
|
|
|
|
|
|
|
|
|
result = await getDiagnosticsTree(DiagnosticsType.renderObject, ByValueKey('Text'), depth: 100);
|
|
|
|
|
children = (result['children'] as List<dynamic>).cast<Map<String, Object>>();
|
|
|
|
|
children = (result['children']! as List<Object>).cast<Map<String, dynamic>>();
|
|
|
|
|
expect(children.single['children'], isEmpty);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('enableTextEntryEmulation', () {
|
|
|
|
|
FlutterDriverExtension driverExtension;
|
|
|
|
|
late FlutterDriverExtension driverExtension;
|
|
|
|
|
|
|
|
|
|
Future<Map<String, dynamic>> enterText() async {
|
|
|
|
|
final Map<String, String> arguments = const EnterText('foo').serialize();
|
|
|
|
|
@@ -905,7 +903,7 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
testWidgets('enableTextEntryEmulation false', (WidgetTester tester) async {
|
|
|
|
|
driverExtension = FlutterDriverExtension((String arg) async => '', true, false);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? arg) async => '', true, false);
|
|
|
|
|
|
|
|
|
|
await tester.pumpWidget(testWidget);
|
|
|
|
|
|
|
|
|
|
@@ -914,7 +912,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('enableTextEntryEmulation true', (WidgetTester tester) async {
|
|
|
|
|
driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
|
|
|
|
|
await tester.pumpWidget(testWidget);
|
|
|
|
|
|
|
|
|
|
@@ -944,7 +942,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('unknown extension finder', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
finders: <FinderExtension>[],
|
|
|
|
|
@@ -960,12 +958,12 @@ void main() {
|
|
|
|
|
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'));
|
|
|
|
|
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 => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
finders: <FinderExtension>[
|
|
|
|
|
@@ -987,7 +985,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('complex extension finder', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
finders: <FinderExtension>[
|
|
|
|
|
@@ -1009,7 +1007,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('extension finder with command', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
finders: <FinderExtension>[
|
|
|
|
|
@@ -1054,7 +1052,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('unknown extension command', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
commands: <CommandExtension>[],
|
|
|
|
|
@@ -1070,12 +1068,12 @@ void main() {
|
|
|
|
|
final Map<String, dynamic> result = await invokeCommand(ByValueKey('Button'), 10);
|
|
|
|
|
expect(result['isError'], true);
|
|
|
|
|
expect(result['response'] is String, true);
|
|
|
|
|
expect(result['response'] as String, contains('Unsupported command kind StubNestedCommand'));
|
|
|
|
|
expect(result['response'] as String?, contains('Unsupported command kind StubNestedCommand'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('nested command', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
commands: <CommandExtension>[
|
|
|
|
|
@@ -1101,7 +1099,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets('prober command', (WidgetTester tester) async {
|
|
|
|
|
final FlutterDriverExtension driverExtension = FlutterDriverExtension(
|
|
|
|
|
(String arg) async => '',
|
|
|
|
|
(String? arg) async => '',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
commands: <CommandExtension>[
|
|
|
|
|
@@ -1127,11 +1125,11 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('waitUntilFrameSync', () {
|
|
|
|
|
FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic> result;
|
|
|
|
|
late FlutterDriverExtension driverExtension;
|
|
|
|
|
Map<String, dynamic>? result;
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
driverExtension = FlutterDriverExtension((String arg) async => '', true, true);
|
|
|
|
|
driverExtension = FlutterDriverExtension((String? arg) async => '', true, true);
|
|
|
|
|
result = null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -1154,7 +1152,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
|
'waits until no transient callbacks', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
|
|
|
|
// Intentionally blank. We only care about existence of a callback.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -1180,7 +1178,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
|
'waits until no pending scheduled frame', (WidgetTester tester) async {
|
|
|
|
|
SchedulerBinding.instance.scheduleFrame();
|
|
|
|
|
SchedulerBinding.instance!.scheduleFrame();
|
|
|
|
|
|
|
|
|
|
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
|
|
|
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
|
|
|
|