[flutter_tools] migrate some files to null safety (#110354)
This commit is contained in:
@@ -2,14 +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 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/application_package.dart';
|
||||
import 'package:flutter_tools/src/base/dds.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart' as io;
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
@@ -19,7 +18,6 @@ import 'package:flutter_tools/src/drive/drive_service.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
@@ -425,10 +423,10 @@ void main() {
|
||||
}
|
||||
|
||||
FlutterDriverService setUpDriverService({
|
||||
Logger logger,
|
||||
ProcessManager processManager,
|
||||
FlutterVmService vmService,
|
||||
DevtoolsLauncher devtoolsLauncher,
|
||||
Logger? logger,
|
||||
ProcessManager? processManager,
|
||||
FlutterVmService? vmService,
|
||||
DevtoolsLauncher? devtoolsLauncher,
|
||||
}) {
|
||||
logger ??= BufferLogger.test();
|
||||
return FlutterDriverService(
|
||||
@@ -441,14 +439,14 @@ FlutterDriverService setUpDriverService({
|
||||
dartSdkPath: 'dart',
|
||||
devtoolsLauncher: devtoolsLauncher ?? FakeDevtoolsLauncher(),
|
||||
vmServiceConnector: (Uri httpUri, {
|
||||
ReloadSources reloadSources,
|
||||
Restart restart,
|
||||
CompileExpression compileExpression,
|
||||
GetSkSLMethod getSkSLMethod,
|
||||
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
|
||||
Object compression,
|
||||
Device device,
|
||||
@required Logger logger,
|
||||
ReloadSources? reloadSources,
|
||||
Restart? restart,
|
||||
CompileExpression? compileExpression,
|
||||
GetSkSLMethod? getSkSLMethod,
|
||||
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
|
||||
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
|
||||
Device? device,
|
||||
required Logger logger,
|
||||
}) async {
|
||||
assert(logger != null);
|
||||
if (httpUri.scheme != 'http') {
|
||||
@@ -457,7 +455,7 @@ FlutterDriverService setUpDriverService({
|
||||
if (httpUri.path.endsWith('/ws')) {
|
||||
fail('Expected HTTP uri to not contain `/ws`, found $httpUri');
|
||||
}
|
||||
return vmService;
|
||||
return vmService!;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -470,8 +468,8 @@ class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFa
|
||||
@override
|
||||
Future<ApplicationPackage> getPackageForPlatform(
|
||||
TargetPlatform platform, {
|
||||
BuildInfo buildInfo,
|
||||
File applicationBinary,
|
||||
BuildInfo? buildInfo,
|
||||
File? applicationBinary,
|
||||
}) async => applicationPackage;
|
||||
}
|
||||
|
||||
@@ -505,21 +503,21 @@ class FakeDevice extends Fake implements Device {
|
||||
|
||||
@override
|
||||
Future<DeviceLogReader> getLogReader({
|
||||
covariant ApplicationPackage app,
|
||||
covariant ApplicationPackage? app,
|
||||
bool includePastLogs = false,
|
||||
}) async => NoOpDeviceLogReader('test');
|
||||
|
||||
@override
|
||||
Future<LaunchResult> startApp(
|
||||
covariant ApplicationPackage package, {
|
||||
String mainPath,
|
||||
String route,
|
||||
DebuggingOptions debuggingOptions,
|
||||
Map<String, dynamic> platformArgs,
|
||||
String? mainPath,
|
||||
String? route,
|
||||
required DebuggingOptions debuggingOptions,
|
||||
Map<String, Object?> platformArgs = const <String, Object?>{},
|
||||
bool prebuiltApplication = false,
|
||||
bool ipv6 = false,
|
||||
String userIdentifier,
|
||||
}) async {
|
||||
String? userIdentifier,
|
||||
}) async {
|
||||
if (failOnce) {
|
||||
failOnce = false;
|
||||
return LaunchResult.failed();
|
||||
@@ -528,13 +526,13 @@ class FakeDevice extends Fake implements Device {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> stopApp(covariant ApplicationPackage app, {String userIdentifier}) async {
|
||||
Future<bool> stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async {
|
||||
didStopApp = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> uninstallApp(covariant ApplicationPackage app, {String userIdentifier}) async {
|
||||
Future<bool> uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async {
|
||||
didUninstallApp = true;
|
||||
return true;
|
||||
}
|
||||
@@ -555,10 +553,10 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
|
||||
@override
|
||||
Future<void> startDartDevelopmentService(
|
||||
Uri observatoryUri, {
|
||||
@required Logger logger,
|
||||
int hostPort,
|
||||
bool ipv6,
|
||||
bool disableServiceAuthCodes,
|
||||
required Logger logger,
|
||||
int? hostPort,
|
||||
bool? ipv6,
|
||||
bool? disableServiceAuthCodes,
|
||||
bool cacheStartupProfile = false,
|
||||
}) async {
|
||||
started = true;
|
||||
@@ -575,7 +573,7 @@ class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
|
||||
final Completer<void> _processStarted = Completer<void>();
|
||||
|
||||
@override
|
||||
Future<void> launch(Uri vmServiceUri, {List<String> additionalArguments}) {
|
||||
Future<void> launch(Uri vmServiceUri, {List<String>? additionalArguments}) {
|
||||
_processStarted.complete();
|
||||
return Completer<void>().future;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
import 'dart:typed_data';
|
||||
@@ -28,7 +26,7 @@ final Uint8List imageBytes = Uint8List.fromList(<int>[1, 2, 3, 4, 5]);
|
||||
void main() {
|
||||
|
||||
group('Test that TestGoldenComparator', () {
|
||||
FakeProcessManager processManager;
|
||||
late FakeProcessManager processManager;
|
||||
|
||||
setUp(() {
|
||||
processManager = FakeProcessManager.empty();
|
||||
@@ -63,7 +61,7 @@ void main() {
|
||||
webRenderer: WebRendererMode.html,
|
||||
);
|
||||
|
||||
final String result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
final String? result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
expect(result, null);
|
||||
});
|
||||
|
||||
@@ -92,7 +90,7 @@ void main() {
|
||||
webRenderer: WebRendererMode.canvaskit,
|
||||
);
|
||||
|
||||
final String result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
final String? result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
expect(result, 'some message');
|
||||
});
|
||||
|
||||
@@ -125,10 +123,10 @@ void main() {
|
||||
webRenderer: WebRendererMode.html,
|
||||
);
|
||||
|
||||
final String result1 = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
final String? result1 = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
expect(result1, 'some message');
|
||||
|
||||
final String result2 = await comparator.compareGoldens(testUri, imageBytes, goldenKey2, false);
|
||||
final String? result2 = await comparator.compareGoldens(testUri, imageBytes, goldenKey2, false);
|
||||
expect(result2, 'some other message');
|
||||
});
|
||||
|
||||
@@ -170,10 +168,10 @@ void main() {
|
||||
webRenderer: WebRendererMode.canvaskit,
|
||||
);
|
||||
|
||||
final String result1 = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
final String? result1 = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
expect(result1, 'some message');
|
||||
|
||||
final String result2 = await comparator.compareGoldens(testUri2, imageBytes, goldenKey2, false);
|
||||
final String? result2 = await comparator.compareGoldens(testUri2, imageBytes, goldenKey2, false);
|
||||
expect(result2, 'some other message');
|
||||
});
|
||||
|
||||
@@ -205,7 +203,7 @@ void main() {
|
||||
webRenderer: WebRendererMode.html,
|
||||
);
|
||||
|
||||
final String result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
final String? result = await comparator.compareGoldens(testUri, imageBytes, goldenKey, false);
|
||||
expect(result, null);
|
||||
|
||||
await comparator.close();
|
||||
|
||||
Reference in New Issue
Block a user