Flutter_driver nnbd (#74856)
This commit is contained in:
@@ -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 'dart:io';
|
||||
|
||||
import 'package:flutter_driver/src/common/error.dart';
|
||||
|
||||
@@ -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 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
@@ -13,8 +11,8 @@ import 'package:flutter_driver/src/common/layer_tree.dart';
|
||||
import 'package:flutter_driver/src/common/wait.dart';
|
||||
import 'package:flutter_driver/src/driver/driver.dart';
|
||||
import 'package:flutter_driver/src/driver/timeline.dart';
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
import 'package:quiver/testing/async.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
@@ -31,9 +29,9 @@ void main() {
|
||||
};
|
||||
|
||||
group('VMServiceFlutterDriver.connect', () {
|
||||
FakeVmService fakeClient;
|
||||
FakeVM fakeVM;
|
||||
FakeIsolate fakeIsolate;
|
||||
late FakeVmService fakeClient;
|
||||
late FakeVM fakeVM;
|
||||
late FakeIsolate fakeIsolate;
|
||||
|
||||
void expectLogContains(String message) {
|
||||
expect(log, anyElement(contains(message)));
|
||||
@@ -44,7 +42,7 @@ void main() {
|
||||
fakeIsolate = FakeIsolate();
|
||||
fakeVM = FakeVM(fakeIsolate);
|
||||
fakeClient = FakeVmService(fakeVM);
|
||||
vmServiceConnectFunction = (String url, Map<String, dynamic> headers) async {
|
||||
vmServiceConnectFunction = (String url, Map<String, dynamic>? headers) async {
|
||||
return fakeClient;
|
||||
};
|
||||
fakeClient.responses['get_health'] = makeFakeResponse(<String, dynamic>{'status': 'ok'});
|
||||
@@ -176,10 +174,10 @@ void main() {
|
||||
});
|
||||
|
||||
group('VMServiceFlutterDriver', () {
|
||||
FakeVmService fakeClient;
|
||||
late FakeVmService fakeClient;
|
||||
FakeVM fakeVM;
|
||||
FakeIsolate fakeIsolate;
|
||||
VMServiceFlutterDriver driver;
|
||||
late VMServiceFlutterDriver driver;
|
||||
|
||||
setUp(() {
|
||||
fakeIsolate = FakeIsolate();
|
||||
@@ -230,10 +228,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('tap', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.tap(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the tap command', () async {
|
||||
await driver.tap(find.text('foo'), timeout: _kTestTimeout);
|
||||
expect(fakeClient.commandLog, <String>[
|
||||
@@ -243,10 +237,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('getText', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getText(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the getText command', () async {
|
||||
fakeClient.responses['get_text'] = makeFakeResponse(<String, dynamic>{'text': 'hello'});
|
||||
final String result = await driver.getText(find.byValueKey(123), timeout: _kTestTimeout);
|
||||
@@ -274,10 +264,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('waitFor', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.waitFor(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the waitFor command', () async {
|
||||
fakeClient.responses['waitFor'] = makeFakeResponse(<String, dynamic>{});
|
||||
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
|
||||
@@ -363,14 +349,6 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getCenter(null), throwsAssertionError);
|
||||
expect(driver.getTopLeft(null), throwsAssertionError);
|
||||
expect(driver.getTopRight(null), throwsAssertionError);
|
||||
expect(driver.getBottomLeft(null), throwsAssertionError);
|
||||
expect(driver.getBottomRight(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the getCenter command', () async {
|
||||
final DriverOffset result = await driver.getCenter(find.byValueKey(123), timeout: _kTestTimeout);
|
||||
expect(result, const DriverOffset(11, 12));
|
||||
@@ -432,7 +410,7 @@ void main() {
|
||||
'setVMTimelineFlags []',
|
||||
'getVMTimeline null null',
|
||||
]);
|
||||
expect(timeline.events.single.name, 'test event');
|
||||
expect(timeline.events!.single.name, 'test event');
|
||||
});
|
||||
|
||||
test('with clearing timeline', () async {
|
||||
@@ -450,7 +428,7 @@ void main() {
|
||||
'setVMTimelineFlags []',
|
||||
'getVMTimeline 1 999999',
|
||||
]);
|
||||
expect(timeline.events.single.name, 'test event');
|
||||
expect(timeline.events!.single.name, 'test event');
|
||||
});
|
||||
|
||||
test('with time interval', () async {
|
||||
@@ -479,7 +457,7 @@ void main() {
|
||||
'getVMTimeline 1 999999',
|
||||
'getVMTimeline 1000001 999999',
|
||||
]);
|
||||
expect(timeline.events.map((TimelineEvent event) => event.name), <String>[
|
||||
expect(timeline.events!.map((TimelineEvent event) => event.name), <String>[
|
||||
'test event',
|
||||
'test event 2',
|
||||
]);
|
||||
@@ -508,7 +486,7 @@ void main() {
|
||||
'getVMTimeline null null'
|
||||
]);
|
||||
|
||||
expect(timeline.events.single.name, 'test event');
|
||||
expect(timeline.events!.single.name, 'test event');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -545,7 +523,7 @@ void main() {
|
||||
fail('expected an exception');
|
||||
} catch (error) {
|
||||
expect(error, isA<DriverError>());
|
||||
expect(error.message, 'Error in Flutter application: {message: This is a failure}');
|
||||
expect((error as DriverError).message, 'Error in Flutter application: {message: This is a failure}');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -570,10 +548,10 @@ void main() {
|
||||
});
|
||||
|
||||
group('VMServiceFlutterDriver with custom timeout', () {
|
||||
FakeVmService fakeClient;
|
||||
late FakeVmService fakeClient;
|
||||
FakeVM fakeVM;
|
||||
FakeIsolate fakeIsolate;
|
||||
VMServiceFlutterDriver driver;
|
||||
late VMServiceFlutterDriver driver;
|
||||
|
||||
setUp(() {
|
||||
fakeIsolate = FakeIsolate();
|
||||
@@ -601,8 +579,8 @@ void main() {
|
||||
});
|
||||
|
||||
group('WebFlutterDriver', () {
|
||||
FakeFlutterWebConnection fakeConnection;
|
||||
WebFlutterDriver driver;
|
||||
late FakeFlutterWebConnection fakeConnection;
|
||||
late WebFlutterDriver driver;
|
||||
|
||||
setUp(() {
|
||||
fakeConnection = FakeFlutterWebConnection();
|
||||
@@ -648,10 +626,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('tap', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.tap(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the tap command', () async {
|
||||
fakeConnection.responses['tap'] = jsonEncode(makeFakeResponse(<String, dynamic>{}));
|
||||
await driver.tap(find.text('foo'), timeout: _kTestTimeout);
|
||||
@@ -662,10 +636,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('getText', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getText(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the getText command', () async {
|
||||
fakeConnection.responses['get_text'] = jsonEncode(makeFakeResponse(<String, dynamic>{'text': 'hello'}));
|
||||
final String result = await driver.getText(find.byValueKey(123), timeout: _kTestTimeout);
|
||||
@@ -677,10 +647,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('waitFor', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.waitFor(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the waitFor command', () async {
|
||||
fakeConnection.responses['waitFor'] = jsonEncode(makeFakeResponse(<String, dynamic>{'text': 'hello'}));
|
||||
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
|
||||
@@ -737,13 +703,6 @@ void main() {
|
||||
'dy': 12,
|
||||
}));
|
||||
});
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getCenter(null), throwsAssertionError);
|
||||
expect(driver.getTopLeft(null), throwsAssertionError);
|
||||
expect(driver.getTopRight(null), throwsAssertionError);
|
||||
expect(driver.getBottomLeft(null), throwsAssertionError);
|
||||
expect(driver.getBottomRight(null), throwsAssertionError);
|
||||
});
|
||||
|
||||
test('sends the getCenter command', () async {
|
||||
final DriverOffset result = await driver.getCenter(find.byValueKey(123), timeout: _kTestTimeout);
|
||||
@@ -824,7 +783,7 @@ void main() {
|
||||
|
||||
group('WebFlutterDriver with non-chrome browser', () {
|
||||
FakeFlutterWebConnection fakeConnection;
|
||||
WebFlutterDriver driver;
|
||||
late WebFlutterDriver driver;
|
||||
|
||||
setUp(() {
|
||||
fakeConnection = FakeFlutterWebConnection();
|
||||
@@ -848,15 +807,15 @@ void main() {
|
||||
/// and return the actual script.
|
||||
/// script will be in the following format:
|
||||
// window.flutterDriver('[actual script]')
|
||||
String _checkAndEncode(dynamic script) {
|
||||
String? _checkAndEncode(dynamic script) {
|
||||
expect(script, isA<String>());
|
||||
expect(script.startsWith(_kWebScriptPrefix), isTrue);
|
||||
expect(script.endsWith(_kWebScriptSuffix), isTrue);
|
||||
// Strip prefix and suffix
|
||||
return script.substring(_kWebScriptPrefix.length, script.length - 2) as String;
|
||||
return script.substring(_kWebScriptPrefix.length, script.length - 2) as String?;
|
||||
}
|
||||
|
||||
vms.Response makeFakeResponse(
|
||||
vms.Response? makeFakeResponse(
|
||||
Map<String, dynamic> response, {
|
||||
bool isError = false,
|
||||
}) {
|
||||
@@ -873,9 +832,9 @@ class FakeFlutterWebConnection extends Fake implements FlutterWebConnection {
|
||||
Map<String, dynamic> responses = <String, dynamic>{};
|
||||
List<String> commandLog = <String>[];
|
||||
@override
|
||||
Future<dynamic> sendCommand(String script, Duration duration) async {
|
||||
Future<dynamic> sendCommand(String script, Duration? duration) async {
|
||||
commandLog.add('$script $duration');
|
||||
final Map<String, dynamic> decoded = jsonDecode(_checkAndEncode(script)) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> decoded = jsonDecode(_checkAndEncode(script)!) as Map<String, dynamic>;
|
||||
final dynamic response = responses[decoded['command']];
|
||||
assert(response != null, 'Missing ${decoded['command']} in responses.');
|
||||
return response;
|
||||
@@ -890,27 +849,27 @@ class FakeFlutterWebConnection extends Fake implements FlutterWebConnection {
|
||||
class FakeVmService extends Fake implements vms.VmService {
|
||||
FakeVmService(this.vm);
|
||||
|
||||
FakeVM vm;
|
||||
FakeVM? vm;
|
||||
bool failOnSetFlag = false;
|
||||
bool failOnResumeWith101 = false;
|
||||
|
||||
final List<String> connectionLog = <String>[];
|
||||
|
||||
@override
|
||||
Future<vms.VM> getVM() async => vm;
|
||||
Future<vms.VM> getVM() async => vm!;
|
||||
|
||||
@override
|
||||
Future<vms.Isolate> getIsolate(String isolateId) async {
|
||||
connectionLog.add('getIsolate');
|
||||
if (isolateId == vm.isolate.id) {
|
||||
return vm.isolate;
|
||||
if (isolateId == vm!.isolate!.id) {
|
||||
return vm!.isolate!;
|
||||
}
|
||||
return null;
|
||||
throw UnimplementedError('getIsolate called with unrecognized $isolateId');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<vms.Success> resume(String isolateId, {String step, int frameIndex}) async {
|
||||
assert(isolateId == vm.isolate.id);
|
||||
Future<vms.Success> resume(String isolateId, {String? step, int? frameIndex}) async {
|
||||
assert(isolateId == vm!.isolate!.id);
|
||||
connectionLog.add('resume');
|
||||
if (failOnResumeWith101) {
|
||||
throw vms.RPCError('resume', 101, '');
|
||||
@@ -950,15 +909,15 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
}
|
||||
|
||||
List<String> commandLog = <String>[];
|
||||
Map<String, vms.Response> responses = <String, vms.Response>{};
|
||||
Future<void> artificialExtensionDelay;
|
||||
Map<String, vms.Response?> responses = <String, vms.Response?>{};
|
||||
Future<void>? artificialExtensionDelay;
|
||||
|
||||
@override
|
||||
Future<vms.Response> callServiceExtension(String method, {Map<dynamic, dynamic> args, String isolateId}) async {
|
||||
Future<vms.Response> callServiceExtension(String method, {Map<dynamic, dynamic>? args, String? isolateId}) async {
|
||||
commandLog.add('$method $args');
|
||||
await artificialExtensionDelay;
|
||||
|
||||
final vms.Response response = responses[args['command']];
|
||||
final vms.Response response = responses[args!['command']]!;
|
||||
assert(response != null, 'Failed to create a response for ${args['command']}');
|
||||
return response;
|
||||
}
|
||||
@@ -993,7 +952,7 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
return vms.Success();
|
||||
}
|
||||
|
||||
final Map<int, vms.Timeline> timelineResponses = <int, vms.Timeline>{
|
||||
final Map<int, vms.Timeline?> timelineResponses = <int, vms.Timeline?>{
|
||||
1: vms.Timeline.parse(<String, dynamic>{
|
||||
'traceEvents': <dynamic>[
|
||||
<String, dynamic>{
|
||||
@@ -1006,9 +965,9 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
};
|
||||
|
||||
@override
|
||||
Future<vms.Timeline> getVMTimeline({int timeOriginMicros, int timeExtentMicros}) async {
|
||||
Future<vms.Timeline> getVMTimeline({int? timeOriginMicros, int? timeExtentMicros}) async {
|
||||
connectionLog.add('getVMTimeline $timeOriginMicros $timeExtentMicros');
|
||||
final vms.Timeline timeline = timelineResponses[timeOriginMicros ?? 1];
|
||||
final vms.Timeline timeline = timelineResponses[timeOriginMicros ?? 1]!;
|
||||
assert(timeline != null, 'Missing entry in timelineResponses[$timeOriginMicros]');
|
||||
return timeline;
|
||||
}
|
||||
@@ -1025,7 +984,7 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
class FakeVM extends Fake implements vms.VM {
|
||||
FakeVM(this.isolate);
|
||||
|
||||
vms.Isolate isolate;
|
||||
vms.Isolate? isolate;
|
||||
|
||||
int numberOfTriesBeforeResolvingIsolate = 0;
|
||||
|
||||
@@ -1034,7 +993,7 @@ class FakeVM extends Fake implements vms.VM {
|
||||
numberOfTriesBeforeResolvingIsolate -= 1;
|
||||
return <vms.Isolate>[
|
||||
if (numberOfTriesBeforeResolvingIsolate <= 0)
|
||||
isolate,
|
||||
isolate!,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1047,7 +1006,7 @@ class FakeIsolate extends Fake implements vms.Isolate {
|
||||
String get id => number;
|
||||
|
||||
@override
|
||||
vms.Event pauseEvent;
|
||||
vms.Event? pauseEvent;
|
||||
|
||||
@override
|
||||
List<String> get extensionRPCs => <String>[];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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_driver/driver_extension.dart';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:flutter_driver/src/common/find.dart';
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
// 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_driver/src/extension/_extension_io.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
|
||||
void main() {
|
||||
group('test io_extension',() {
|
||||
Future<Map<String, dynamic>> Function(Map<String, String>) call;
|
||||
late Future<Map<String, dynamic>> Function(Map<String, String>) call;
|
||||
|
||||
setUp(() {
|
||||
call = (Map<String, String> args) async {
|
||||
|
||||
@@ -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_driver/flutter_driver.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
|
||||
@@ -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 'dart:convert' show json;
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@@ -409,7 +407,7 @@ void main() {
|
||||
|
||||
group('writeTimelineToFile', () {
|
||||
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
useMemoryFileSystemForTesting();
|
||||
@@ -480,7 +478,7 @@ void main() {
|
||||
final Timeline timeline = Timeline.fromJson(<String, dynamic>{
|
||||
'traceEvents': traceEvents,
|
||||
});
|
||||
return SceneDisplayLagSummarizer(timeline.events);
|
||||
return SceneDisplayLagSummarizer(timeline.events!);
|
||||
}
|
||||
|
||||
test('average_vsyncs_missed', () async {
|
||||
@@ -531,7 +529,7 @@ void main() {
|
||||
final Timeline timeline = Timeline.fromJson(<String, dynamic>{
|
||||
'traceEvents': traceEvents,
|
||||
});
|
||||
return ProfilingSummarizer.fromEvents(timeline.events);
|
||||
return ProfilingSummarizer.fromEvents(timeline.events!);
|
||||
}
|
||||
|
||||
test('has_both_cpu_and_memory_usage', () async {
|
||||
|
||||
@@ -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_driver/src/driver/timeline.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
@@ -34,7 +32,7 @@ void main() {
|
||||
|
||||
expect(timeline.events, hasLength(2));
|
||||
|
||||
final TimelineEvent e1 = timeline.events[1];
|
||||
final TimelineEvent e1 = timeline.events![1];
|
||||
expect(e1.name, 'test event');
|
||||
expect(e1.category, 'test category');
|
||||
expect(e1.phase, 'B');
|
||||
@@ -46,7 +44,7 @@ void main() {
|
||||
expect(e1.threadTimestampMicros, 567);
|
||||
expect(e1.arguments, <String, dynamic>{'arg1': true});
|
||||
|
||||
final TimelineEvent e2 = timeline.events[0];
|
||||
final TimelineEvent e2 = timeline.events![0];
|
||||
expect(e2.name, isNull);
|
||||
expect(e2.category, isNull);
|
||||
expect(e2.phase, isNull);
|
||||
@@ -74,10 +72,10 @@ void main() {
|
||||
});
|
||||
|
||||
expect(timeline.events, hasLength(2));
|
||||
expect(timeline.events[0].timestampMicros, equals(456));
|
||||
expect(timeline.events[1].timestampMicros, equals(457));
|
||||
expect(timeline.events[0].name, equals('test event 2'));
|
||||
expect(timeline.events[1].name, equals('test event 1'));
|
||||
expect(timeline.events![0].timestampMicros, equals(456));
|
||||
expect(timeline.events![1].timestampMicros, equals(457));
|
||||
expect(timeline.events![0].name, equals('test event 2'));
|
||||
expect(timeline.events![1].name, equals('test event 1'));
|
||||
});
|
||||
|
||||
test('sorts JSON nulls first', () {
|
||||
@@ -103,14 +101,14 @@ void main() {
|
||||
});
|
||||
|
||||
expect(timeline.events, hasLength(4));
|
||||
expect(timeline.events[0].timestampMicros, isNull);
|
||||
expect(timeline.events[1].timestampMicros, isNull);
|
||||
expect(timeline.events[2].timestampMicros, equals(456));
|
||||
expect(timeline.events[3].timestampMicros, equals(457));
|
||||
expect(timeline.events[0].name, equals('test event 0'));
|
||||
expect(timeline.events[1].name, equals('test event 3'));
|
||||
expect(timeline.events[2].name, equals('test event 2'));
|
||||
expect(timeline.events[3].name, equals('test event 1'));
|
||||
expect(timeline.events![0].timestampMicros, isNull);
|
||||
expect(timeline.events![1].timestampMicros, isNull);
|
||||
expect(timeline.events![2].timestampMicros, equals(456));
|
||||
expect(timeline.events![3].timestampMicros, equals(457));
|
||||
expect(timeline.events![0].name, equals('test event 0'));
|
||||
expect(timeline.events![1].name, equals('test event 3'));
|
||||
expect(timeline.events![2].name, equals('test event 2'));
|
||||
expect(timeline.events![3].name, equals('test event 1'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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_driver/src/common/wait.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
|
||||
Reference in New Issue
Block a user