Unverified Commit 6d1938e6 authored by 嘟囔's avatar 嘟囔 Committed by GitHub

migrate integration.shard/vmservice_integration_test.dart to null safety (#92812)

parent 8b70641c
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -16,9 +14,9 @@ import 'test_utils.dart'; ...@@ -16,9 +14,9 @@ import 'test_utils.dart';
void main() { void main() {
group('Flutter Tool VMService method', () { group('Flutter Tool VMService method', () {
Directory tempDir; late Directory tempDir;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
VmService vmService; late VmService vmService;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('vmservice_integration_test.'); tempDir = createResolvedTempDirectorySync('vmservice_integration_test.');
...@@ -28,12 +26,13 @@ void main() { ...@@ -28,12 +26,13 @@ void main() {
flutter = FlutterRunTestDriver(tempDir); flutter = FlutterRunTestDriver(tempDir);
await flutter.run(withDebugger: true); await flutter.run(withDebugger: true);
final int port = flutter.vmServicePort; final int? port = flutter.vmServicePort;
expect(port != null, true);
vmService = await vmServiceConnectUri('ws://localhost:$port/ws'); vmService = await vmServiceConnectUri('ws://localhost:$port/ws');
}); });
tearDown(() async { tearDown(() async {
await flutter?.stop(); await flutter.stop();
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
...@@ -41,7 +40,7 @@ void main() { ...@@ -41,7 +40,7 @@ void main() {
final ProtocolList protocolList = final ProtocolList protocolList =
await vmService.getSupportedProtocols(); await vmService.getSupportedProtocols();
expect(protocolList.protocols, hasLength(2)); expect(protocolList.protocols, hasLength(2));
for (final Protocol protocol in protocolList.protocols) { for (final Protocol protocol in protocolList.protocols!) {
expect(protocol.protocolName, anyOf('VM Service', 'DDS')); expect(protocol.protocolName, anyOf('VM Service', 'DDS'));
} }
}); });
...@@ -62,10 +61,10 @@ void main() { ...@@ -62,10 +61,10 @@ void main() {
testWithoutContext('reloadSources can be called', () async { testWithoutContext('reloadSources can be called', () async {
final VM vm = await vmService.getVM(); final VM vm = await vmService.getVM();
final IsolateRef isolateRef = vm.isolates.first; final IsolateRef? isolateRef = vm.isolates?.first;
expect(isolateRef != null, true);
final Response response = await vmService.callMethod('s0.reloadSources', final Response response = await vmService.callMethod('s0.reloadSources',
isolateId: isolateRef.id); isolateId: isolateRef!.id);
expect(response.type, 'Success'); expect(response.type, 'Success');
}); });
...@@ -77,10 +76,10 @@ void main() { ...@@ -77,10 +76,10 @@ void main() {
testWithoutContext('hotRestart can be called', () async { testWithoutContext('hotRestart can be called', () async {
final VM vm = await vmService.getVM(); final VM vm = await vmService.getVM();
final IsolateRef isolateRef = vm.isolates.first; final IsolateRef? isolateRef = vm.isolates?.first;
expect(isolateRef != null, true);
final Response response = final Response response =
await vmService.callMethod('s0.hotRestart', isolateId: isolateRef.id); await vmService.callMethod('s0.hotRestart', isolateId: isolateRef!.id);
expect(response.type, 'Success'); expect(response.type, 'Success');
}); });
...@@ -102,7 +101,7 @@ void main() { ...@@ -102,7 +101,7 @@ void main() {
'ext.flutter.brightnessOverride', 'ext.flutter.brightnessOverride',
isolateId: isolate.id, isolateId: isolate.id,
); );
expect(response.json['value'], 'Brightness.light'); expect(response.json?['value'], 'Brightness.light');
final Response updateResponse = await vmService.callServiceExtension( final Response updateResponse = await vmService.callServiceExtension(
'ext.flutter.brightnessOverride', 'ext.flutter.brightnessOverride',
...@@ -111,7 +110,7 @@ void main() { ...@@ -111,7 +110,7 @@ void main() {
'value': 'Brightness.dark', 'value': 'Brightness.dark',
} }
); );
expect(updateResponse.json['value'], 'Brightness.dark'); expect(updateResponse.json?['value'], 'Brightness.dark');
// Change the brightness back to light // Change the brightness back to light
final Response verifyResponse = await vmService.callServiceExtension( final Response verifyResponse = await vmService.callServiceExtension(
...@@ -121,7 +120,7 @@ void main() { ...@@ -121,7 +120,7 @@ void main() {
'value': 'Brightness.light', 'value': 'Brightness.light',
} }
); );
expect(verifyResponse.json['value'], 'Brightness.light'); expect(verifyResponse.json?['value'], 'Brightness.light');
// Change with a bogus value // Change with a bogus value
final Response bogusResponse = await vmService.callServiceExtension( final Response bogusResponse = await vmService.callServiceExtension(
...@@ -131,7 +130,7 @@ void main() { ...@@ -131,7 +130,7 @@ void main() {
'value': 'dark', // Intentionally invalid value. 'value': 'dark', // Intentionally invalid value.
} }
); );
expect(bogusResponse.json['value'], 'Brightness.light'); expect(bogusResponse.json?['value'], 'Brightness.light');
}); });
testWithoutContext('ext.flutter.debugPaint can toggle debug painting', () async { testWithoutContext('ext.flutter.debugPaint can toggle debug painting', () async {
...@@ -140,7 +139,7 @@ void main() { ...@@ -140,7 +139,7 @@ void main() {
'ext.flutter.debugPaint', 'ext.flutter.debugPaint',
isolateId: isolate.id, isolateId: isolate.id,
); );
expect(response.json['enabled'], 'false'); expect(response.json?['enabled'], 'false');
final Response updateResponse = await vmService.callServiceExtension( final Response updateResponse = await vmService.callServiceExtension(
'ext.flutter.debugPaint', 'ext.flutter.debugPaint',
...@@ -149,7 +148,7 @@ void main() { ...@@ -149,7 +148,7 @@ void main() {
'enabled': 'true', 'enabled': 'true',
} }
); );
expect(updateResponse.json['enabled'], 'true'); expect(updateResponse.json?['enabled'], 'true');
}); });
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment