Unverified Commit 4453ba0a authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Null safety migration of packages/flutter_tools/test/general.shard, part 2/2 (#110712)

* Migrate packages/flutter_tools/test/general.shard, part 2/2

* Fix analysis

* Fix tests

* Fix analysis

* Apply suggestions from code review
Co-authored-by: 's avatarChristopher Fujino <fujino@google.com>
Co-authored-by: 's avatarChristopher Fujino <fujino@google.com>
parent 6c79dcca
...@@ -707,7 +707,7 @@ abstract class ResidentHandlers { ...@@ -707,7 +707,7 @@ abstract class ResidentHandlers {
} }
final List<FlutterView> views = await device!.vmService!.getFlutterViews(); final List<FlutterView> views = await device!.vmService!.getFlutterViews();
for (final FlutterView view in views) { for (final FlutterView view in views) {
final Map<String, Object>? rasterData = final Map<String, Object?>? rasterData =
await device.vmService!.renderFrameWithRasterStats( await device.vmService!.renderFrameWithRasterStats(
viewId: view.id, viewId: view.id,
uiIsolateId: view.uiIsolate!.id, uiIsolateId: view.uiIsolate!.id,
......
...@@ -557,7 +557,7 @@ class FlutterVmService { ...@@ -557,7 +557,7 @@ class FlutterVmService {
/// for rasterization which is not reflective of how long the frame takes in /// for rasterization which is not reflective of how long the frame takes in
/// production. This is primarily intended to be used to identify the layers /// production. This is primarily intended to be used to identify the layers
/// that result in the most raster perf degradation. /// that result in the most raster perf degradation.
Future<Map<String, Object>?> renderFrameWithRasterStats({ Future<Map<String, Object?>?> renderFrameWithRasterStats({
required String? viewId, required String? viewId,
required String? uiIsolateId, required String? uiIsolateId,
}) async { }) async {
...@@ -568,7 +568,7 @@ class FlutterVmService { ...@@ -568,7 +568,7 @@ class FlutterVmService {
'viewId': viewId, 'viewId': viewId,
}, },
); );
return response?.json as Map<String, Object>?; return response?.json;
} }
Future<String> flutterDebugDumpApp({ Future<String> flutterDebugDumpApp({
......
...@@ -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:args/args.dart'; import 'package:args/args.dart';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/executable.dart' as executable; import 'package:flutter_tools/executable.dart' as executable;
...@@ -111,7 +109,7 @@ void main() { ...@@ -111,7 +109,7 @@ void main() {
}); });
} }
void verifyCommandRunner(CommandRunner<Object> runner) { void verifyCommandRunner(CommandRunner<Object?> runner) {
expect(runner.argParser, isNotNull, reason: '${runner.runtimeType} has no argParser'); expect(runner.argParser, isNotNull, reason: '${runner.runtimeType} has no argParser');
expect(runner.argParser.allowsAnything, isFalse, reason: '${runner.runtimeType} allows anything'); expect(runner.argParser.allowsAnything, isFalse, reason: '${runner.runtimeType} allows anything');
expect(runner.argParser.allowTrailingOptions, isFalse, reason: '${runner.runtimeType} allows trailing options'); expect(runner.argParser.allowTrailingOptions, isFalse, reason: '${runner.runtimeType} allows trailing options');
...@@ -119,7 +117,7 @@ void verifyCommandRunner(CommandRunner<Object> runner) { ...@@ -119,7 +117,7 @@ void verifyCommandRunner(CommandRunner<Object> runner) {
runner.commands.values.forEach(verifyCommand); runner.commands.values.forEach(verifyCommand);
} }
void verifyCommand(Command<Object> runner) { void verifyCommand(Command<Object?> runner) {
expect(runner.argParser, isNotNull, reason: 'command ${runner.name} has no argParser'); expect(runner.argParser, isNotNull, reason: 'command ${runner.name} has no argParser');
verifyOptions(runner.name, runner.argParser.options.values); verifyOptions(runner.name, runner.argParser.options.values);
...@@ -161,7 +159,7 @@ const String _needHelp = "Every option must have help explaining what it does, e ...@@ -161,7 +159,7 @@ const String _needHelp = "Every option must have help explaining what it does, e
const String _header = ' Comment: '; const String _header = ' Comment: ';
void verifyOptions(String command, Iterable<Option> options) { void verifyOptions(String? command, Iterable<Option> options) {
String target; String target;
if (command == null) { if (command == null) {
target = 'the global argument "'; target = 'the global argument "';
...@@ -191,10 +189,11 @@ void verifyOptions(String command, Iterable<Option> options) { ...@@ -191,10 +189,11 @@ void verifyOptions(String command, Iterable<Option> options) {
if (option.defaultsTo != null) { if (option.defaultsTo != null) {
expect(option.help, isNot(contains('Default')), reason: '${_header}Help for $target--${option.name}" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).'); expect(option.help, isNot(contains('Default')), reason: '${_header}Help for $target--${option.name}" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).');
if (option.allowedHelp != null) { final Map<String, String>? allowedHelp = option.allowedHelp;
for (final String allowedValue in option.allowedHelp.keys) { if (allowedHelp != null) {
for (final String allowedValue in allowedHelp.keys) {
expect( expect(
option.allowedHelp[allowedValue], allowedHelp[allowedValue],
isNot(anyOf(contains('default'), contains('Default'))), isNot(anyOf(contains('default'), contains('Default'))),
reason: '${_header}Help for $target--${option.name} $allowedValue" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).', reason: '${_header}Help for $target--${option.name} $allowedValue" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).',
); );
...@@ -202,7 +201,7 @@ void verifyOptions(String command, Iterable<Option> options) { ...@@ -202,7 +201,7 @@ void verifyOptions(String command, Iterable<Option> options) {
} }
} }
expect(option.help, isNot(matches(_bannedArgumentReferencePatterns)), reason: '${_header}Help for $target--${option.name}" contains the string "--" in an unexpected way. If it\'s trying to mention another argument, it should be quoted, as in "--foo".'); expect(option.help, isNot(matches(_bannedArgumentReferencePatterns)), reason: '${_header}Help for $target--${option.name}" contains the string "--" in an unexpected way. If it\'s trying to mention another argument, it should be quoted, as in "--foo".');
for (final String line in option.help.split('\n')) { for (final String line in option.help!.split('\n')) {
if (!line.startsWith(' ')) { if (!line.startsWith(' ')) {
expect(line, isNot(contains(' ')), reason: '${_header}Help for $target--${option.name}" has excessive whitespace (check e.g. for double spaces after periods or round line breaks in the source).'); expect(line, isNot(contains(' ')), reason: '${_header}Help for $target--${option.name}" has excessive whitespace (check e.g. for double spaces after periods or round line breaks in the source).');
expect(line, matches(_allowedTrailingPatterns), reason: '${_header}A line in the help for $target--${option.name}" does not end with the expected period that a full sentence should end with. (If the help ends with a URL, place it after a colon, don\'t leave a trailing period; if it\'s sample code, prefix the line with four spaces.)'); expect(line, matches(_allowedTrailingPatterns), reason: '${_header}A line in the help for $target--${option.name}" does not end with the expected period that a full sentence should end with. (If the help ends with a URL, place it after a colon, don\'t leave a trailing period; if it\'s sample code, prefix the line with four spaces.)');
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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:file/memory.dart'; import 'package:file/memory.dart';
...@@ -45,10 +45,10 @@ const FakeCommand kListEmulatorsCommand = FakeCommand( ...@@ -45,10 +45,10 @@ const FakeCommand kListEmulatorsCommand = FakeCommand(
); );
void main() { void main() {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
FakeAndroidSdk sdk; late FakeAndroidSdk sdk;
FileSystem fileSystem; late FileSystem fileSystem;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -110,7 +110,16 @@ void main() { ...@@ -110,7 +110,16 @@ void main() {
}); });
testWithoutContext('getEmulatorsById', () async { testWithoutContext('getEmulatorsById', () async {
final TestEmulatorManager testEmulatorManager = TestEmulatorManager(emulators); final TestEmulatorManager testEmulatorManager = TestEmulatorManager(emulators,
logger: BufferLogger.test(),
processManager: fakeProcessManager,
androidWorkflow: AndroidWorkflow(
androidSdk: sdk,
featureFlags: TestFeatureFlags(),
operatingSystemUtils: FakeOperatingSystemUtils(),
),
fileSystem: fileSystem,
);
expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5'), <Emulator>[emulator1]); expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5'), <Emulator>[emulator1]);
expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5X'), <Emulator>[emulator2]); expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5X'), <Emulator>[emulator2]);
...@@ -340,7 +349,12 @@ void main() { ...@@ -340,7 +349,12 @@ void main() {
} }
class TestEmulatorManager extends EmulatorManager { class TestEmulatorManager extends EmulatorManager {
TestEmulatorManager(this.allEmulators); TestEmulatorManager(this.allEmulators, {
required super.logger,
required super.processManager,
required super.androidWorkflow,
required super.fileSystem,
});
final List<Emulator> allEmulators; final List<Emulator> allEmulators;
...@@ -374,16 +388,16 @@ class FakeEmulator extends Emulator { ...@@ -374,16 +388,16 @@ class FakeEmulator extends Emulator {
class FakeAndroidSdk extends Fake implements AndroidSdk { class FakeAndroidSdk extends Fake implements AndroidSdk {
@override @override
String avdManagerPath; String? avdManagerPath;
@override @override
String emulatorPath; String? emulatorPath;
@override @override
String adbPath; String? adbPath;
@override @override
String getAvdManagerPath() => avdManagerPath; String? getAvdManagerPath() => avdManagerPath;
@override @override
String getAvdPath() => 'avd'; String getAvdPath() => 'avd';
......
...@@ -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 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -28,9 +26,9 @@ import '../src/context.dart'; ...@@ -28,9 +26,9 @@ import '../src/context.dart';
import '../src/test_build_system.dart'; import '../src/test_build_system.dart';
void main() { void main() {
FakeFlutterDevice mockFlutterDevice; late FakeFlutterDevice mockFlutterDevice;
FakeWebDevFS mockWebDevFS; late FakeWebDevFS mockWebDevFS;
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -191,22 +189,22 @@ class FakeWebDevice extends Fake implements Device { ...@@ -191,22 +189,22 @@ class FakeWebDevice extends Fake implements Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
covariant ApplicationPackage app, { covariant ApplicationPackage? app, {
String userIdentifier, String? userIdentifier,
}) async { }) async {
return true; return true;
} }
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant ApplicationPackage package, { covariant ApplicationPackage? package, {
String mainPath, String? mainPath,
String route, String? route,
DebuggingOptions debuggingOptions, DebuggingOptions? debuggingOptions,
Map<String, dynamic> platformArgs, Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async { }) async {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
...@@ -219,14 +217,14 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -219,14 +217,14 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
final FakeWebDevice device; final FakeWebDevice device;
DevFS _devFS; DevFS? _devFS;
@override @override
DevFS get devFS => _devFS; DevFS? get devFS => _devFS;
@override @override
set devFS(DevFS value) { } set devFS(DevFS? value) { }
@override @override
FlutterVmService vmService; FlutterVmService? vmService;
} }
...@@ -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 'dart:async'; import 'dart:async';
import 'package:fake_async/fake_async.dart'; import 'package:fake_async/fake_async.dart';
...@@ -62,7 +60,7 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest( ...@@ -62,7 +60,7 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest(
void main() { void main() {
testWithoutContext('VmService registers reloadSources', () async { testWithoutContext('VmService registers reloadSources', () async {
Future<void> reloadSources(String isolateId, { bool pause, bool force}) async {} Future<void> reloadSources(String isolateId, { bool? pause, bool? force}) async {}
final MockVMService mockVMService = MockVMService(); final MockVMService mockVMService = MockVMService();
await setUpVmService( await setUpVmService(
...@@ -217,7 +215,7 @@ void main() { ...@@ -217,7 +215,7 @@ void main() {
windows: false, windows: false,
)); ));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>; final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[ expect(rawRequest, allOf(<Matcher>[
containsPair('method', kSetAssetBundlePathMethod), containsPair('method', kSetAssetBundlePathMethod),
...@@ -245,7 +243,7 @@ void main() { ...@@ -245,7 +243,7 @@ void main() {
windows: true, windows: true,
)); ));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>; final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[ expect(rawRequest, allOf(<Matcher>[
containsPair('method', kSetAssetBundlePathMethod), containsPair('method', kSetAssetBundlePathMethod),
...@@ -269,7 +267,7 @@ void main() { ...@@ -269,7 +267,7 @@ void main() {
viewId: 'abc', viewId: 'abc',
)); ));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>; final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[ expect(rawRequest, allOf(<Matcher>[
containsPair('method', kGetSkSLsMethod), containsPair('method', kGetSkSLsMethod),
...@@ -291,7 +289,7 @@ void main() { ...@@ -291,7 +289,7 @@ void main() {
uiIsolateId: 'def', uiIsolateId: 'def',
)); ));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>; final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[ expect(rawRequest, allOf(<Matcher>[
containsPair('method', kFlushUIThreadTasksMethod), containsPair('method', kFlushUIThreadTasksMethod),
...@@ -469,7 +467,7 @@ void main() { ...@@ -469,7 +467,7 @@ void main() {
] ]
); );
final Map<String, Object> skSLs = await fakeVmServiceHost.vmService.getSkSLs( final Map<String, Object?>? skSLs = await fakeVmServiceHost.vmService.getSkSLs(
viewId: '1234', viewId: '1234',
); );
expect(skSLs, isNull); expect(skSLs, isNull);
...@@ -477,19 +475,19 @@ void main() { ...@@ -477,19 +475,19 @@ void main() {
final List<FlutterView> views = await fakeVmServiceHost.vmService.getFlutterViews(); final List<FlutterView> views = await fakeVmServiceHost.vmService.getFlutterViews();
expect(views, isEmpty); expect(views, isEmpty);
final vm_service.Response screenshot = await fakeVmServiceHost.vmService.screenshot(); final vm_service.Response? screenshot = await fakeVmServiceHost.vmService.screenshot();
expect(screenshot, isNull); expect(screenshot, isNull);
final vm_service.Response screenshotSkp = await fakeVmServiceHost.vmService.screenshotSkp(); final vm_service.Response? screenshotSkp = await fakeVmServiceHost.vmService.screenshotSkp();
expect(screenshotSkp, isNull); expect(screenshotSkp, isNull);
// Checking that this doesn't throw. // Checking that this doesn't throw.
await fakeVmServiceHost.vmService.setTimelineFlags(<String>['test']); await fakeVmServiceHost.vmService.setTimelineFlags(<String>['test']);
final vm_service.Response timeline = await fakeVmServiceHost.vmService.getTimeline(); final vm_service.Response? timeline = await fakeVmServiceHost.vmService.getTimeline();
expect(timeline, isNull); expect(timeline, isNull);
final Map<String, Object> rasterStats = final Map<String, Object?>? rasterStats =
await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: '1', uiIsolateId: '12'); await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: '1', uiIsolateId: '12');
expect(rasterStats, isNull); expect(rasterStats, isNull);
...@@ -505,7 +503,7 @@ void main() { ...@@ -505,7 +503,7 @@ void main() {
] ]
); );
final vm_service.Isolate isolate = await fakeVmServiceHost.vmService.getIsolateOrNull( final vm_service.Isolate? isolate = await fakeVmServiceHost.vmService.getIsolateOrNull(
'isolate/123', 'isolate/123',
); );
expect(isolate, null); expect(isolate, null);
...@@ -535,7 +533,7 @@ void main() { ...@@ -535,7 +533,7 @@ void main() {
] ]
); );
final Map<String, Object> rasterStats = final Map<String, Object?>? rasterStats =
await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: 'view/1', uiIsolateId: 'isolate/123'); await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: 'view/1', uiIsolateId: 'isolate/123');
expect(rasterStats, equals(response)); expect(rasterStats, equals(response));
...@@ -629,7 +627,7 @@ void main() { ...@@ -629,7 +627,7 @@ void main() {
isolate.toJson() isolate.toJson()
..['id'] = '2' ..['id'] = '2'
..['extensionRPCs'] = <String>[otherExtensionName], ..['extensionRPCs'] = <String>[otherExtensionName],
); )!;
final FlutterView fakeFlutterView2 = FlutterView( final FlutterView fakeFlutterView2 = FlutterView(
id: '2', id: '2',
...@@ -680,7 +678,7 @@ void main() { ...@@ -680,7 +678,7 @@ void main() {
testWithoutContext('does not rethrow a sentinel exception if the initially queried flutter view disappears', () async { testWithoutContext('does not rethrow a sentinel exception if the initially queried flutter view disappears', () async {
const String otherExtensionName = 'ext.flutter.test.otherExtension'; const String otherExtensionName = 'ext.flutter.test.otherExtension';
final vm_service.Isolate isolate2 = vm_service.Isolate.parse( final vm_service.Isolate? isolate2 = vm_service.Isolate.parse(
isolate.toJson() isolate.toJson()
..['id'] = '2' ..['id'] = '2'
..['extensionRPCs'] = <String>[otherExtensionName], ..['extensionRPCs'] = <String>[otherExtensionName],
...@@ -836,7 +834,7 @@ void main() { ...@@ -836,7 +834,7 @@ void main() {
testUsingContext('WebSocket URL construction uses correct URI join primitives', () async { testUsingContext('WebSocket URL construction uses correct URI join primitives', () async {
final Completer<String> completer = Completer<String>(); final Completer<String> completer = Completer<String>();
openChannelForTesting = (String url, {io.CompressionOptions compression, Logger logger}) async { openChannelForTesting = (String url, {io.CompressionOptions compression = io.CompressionOptions.compressionDefault, required Logger logger}) async {
completer.complete(url); completer.complete(url);
throw Exception(''); throw Exception('');
}; };
...@@ -883,8 +881,8 @@ class FakeDevice extends Fake implements Device { } ...@@ -883,8 +881,8 @@ class FakeDevice extends Fake implements Device { }
/// A [WebSocketConnector] that always throws an [io.SocketException]. /// A [WebSocketConnector] that always throws an [io.SocketException].
Future<io.WebSocket> failingWebSocketConnector( Future<io.WebSocket> failingWebSocketConnector(
String url, { String url, {
io.CompressionOptions compression, io.CompressionOptions? compression,
Logger logger, Logger? logger,
}) { }) {
throw const io.SocketException('Failed WebSocket connection'); throw const io.SocketException('Failed WebSocket connection');
} }
...@@ -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 'dart:async'; import 'dart:async';
import 'dart:io' hide Directory, File; import 'dart:io' hide Directory, File;
...@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/globals.dart' as globals; ...@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/isolated/devfs_web.dart'; import 'package:flutter_tools/src/isolated/devfs_web.dart';
import 'package:flutter_tools/src/web/compile.dart'; import 'package:flutter_tools/src/web/compile.dart';
import 'package:logging/logging.dart' as logging; import 'package:logging/logging.dart' as logging;
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import 'package:shelf/shelf.dart'; import 'package:shelf/shelf.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
...@@ -41,14 +38,14 @@ const List<int> kTransparentImage = <int>[ ...@@ -41,14 +38,14 @@ const List<int> kTransparentImage = <int>[
]; ];
void main() { void main() {
Testbed testbed; late Testbed testbed;
WebAssetServer webAssetServer; late WebAssetServer webAssetServer;
ReleaseAssetServer releaseAssetServer; late ReleaseAssetServer releaseAssetServer;
Platform linux; late Platform linux;
PackageConfig packages; late PackageConfig packages;
Platform windows; late Platform windows;
FakeHttpServer httpServer; late FakeHttpServer httpServer;
BufferLogger logger; late BufferLogger logger;
setUpAll(() async { setUpAll(() async {
packages = PackageConfig(<Package>[ packages = PackageConfig(<Package>[
...@@ -66,15 +63,15 @@ void main() { ...@@ -66,15 +63,15 @@ void main() {
httpServer, httpServer,
packages, packages,
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
null, <String, String>{},
null, <String, String>{},
null, NullSafetyMode.unsound,
); );
releaseAssetServer = ReleaseAssetServer( releaseAssetServer = ReleaseAssetServer(
globals.fs.file('main.dart').uri, globals.fs.file('main.dart').uri,
fileSystem: null, // ignore: avoid_redundant_argument_values fileSystem: globals.fs,
flutterRoot: null, // ignore: avoid_redundant_argument_values flutterRoot: null, // ignore: avoid_redundant_argument_values
platform: null, // ignore: avoid_redundant_argument_values platform: FakePlatform(),
webBuildDirectory: null, // ignore: avoid_redundant_argument_values webBuildDirectory: null, // ignore: avoid_redundant_argument_values
basePath: null, basePath: null,
); );
...@@ -183,10 +180,10 @@ void main() { ...@@ -183,10 +180,10 @@ void main() {
})); }));
webAssetServer.write(source, manifest, sourcemap, metadata); webAssetServer.write(source, manifest, sourcemap, metadata);
final String merged = await webAssetServer.metadataContents('main_module.ddc_merged_metadata'); final String? merged = await webAssetServer.metadataContents('main_module.ddc_merged_metadata');
expect(merged, equals(metadataContents)); expect(merged, equals(metadataContents));
final String single = await webAssetServer.metadataContents('foo.js.metadata'); final String? single = await webAssetServer.metadataContents('foo.js.metadata');
expect(single, equals(metadataContents)); expect(single, equals(metadataContents));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => linux, Platform: () => linux,
...@@ -292,9 +289,9 @@ void main() { ...@@ -292,9 +289,9 @@ void main() {
httpServer, httpServer,
packages, packages,
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
null, <String, String>{},
null, <String, String>{},
null, NullSafetyMode.unsound,
); );
expect(webAssetServer.basePath, 'foo/bar'); expect(webAssetServer.basePath, 'foo/bar');
...@@ -311,9 +308,9 @@ void main() { ...@@ -311,9 +308,9 @@ void main() {
httpServer, httpServer,
packages, packages,
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
null, <String, String>{},
null, <String, String>{},
null, NullSafetyMode.unsound,
); );
// Defaults to "/" when there's no base element. // Defaults to "/" when there's no base element.
...@@ -332,9 +329,9 @@ void main() { ...@@ -332,9 +329,9 @@ void main() {
httpServer, httpServer,
packages, packages,
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
null, <String, String>{},
null, <String, String>{},
null, NullSafetyMode.unsound,
), ),
throwsToolExit(), throwsToolExit(),
); );
...@@ -352,9 +349,9 @@ void main() { ...@@ -352,9 +349,9 @@ void main() {
httpServer, httpServer,
packages, packages,
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
null, <String, String>{},
null, <String, String>{},
null, NullSafetyMode.unsound,
), ),
throwsToolExit(), throwsToolExit(),
); );
...@@ -380,7 +377,7 @@ void main() { ...@@ -380,7 +377,7 @@ void main() {
final Response response = await webAssetServer final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/foo.js'))); .handleRequest(Request('GET', Uri.parse('http://foobar/foo.js')));
final String etag = response.headers[HttpHeaders.etagHeader]; final String etag = response.headers[HttpHeaders.etagHeader]!;
final Response cachedResponse = await webAssetServer final Response cachedResponse = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/foo.js'), headers: <String, String>{ .handleRequest(Request('GET', Uri.parse('http://foobar/foo.js'), headers: <String, String>{
...@@ -622,14 +619,14 @@ void main() { ...@@ -622,14 +619,14 @@ void main() {
final Response response = await webAssetServer final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/fooπ'))); .handleRequest(Request('GET', Uri.parse('http://foobar/assets/fooπ')));
final String etag = response.headers[HttpHeaders.etagHeader]; final String etag = response.headers[HttpHeaders.etagHeader]!;
expect(etag.runes, everyElement(predicate((int char) => char < 255))); expect(etag.runes, everyElement(predicate((int char) => char < 255)));
})); }));
test('serves /packages/<package>/<path> files as if they were ' test('serves /packages/<package>/<path> files as if they were '
'package:<package>/<path> uris', () => testbed.run(() async { 'package:<package>/<path> uris', () => testbed.run(() async {
final Uri expectedUri = packages.resolve( final Uri? expectedUri = packages.resolve(
Uri.parse('package:flutter_tools/foo.dart')); Uri.parse('package:flutter_tools/foo.dart'));
final File source = globals.fs.file(globals.fs.path.fromUri(expectedUri)) final File source = globals.fs.file(globals.fs.path.fromUri(expectedUri))
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -691,13 +688,13 @@ void main() { ...@@ -691,13 +688,13 @@ void main() {
final Uri uri = await webDevFS.create(); final Uri uri = await webDevFS.create();
webDevFS.webAssetServer.entrypointCacheDirectory = globals.fs.currentDirectory; webDevFS.webAssetServer.entrypointCacheDirectory = globals.fs.currentDirectory;
final String webPrecompiledSdk = globals.artifacts final String webPrecompiledSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSdk).path; .getHostArtifact(HostArtifact.webPrecompiledSdk).path;
final String webPrecompiledSdkSourcemaps = globals.artifacts final String webPrecompiledSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSdkSourcemaps).path; .getHostArtifact(HostArtifact.webPrecompiledSdkSourcemaps).path;
final String webPrecompiledCanvaskitSdk = globals.artifacts final String webPrecompiledCanvaskitSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdk).path; .getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdk).path;
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdkSourcemaps).path; .getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdkSourcemaps).path;
globals.fs.currentDirectory globals.fs.currentDirectory
.childDirectory('lib') .childDirectory('lib')
...@@ -808,13 +805,13 @@ void main() { ...@@ -808,13 +805,13 @@ void main() {
.childFile('web_entrypoint.dart') .childFile('web_entrypoint.dart')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('GENERATED'); ..writeAsStringSync('GENERATED');
final String webPrecompiledSdk = globals.artifacts final String webPrecompiledSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSoundSdk).path; .getHostArtifact(HostArtifact.webPrecompiledSoundSdk).path;
final String webPrecompiledSdkSourcemaps = globals.artifacts final String webPrecompiledSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSoundSdkSourcemaps).path; .getHostArtifact(HostArtifact.webPrecompiledSoundSdkSourcemaps).path;
final String webPrecompiledCanvaskitSdk = globals.artifacts final String webPrecompiledCanvaskitSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdk).path; .getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdk).path;
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdkSourcemaps).path; .getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdkSourcemaps).path;
globals.fs.file(webPrecompiledSdk) globals.fs.file(webPrecompiledSdk)
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -917,7 +914,7 @@ void main() { ...@@ -917,7 +914,7 @@ void main() {
webDevFS.webAssetServer.dwds = FakeDwds(<AppConnection>[firstConnection, secondConnection]); webDevFS.webAssetServer.dwds = FakeDwds(<AppConnection>[firstConnection, secondConnection]);
int vmServiceFactoryInvocationCount = 0; int vmServiceFactoryInvocationCount = 0;
Future<vm_service.VmService> vmServiceFactory(Uri uri, {CompressionOptions compression, @required Logger logger}) { Future<vm_service.VmService> vmServiceFactory(Uri uri, {CompressionOptions? compression, required Logger logger}) {
if (vmServiceFactoryInvocationCount > 0) { if (vmServiceFactoryInvocationCount > 0) {
fail('Called vmServiceFactory twice!'); fail('Called vmServiceFactory twice!');
} }
...@@ -927,7 +924,7 @@ void main() { ...@@ -927,7 +924,7 @@ void main() {
() => FakeVmService(), () => FakeVmService(),
); );
} }
return webDevFS.connect(false, vmServiceFactory: vmServiceFactory).then<void>((ConnectionResult firstConnectionResult) { return webDevFS.connect(false, vmServiceFactory: vmServiceFactory).then<void>((ConnectionResult? firstConnectionResult) {
return webDevFS.destroy(); return webDevFS.destroy();
}); });
}); });
...@@ -1078,7 +1075,7 @@ void main() { ...@@ -1078,7 +1075,7 @@ void main() {
false, false,
Uri.base, Uri.base,
null, null,
null, NullSafetyMode.unsound,
testMode: true); testMode: true);
expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null); expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null);
...@@ -1179,20 +1176,20 @@ class FakeHttpServer extends Fake implements HttpServer { ...@@ -1179,20 +1176,20 @@ class FakeHttpServer extends Fake implements HttpServer {
} }
class FakeResidentCompiler extends Fake implements ResidentCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler {
CompilerOutput output; CompilerOutput? output;
@override @override
void addFileSystemRoot(String root) { } void addFileSystemRoot(String root) { }
@override @override
Future<CompilerOutput> recompile(Uri mainUri, List<Uri> invalidatedFiles, { Future<CompilerOutput?> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {
String outputPath, String? outputPath,
PackageConfig packageConfig, PackageConfig? packageConfig,
String projectRootPath, String? projectRootPath,
FileSystem fs, FileSystem? fs,
bool suppressErrors = false, bool suppressErrors = false,
bool checkDartPluginRegistry = false, bool checkDartPluginRegistry = false,
File dartPluginRegistrant, File? dartPluginRegistrant,
}) async { }) async {
return output; return output;
} }
...@@ -1202,7 +1199,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -1202,7 +1199,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler(TargetPlatform platform, { @required bool enableImpeller }) { } void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -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 'dart:convert'; import 'dart:convert';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -16,11 +14,11 @@ import '../../src/fakes.dart'; ...@@ -16,11 +14,11 @@ import '../../src/fakes.dart';
void main() { void main() {
group('Test that TestGoldenComparatorProcess', () { group('Test that TestGoldenComparatorProcess', () {
File imageFile; late File imageFile;
Uri goldenKey; late Uri goldenKey;
File imageFile2; late File imageFile2;
Uri goldenKey2; late Uri goldenKey2;
FakeProcess Function(String) createFakeProcess; late FakeProcess Function(String) createFakeProcess;
setUpAll(() { setUpAll(() {
imageFile = globals.fs.file('test_image_file'); imageFile = globals.fs.file('test_image_file');
......
...@@ -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/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart';
...@@ -22,13 +20,13 @@ void main() { ...@@ -22,13 +20,13 @@ void main() {
group('ScrubGeneratedPluginRegistrant', () { group('ScrubGeneratedPluginRegistrant', () {
// The files this migration deals with // The files this migration deals with
File gitignore; late File gitignore;
File registrant; late File registrant;
// Environment overrides // Environment overrides
FileSystem fileSystem; late FileSystem fileSystem;
ProcessManager processManager; late ProcessManager processManager;
BuildSystem buildSystem; late BuildSystem buildSystem;
setUp(() { setUp(() {
// Prepare environment overrides // Prepare environment overrides
......
...@@ -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/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -28,7 +26,7 @@ final Platform platform = FakePlatform( ...@@ -28,7 +26,7 @@ final Platform platform = FakePlatform(
); );
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
......
...@@ -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:dwds/dwds.dart'; import 'package:dwds/dwds.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -14,7 +12,7 @@ import 'package:test/fake.dart'; ...@@ -14,7 +12,7 @@ import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -27,7 +25,7 @@ void main() { ...@@ -27,7 +25,7 @@ void main() {
final ExpressionCompilationResult result = final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs( await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, null); '', '', 1, 1, <String, String>{}, <String, String>{}, '', '');
expectResult(result, false, 'a'); expectResult(result, false, 'a');
}); });
...@@ -39,7 +37,7 @@ void main() { ...@@ -39,7 +37,7 @@ void main() {
final ExpressionCompilationResult result = final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs( await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, null); '', '', 1, 1, <String, String>{}, <String, String>{}, '', '');
expectResult(result, true, 'Error: a'); expectResult(result, true, 'Error: a');
}); });
...@@ -50,7 +48,7 @@ void main() { ...@@ -50,7 +48,7 @@ void main() {
final ExpressionCompilationResult result = final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs( await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, 'a'); '', '', 1, 1, <String, String>{}, <String, String>{}, '', 'a');
expectResult(result, true, "InternalError: frontend server failed to compile 'a'"); expectResult(result, true, "InternalError: frontend server failed to compile 'a'");
}); });
...@@ -66,10 +64,10 @@ void expectResult(ExpressionCompilationResult result, bool isError, String value ...@@ -66,10 +64,10 @@ void expectResult(ExpressionCompilationResult result, bool isError, String value
class FakeResidentCompiler extends Fake implements ResidentCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler {
FakeResidentCompiler(this.output); FakeResidentCompiler(this.output);
final CompilerOutput output; final CompilerOutput? output;
@override @override
Future<CompilerOutput> compileExpressionToJs( Future<CompilerOutput?> compileExpressionToJs(
String libraryUri, String libraryUri,
int line, int line,
int column, int column,
......
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