Unverified Commit db829c1e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] migrate more unit tests to null safety (#106153)

parent 2af82503
......@@ -210,10 +210,10 @@ DevFSContent? processSkSLBundle(String? bundlePath, {
}
// Step 2: validate top level bundle structure.
Map<String, Object>? bundle;
Map<String, Object?>? bundle;
try {
final Object? rawBundle = json.decode(skSLBundleFile.readAsStringSync());
if (rawBundle is Map<String, Object>) {
if (rawBundle is Map<String, Object?>) {
bundle = rawBundle;
} else {
logger.printError('"$bundle" was not a JSON object: $rawBundle');
......
......@@ -389,10 +389,10 @@ class Cache {
throw Exception('Could not find file at $versionFilePath');
}
final dynamic data = jsonDecode(versionFile.readAsStringSync());
if (data is! Map<String, Object>) {
throw Exception("Expected object of type 'Map<String, Object>' but got one of type '${data.runtimeType}'");
if (data is! Map<String, Object?>) {
throw Exception("Expected object of type 'Map<String, Object?>' but got one of type '${data.runtimeType}'");
}
final dynamic version = data['version'];
final Object? version = data['version'];
if (version == null) {
throw Exception('Could not parse DevTools version from $version');
}
......
......@@ -668,11 +668,11 @@ abstract class CreateBase extends FlutterCommand {
'templates',
'template_manifest.json',
);
final Map<String, Object> manifest = json.decode(
final Map<String, Object?> manifest = json.decode(
globals.fs.file(manifestPath).readAsStringSync(),
) as Map<String, Object>;
) as Map<String, Object?>;
return Set<Uri>.from(
(manifest['files']! as List<Object>).cast<String>().map<Uri>(
(manifest['files']! as List<Object?>).cast<String>().map<Uri>(
(String path) =>
Uri.file(globals.fs.path.join(flutterToolsAbsolutePath, path))),
);
......
......@@ -86,8 +86,8 @@ abstract class MacOSApp extends ApplicationPackage {
return null;
}
final Map<String, dynamic> propertyValues = globals.plistParser.parseFile(plistPath);
final String id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String;
final String executableName = propertyValues[PlistParser.kCFBundleExecutable] as String;
final String? id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String?;
final String? executableName = propertyValues[PlistParser.kCFBundleExecutable] as String?;
if (id == null) {
globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier');
return null;
......
......@@ -1534,7 +1534,7 @@ abstract class FlutterCommand extends Command<void> {
if (!argParser.options.containsKey(name)) {
return null;
}
return argResults![name] as String;
return argResults![name] as String?;
}
/// Gets the parsed command-line option named [name] as an `int`.
......
......@@ -117,7 +117,7 @@ class CoverageCollector extends TestWatcher {
);
final Future<void> collectionComplete = testDevice.observatoryUri
.then((Uri observatoryUri) {
.then((Uri? observatoryUri) {
_logMessage('collecting coverage data from $testDevice at $observatoryUri...');
return collect(observatoryUri, libraryNames)
.then<void>((Map<String, dynamic> result) {
......
......@@ -494,7 +494,7 @@ class FlutterPlatform extends PlatformPlugin {
await Future.any<void>(<Future<void>>[
testDevice.finished,
() async {
final Uri processObservatoryUri = await testDevice.observatoryUri;
final Uri? processObservatoryUri = await testDevice.observatoryUri;
if (processObservatoryUri != null) {
globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri');
} else {
......
......@@ -47,8 +47,7 @@ class FlutterTesterTestDevice extends TestDevice {
}) : assert(shellPath != null), // Please provide the path to the shell in the SKY_SHELL environment variable.
assert(!debuggingOptions.startPaused || enableObservatory),
_gotProcessObservatoryUri = enableObservatory
// ignore: null_argument_to_non_null_type
? Completer<Uri>() : (Completer<Uri>()..complete()),
? Completer<Uri?>() : (Completer<Uri?>()..complete()),
_operatingSystemUtils = OperatingSystemUtils(
fileSystem: fileSystem,
logger: logger,
......@@ -73,7 +72,7 @@ class FlutterTesterTestDevice extends TestDevice {
final CompileExpression? compileExpression;
final FontConfigManager fontConfigManager;
final Completer<Uri> _gotProcessObservatoryUri;
final Completer<Uri?> _gotProcessObservatoryUri;
final Completer<int> _exitCode = Completer<int>();
Process? _process;
......@@ -209,7 +208,7 @@ class FlutterTesterTestDevice extends TestDevice {
}
@override
Future<Uri> get observatoryUri {
Future<Uri?> get observatoryUri {
assert(_gotProcessObservatoryUri != null);
return _gotProcessObservatoryUri.future;
}
......
......@@ -79,7 +79,7 @@ class TestCompiler {
late File outputDill;
Future<String?> compile(Uri mainDart) {
final Completer<String> completer = Completer<String>();
final Completer<String?> completer = Completer<String?>();
if (compilerController.isClosed) {
return Future<String?>.value();
}
......@@ -175,7 +175,7 @@ class TestCompiler {
// compiler to avoid reusing compiler that might have gotten into
// a weird state.
if (outputPath == null || compilerOutput!.errorCount > 0) {
request.result.complete(null);
request.result.complete();
await _shutdown();
} else {
if (shouldCopyDillFile) {
......
......@@ -22,7 +22,7 @@ abstract class TestDevice {
Future<StreamChannel<String>> start(String entrypointPath);
/// Should complete with null if the observatory is not enabled.
Future<Uri> get observatoryUri;
Future<Uri?> get observatoryUri;
/// Terminates the test device.
Future<void> kill();
......
......@@ -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:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_workflow.dart';
......@@ -37,8 +35,8 @@ void main() {
});
group('analytics', () {
Directory tempDir;
Config testConfig;
late Directory tempDir;
late Config testConfig;
setUp(() {
Cache.flutterRoot = '../..';
......@@ -108,7 +106,7 @@ void main() {
});
testUsingContext('Usage records one feature in experiment setting', () async {
testConfig.setValue(flutterWebFeature.configSetting, true);
testConfig.setValue(flutterWebFeature.configSetting!, true);
final Usage usage = Usage(runningOnBot: true);
usage.sendCommand('test');
......@@ -126,9 +124,9 @@ void main() {
});
testUsingContext('Usage records multiple features in experiment setting', () async {
testConfig.setValue(flutterWebFeature.configSetting, true);
testConfig.setValue(flutterLinuxDesktopFeature.configSetting, true);
testConfig.setValue(flutterMacOSDesktopFeature.configSetting, true);
testConfig.setValue(flutterWebFeature.configSetting!, true);
testConfig.setValue(flutterLinuxDesktopFeature.configSetting!, true);
testConfig.setValue(flutterMacOSDesktopFeature.configSetting!, true);
final Usage usage = Usage(runningOnBot: true);
usage.sendCommand('test');
......@@ -150,11 +148,11 @@ void main() {
});
group('analytics with fakes', () {
MemoryFileSystem memoryFileSystem;
FakeStdio fakeStdio;
TestUsage testUsage;
FakeClock fakeClock;
FakeDoctor doctor;
late MemoryFileSystem memoryFileSystem;
late FakeStdio fakeStdio;
late TestUsage testUsage;
late FakeClock fakeClock;
late FakeDoctor doctor;
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
......@@ -211,7 +209,7 @@ void main() {
testUsingContext('compound command usage path', () async {
final BuildCommand buildCommand = BuildCommand();
final FlutterCommand buildApkCommand = buildCommand.subcommands['apk'] as FlutterCommand;
final FlutterCommand buildApkCommand = buildCommand.subcommands['apk']! as FlutterCommand;
expect(await buildApkCommand.usagePath, 'build/apk');
}, overrides: <Type, Generator>{
......@@ -280,7 +278,7 @@ void main() {
});
group('analytics bots', () {
Directory tempDir;
late Directory tempDir;
setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.');
......@@ -341,8 +339,8 @@ Analytics throwingAnalyticsIOFactory(
String trackingId,
String applicationName,
String applicationVersion, {
String analyticsUrl,
Directory documentDirectory,
String? analyticsUrl,
Directory? documentDirectory,
}) {
throw const FileSystemException('Could not create file');
}
......@@ -368,9 +366,9 @@ class FakeDoctor extends Fake implements Doctor {
bool androidLicenses = false,
bool verbose = true,
bool showColor = true,
AndroidLicenseValidator androidLicenseValidator,
AndroidLicenseValidator? androidLicenseValidator,
bool showPii = true,
List<ValidatorTask> startedValidatorTasks,
List<ValidatorTask>? startedValidatorTasks,
bool sendEvent = true,
}) async {
return diagnoseSucceeds;
......
......@@ -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:archive/archive.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
......@@ -27,10 +25,10 @@ import '../../src/fake_process_manager.dart';
void main() {
group('gradle build', () {
BufferLogger logger;
TestUsage testUsage;
FileSystem fileSystem;
FakeProcessManager processManager;
late BufferLogger logger;
late TestUsage testUsage;
late FileSystem fileSystem;
late FakeProcessManager processManager;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -99,10 +97,10 @@ void main() {
return line.contains('Some gradle message');
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool multidexEnabled
String? line,
FlutterProject? project,
bool? usesAndroidX,
bool? multidexEnabled
}) async {
handlerCalled = true;
return GradleBuildStatus.exit;
......@@ -263,10 +261,10 @@ void main() {
return false;
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool multidexEnabled
String? line,
FlutterProject? project,
bool? usesAndroidX,
bool? multidexEnabled
}) async {
return GradleBuildStatus.retry;
},
......@@ -351,10 +349,10 @@ void main() {
return line.contains('Some gradle message');
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool multidexEnabled
String? line,
FlutterProject? project,
bool? usesAndroidX,
bool? multidexEnabled
}) async {
handlerCalled = true;
return GradleBuildStatus.exit;
......@@ -517,10 +515,10 @@ void main() {
return line.contains('Some gradle message');
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool multidexEnabled
String? line,
FlutterProject? project,
bool? usesAndroidX,
bool? multidexEnabled
}) async {
return GradleBuildStatus.retry;
},
......@@ -595,7 +593,7 @@ void main() {
.childDirectory('flutter-apk')
.childFile('app-release.apk')
..createSync(recursive: true)
..writeAsBytesSync(ZipEncoder().encode(archive));
..writeAsBytesSync(ZipEncoder().encode(archive)!);
fileSystem.file('foo/snapshot.arm64-v8a.json')
..createSync(recursive: true)
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/android/android_studio_validator.dart';
import 'package:flutter_tools/src/base/config.dart';
......@@ -24,8 +22,8 @@ final Platform linuxPlatform = FakePlatform(
);
void main() {
FileSystem fileSystem;
FakeProcessManager fakeProcessManager;
late FileSystem fileSystem;
late FakeProcessManager fakeProcessManager;
setUp(() {
fileSystem = MemoryFileSystem.test();
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/android/deferred_components_prebuild_validator.dart';
import 'package:flutter_tools/src/android/deferred_components_validator.dart';
......@@ -16,11 +14,11 @@ import '../../src/common.dart';
import '../../src/context.dart';
void main() {
FileSystem fileSystem;
BufferLogger logger;
Directory projectDir;
Platform platform;
Directory flutterRootDir;
late FileSystem fileSystem;
late BufferLogger logger;
late Directory projectDir;
late Platform platform;
late Directory flutterRootDir;
setUp(() {
fileSystem = MemoryFileSystem.test();
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/gradle.dart';
......@@ -33,7 +31,7 @@ void main() {
Cache.flutterRoot = getFlutterRoot();
group('build artifacts', () {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -194,8 +192,8 @@ void main() {
});
group('Gradle local.properties', () {
Artifacts localEngineArtifacts;
FileSystem fs;
late Artifacts localEngineArtifacts;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem.test();
......@@ -211,7 +209,7 @@ void main() {
});
}
String propertyFor(String key, File file) {
String? propertyFor(String key, File file) {
final Iterable<String> result = file.readAsLinesSync()
.where((String line) => line.startsWith('$key='))
.map((String line) => line.split('=')[1]);
......@@ -219,10 +217,10 @@ void main() {
}
Future<void> checkBuildVersion({
String manifest,
BuildInfo buildInfo,
String expectedBuildName,
String expectedBuildNumber,
required String manifest,
BuildInfo? buildInfo,
String? expectedBuildName,
String? expectedBuildNumber,
}) async {
final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true);
......@@ -457,7 +455,7 @@ flutter:
});
group('isAppUsingAndroidX', () {
FileSystem fs;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem.test();
......@@ -503,8 +501,8 @@ flutter:
});
group('printHowToConsumeAar', () {
BufferLogger logger;
FileSystem fileSystem;
late BufferLogger logger;
late FileSystem fileSystem;
setUp(() {
logger = BufferLogger.test();
......@@ -694,8 +692,8 @@ flutter:
// If this test fails, you probably edited templates/app/android.tmpl.
// That's fine, but you now need to add a copy of that file to gradle/settings.gradle.legacy_versions, separated
// from the previous versions by a line that just says ";EOF".
final File templateSettingsDotGradle = globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'app', 'android.tmpl', 'settings.gradle'));
final File legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'packages','flutter_tools', 'gradle', 'settings.gradle.legacy_versions'));
final File templateSettingsDotGradle = globals.fs.file(globals.fs.path.join(Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'app', 'android.tmpl', 'settings.gradle'));
final File legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(Cache.flutterRoot!, 'packages','flutter_tools', 'gradle', 'settings.gradle.legacy_versions'));
expect(
legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()),
contains(templateSettingsDotGradle.readAsStringSync().trim()),
......
......@@ -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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/multidex.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';
import 'package:file/file.dart';
......@@ -24,9 +22,9 @@ void main() {
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator);
return path.replaceAll('/', globals.fs.path.separator);
}
void writePubspecFile(String path, String name, { String fontsSection }) {
void writePubspecFile(String path, String name, { String? fontsSection }) {
if (fontsSection == null) {
fontsSection = '';
} else {
......@@ -61,14 +59,14 @@ $fontsSection
String expectedAssetManifest,
) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
for (final String packageName in packages) {
for (final String packageFont in packageFonts) {
final String entryKey = 'packages/$packageName/$packageFont';
expect(bundle.entries.containsKey(entryKey), true);
expect(
utf8.decode(await bundle.entries[entryKey].contentsAsBytes()),
utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()),
packageFont,
);
}
......@@ -76,14 +74,14 @@ $fontsSection
for (final String localFont in localFonts) {
expect(bundle.entries.containsKey(localFont), true);
expect(
utf8.decode(await bundle.entries[localFont].contentsAsBytes()),
utf8.decode(await bundle.entries[localFont]!.contentsAsBytes()),
localFont,
);
}
}
expect(
json.decode(utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes())),
json.decode(utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes())),
json.decode(expectedAssetManifest),
);
}
......@@ -95,7 +93,7 @@ $fontsSection
}
group('AssetBundle fonts from packages', () {
FileSystem testFileSystem;
FileSystem? testFileSystem;
setUp(() async {
testFileSystem = MemoryFileSystem(
......@@ -103,7 +101,7 @@ $fontsSection
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
testFileSystem.currentDirectory = testFileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
testFileSystem!.currentDirectory = testFileSystem!.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
});
testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async {
......@@ -112,7 +110,7 @@ $fontsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
expect(bundle.entries.containsKey('FontManifest.json'), isTrue);
}, overrides: <Type, Generator>{
......
......@@ -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';
import 'package:file/file.dart';
......@@ -24,9 +22,9 @@ void main() {
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator);
return path.replaceAll('/', globals.fs.path.separator);
}
void writePubspecFile(String path, String name, { List<String> assets }) {
void writePubspecFile(String path, String name, { List<String>? assets }) {
String assetsSection;
if (assets == null) {
assetsSection = '';
......@@ -65,11 +63,11 @@ $assetsSection
Future<void> buildAndVerifyAssets(
List<String> assets,
List<String> packages,
String expectedAssetManifest, {
String? expectedAssetManifest, {
bool expectExists = true,
}) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
for (final String packageName in packages) {
for (final String asset in assets) {
......@@ -78,7 +76,7 @@ $assetsSection
reason: 'Cannot find key on bundle: $entryKey');
if (expectExists) {
expect(
utf8.decode(await bundle.entries[entryKey].contentsAsBytes()),
utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()),
asset,
);
}
......@@ -87,7 +85,7 @@ $assetsSection
if (expectExists) {
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest,
);
}
......@@ -103,7 +101,7 @@ $assetsSection
}
}
FileSystem testFileSystem;
late FileSystem testFileSystem;
setUp(() async {
testFileSystem = MemoryFileSystem(
......@@ -121,15 +119,15 @@ $assetsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}';
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest,
);
expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()),
'[]',
);
}, overrides: <Type, Generator>{
......@@ -146,15 +144,15 @@ $assetsSection
writeAssets('p/p/', assets);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}';
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest,
);
expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()),
'[]',
);
}, overrides: <Type, Generator>{
......@@ -540,7 +538,7 @@ $assetsSection
writeAssets('p/p/', assetsOnDisk);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries['AssetManifest.json'], isNull,
reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' );
......
......@@ -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';
import 'package:file/file.dart';
......@@ -24,11 +22,11 @@ void main() {
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator);
return path.replaceAll('/', globals.fs.path.separator);
}
group('AssetBundle asset variants', () {
FileSystem testFileSystem;
late FileSystem testFileSystem;
setUp(() async {
testFileSystem = MemoryFileSystem(
style: globals.platform.isWindows
......@@ -67,24 +65,24 @@ flutter:
}
AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
// The main asset file, /a/b/c/foo, and its variants exist.
for (final String asset in assets) {
expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset);
expect(utf8.decode(await bundle.entries[asset]!.contentsAsBytes()), asset);
}
globals.fs.file(fixPath('a/b/c/foo')).deleteSync();
bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
// Now the main asset file, /a/b/c/foo, does not exist. This is OK because
// the /a/b/c/*/foo variants do exist.
expect(bundle.entries.containsKey('a/b/c/foo'), false);
for (final String asset in assets.skip(1)) {
expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset);
expect(utf8.decode(await bundle.entries[asset]!.contentsAsBytes()), asset);
}
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
......
......@@ -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_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
......@@ -86,5 +84,5 @@ void main() {
}
Future<String> getValueAsString(String key, AssetBundle asset) async {
return String.fromCharCodes(await asset.entries[key].contentsAsBytes());
return String.fromCharCodes(await asset.entries[key]!.contentsAsBytes());
}
......@@ -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_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
......@@ -21,9 +19,9 @@ final Platform windowsPlatform = FakePlatform(
);
void main() {
Testbed testbed;
SourceVisitor visitor;
Environment environment;
late Testbed testbed;
late SourceVisitor visitor;
late Environment environment;
setUp(() {
testbed = Testbed(setup: () {
......@@ -33,7 +31,7 @@ void main() {
environment = Environment.test(
globals.fs.currentDirectory,
outputDir: outputs,
artifacts: globals.artifacts, // using real artifacts
artifacts: globals.artifacts!, // using real artifacts
processManager: FakeProcessManager.any(),
fileSystem: globals.fs,
// engineVersion being null simulates a local engine.
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -21,10 +19,10 @@ import '../../../src/context.dart';
import '../../../src/fake_process_manager.dart';
void main() {
FakeProcessManager processManager;
FileSystem fileSystem;
Artifacts artifacts;
Logger logger;
late FakeProcessManager processManager;
late FileSystem fileSystem;
late Artifacts artifacts;
late Logger logger;
setUp(() {
logger = BufferLogger.test();
......
......@@ -2,8 +2,7 @@
// 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:collection/collection.dart' show IterableExtension;
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -21,8 +20,8 @@ import '../../../src/common.dart';
import '../../../src/context.dart';
void main() {
Environment environment;
FileSystem fileSystem;
late Environment environment;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -75,7 +74,7 @@ flutter:
final Depfile dependencies = depfileService.parse(depfile);
expect(
dependencies.inputs.firstWhere((File file) => file.path == '/bar/LICENSE', orElse: () => null),
dependencies.inputs.firstWhereOrNull((File file) => file.path == '/bar/LICENSE'),
isNotNull,
);
}, overrides: <Type, Generator>{
......@@ -124,7 +123,6 @@ flutter:
targetPlatform: TargetPlatform.android,
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
engineVersion: null,
), isNull);
});
......@@ -136,7 +134,6 @@ flutter:
targetPlatform: TargetPlatform.android,
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
engineVersion: null,
), throwsException);
});
......@@ -152,7 +149,6 @@ flutter:
targetPlatform: TargetPlatform.android,
fileSystem: fileSystem,
logger: logger,
engineVersion: null,
), throwsException);
expect(logger.errorText, contains('was not a JSON object'));
});
......@@ -169,7 +165,6 @@ flutter:
targetPlatform: TargetPlatform.android,
fileSystem: fileSystem,
logger: logger,
engineVersion: null,
), throwsException);
expect(logger.errorText, contains('was not a JSON object'));
});
......@@ -214,7 +209,7 @@ flutter:
fileSystem: fileSystem,
logger: logger,
engineVersion: '2',
);
)!;
expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}'));
expect(logger.errorText, contains('This may lead to less efficient shader caching'));
......@@ -238,7 +233,7 @@ flutter:
fileSystem: fileSystem,
logger: logger,
engineVersion: '2',
);
)!;
expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}'));
expect(logger.errorText, isEmpty);
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -26,12 +24,12 @@ const String kAssemblyAot = '--snapshot_kind=app-aot-assembly';
final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment: <String, String>{});
void main() {
FakeProcessManager processManager;
Environment androidEnvironment;
Environment iosEnvironment;
Artifacts artifacts;
FileSystem fileSystem;
Logger logger;
late FakeProcessManager processManager;
late Environment androidEnvironment;
late Environment iosEnvironment;
late Artifacts artifacts;
late FileSystem fileSystem;
late Logger logger;
setUp(() {
processManager = FakeProcessManager.empty();
......
......@@ -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
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -19,8 +17,8 @@ import '../../../src/context.dart';
// These tests perform a simple check to verify if the check/task was executed at all.
// Detailed per-check tests are in android/deferred_components_setup_validator_test.dart.
void main() {
FileSystem fileSystem;
BufferLogger logger;
late FileSystem fileSystem;
late BufferLogger logger;
setUp(() {
logger = BufferLogger.test();
......@@ -55,9 +53,9 @@ void main() {
await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.inputs.length, 3);
expect(validatorTarget.validator.inputs[0].path, 'project/pubspec.yaml');
expect(validatorTarget.validator.inputs[1].path, 'project/android/app/src/main/AndroidManifest.xml');
expect(validatorTarget.validator!.inputs.length, 3);
expect(validatorTarget.validator!.inputs[0].path, 'project/pubspec.yaml');
expect(validatorTarget.validator!.inputs[1].path, 'project/android/app/src/main/AndroidManifest.xml');
});
testUsingContext('checkAgainstLoadingUnitsCache checks runs', () async {
......@@ -88,8 +86,8 @@ void main() {
await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.inputs.length, 3);
expect(validatorTarget.validator.inputs[2].path, 'project/deferred_components_loading_units.yaml');
expect(validatorTarget.validator!.inputs.length, 3);
expect(validatorTarget.validator!.inputs[2].path, 'project/deferred_components_loading_units.yaml');
});
testUsingContext('writeLoadingUnitsCache task runs', () async {
......@@ -120,7 +118,7 @@ void main() {
await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.outputs.length, 1);
expect(validatorTarget.validator.outputs[0].path, 'project/deferred_components_loading_units.yaml');
expect(validatorTarget.validator!.outputs.length, 1);
expect(validatorTarget.validator!.outputs[0].path, 'project/deferred_components_loading_units.yaml');
});
}
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -39,11 +37,11 @@ const List<String> _kSharedConfig = <String>[
];
void main() {
Environment environment;
FileSystem fileSystem;
FakeProcessManager processManager;
Artifacts artifacts;
BufferLogger logger;
late Environment environment;
late FileSystem fileSystem;
late FakeProcessManager processManager;
late Artifacts artifacts;
late BufferLogger logger;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -323,13 +321,13 @@ void main() {
});
group('copies Flutter.framework', () {
Directory outputDir;
File binary;
FakeCommand copyPhysicalFrameworkCommand;
FakeCommand lipoCommandNonFatResult;
FakeCommand lipoVerifyArm64Command;
FakeCommand bitcodeStripCommand;
FakeCommand adHocCodesignCommand;
late Directory outputDir;
late File binary;
late FakeCommand copyPhysicalFrameworkCommand;
late FakeCommand lipoCommandNonFatResult;
late FakeCommand lipoVerifyArm64Command;
late FakeCommand bitcodeStripCommand;
late FakeCommand adHocCodesignCommand;
setUp(() {
final FileSystem fileSystem = MemoryFileSystem.test();
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -90,7 +88,8 @@ void main() {
});
// Only required for the test below that still depends on the context.
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
});
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -19,16 +17,16 @@ import '../../../src/context.dart';
import '../../../src/fake_process_manager.dart';
void main() {
Environment environment;
FileSystem fileSystem;
Artifacts artifacts;
FakeProcessManager processManager;
File binary;
BufferLogger logger;
FakeCommand copyFrameworkCommand;
FakeCommand lipoInfoNonFatCommand;
FakeCommand lipoInfoFatCommand;
FakeCommand lipoVerifyX86_64Command;
late Environment environment;
late FileSystem fileSystem;
late Artifacts artifacts;
late FakeProcessManager processManager;
late File binary;
late BufferLogger logger;
late FakeCommand copyFrameworkCommand;
late FakeCommand lipoInfoNonFatCommand;
late FakeCommand lipoInfoFatCommand;
late FakeCommand lipoVerifyX86_64Command;
setUp(() {
processManager = FakeProcessManager.empty();
......
......@@ -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:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -30,9 +28,9 @@ const List<String> kDart2jsLinuxArgs = <String>[
];
void main() {
Testbed testbed;
Environment environment;
FakeProcessManager processManager;
late Testbed testbed;
late Environment environment;
late FakeProcessManager processManager;
final Platform linux = FakePlatform(
environment: <String, String>{},
);
......@@ -40,7 +38,7 @@ void main() {
operatingSystem: 'windows',
environment: <String, String>{},
);
DepfileService depfileService;
late DepfileService depfileService;
setUp(() {
testbed = Testbed(setup: () {
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
......@@ -120,7 +118,7 @@ void main() {
});
// AssetBundleFactory still uses context injection
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -71,7 +69,7 @@ void main() {
final String mainPath = globals.fs.path.join('lib', 'main.dart');
const String assetDirPath = 'example';
const String depfilePath = 'example.d';
Environment env;
Environment? env;
final BuildSystem buildSystem = TestBuildSystem.all(
BuildResult(success: true),
(Target target, Environment environment) {
......@@ -104,17 +102,17 @@ void main() {
);
expect(env, isNotNull);
expect(env.defines[kBuildMode], 'debug');
expect(env.defines[kTargetPlatform], 'ios');
expect(env.defines[kTargetFile], mainPath);
expect(env.defines[kTrackWidgetCreation], 'true');
expect(env.defines[kExtraFrontEndOptions], 'test1,test2');
expect(env.defines[kExtraGenSnapshotOptions], 'test3,test4');
expect(env.defines[kFileSystemRoots], 'test5,test6');
expect(env.defines[kFileSystemScheme], 'test7');
expect(env.defines[kDartDefines], encodeDartDefines(<String>['test8', 'test9']));
expect(env.defines[kIconTreeShakerFlag], 'true');
expect(env.defines[kDeferredComponents], 'false');
expect(env!.defines[kBuildMode], 'debug');
expect(env!.defines[kTargetPlatform], 'ios');
expect(env!.defines[kTargetFile], mainPath);
expect(env!.defines[kTrackWidgetCreation], 'true');
expect(env!.defines[kExtraFrontEndOptions], 'test1,test2');
expect(env!.defines[kExtraGenSnapshotOptions], 'test3,test4');
expect(env!.defines[kFileSystemRoots], 'test5,test6');
expect(env!.defines[kFileSystemScheme], 'test7');
expect(env!.defines[kDartDefines], encodeDartDefines(<String>['test8', 'test9']));
expect(env!.defines[kIconTreeShakerFlag], 'true');
expect(env!.defines[kDeferredComponents], 'false');
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
......
......@@ -2,8 +2,7 @@
// 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:collection/collection.dart' show IterableExtension;
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
......@@ -17,7 +16,6 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/flutter_cache.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../src/common.dart';
......@@ -41,7 +39,7 @@ const FakeCommand unameCommandForArm64 = FakeCommand(
);
void main() {
FakeProcessManager fakeProcessManager;
late FakeProcessManager fakeProcessManager;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -79,7 +77,7 @@ void main() {
});
testWithoutContext('should not throw when lock is acquired', () async {
final String oldRoot = Cache.flutterRoot;
final String? oldRoot = Cache.flutterRoot;
Cache.flutterRoot = '';
try {
final FileSystem fileSystem = MemoryFileSystem.test();
......@@ -365,7 +363,7 @@ void main() {
final Directory dir = fileSystem.systemTempDirectory
.listSync(recursive: true)
.whereType<Directory>()
.singleWhere((Directory directory) => directory.basename == 'bin_dir', orElse: () => null);
.singleWhereOrNull((Directory directory) => directory.basename == 'bin_dir')!;
expect(dir, isNotNull);
expect(dir.path, artifactDir.childDirectory('bin_dir').path);
......@@ -458,6 +456,7 @@ void main() {
testWithoutContext('FlutterRunnerDebugSymbols downloads Flutter runner debug symbols', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final Cache cache = FakeSecondaryCache()
..artifactDirectory = fileSystem.currentDirectory
..version = '123456';
final FakeVersionedPackageResolver packageResolver = FakeVersionedPackageResolver();
......@@ -974,9 +973,9 @@ void main() {
});
group('AndroidMavenArtifacts', () {
MemoryFileSystem memoryFileSystem;
Cache cache;
FakeAndroidSdk fakeAndroidSdk;
MemoryFileSystem? memoryFileSystem;
Cache? cache;
FakeAndroidSdk? fakeAndroidSdk;
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
......@@ -988,25 +987,25 @@ void main() {
});
testWithoutContext('AndroidMavenArtifacts has a specified development artifact', () async {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform());
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(mavenArtifacts.developmentArtifact, DevelopmentArtifact.androidMaven);
});
testUsingContext('AndroidMavenArtifacts can invoke Gradle resolve dependencies if Android SDK is present', () async {
final String oldRoot = Cache.flutterRoot;
final String? oldRoot = Cache.flutterRoot;
Cache.flutterRoot = '';
try {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse);
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
final Directory gradleWrapperDir = cache.getArtifactDirectory('gradle_wrapper')..createSync(recursive: true);
final Directory gradleWrapperDir = cache!.getArtifactDirectory('gradle_wrapper')..createSync(recursive: true);
gradleWrapperDir.childFile('gradlew').writeAsStringSync('irrelevant');
gradleWrapperDir.childFile('gradlew.bat').writeAsStringSync('irrelevant');
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem, FakeOperatingSystemUtils());
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem!, FakeOperatingSystemUtils());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse);
expect(fakeAndroidSdk.reinitialized, true);
expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
expect(fakeAndroidSdk!.reinitialized, true);
} finally {
Cache.flutterRoot = oldRoot;
}
......@@ -1028,12 +1027,12 @@ void main() {
});
testUsingContext('AndroidMavenArtifacts is a no-op if the Android SDK is absent', () async {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse);
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem, FakeOperatingSystemUtils());
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem!, FakeOperatingSystemUtils());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse);
expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
}, overrides: <Type, Generator>{
Cache: () => cache,
FileSystem: () => memoryFileSystem,
......@@ -1046,8 +1045,8 @@ void main() {
class FakeCachedArtifact extends EngineCachedArtifact {
FakeCachedArtifact({
String stampName = 'STAMP',
@required Cache cache,
DevelopmentArtifact requiredArtifacts,
required Cache cache,
required DevelopmentArtifact requiredArtifacts,
this.binaryDirs = const <List<String>>[],
this.licenseDirs = const <String>[],
this.packageDirs = const <String>[],
......@@ -1081,7 +1080,7 @@ class FakeSimpleArtifact extends CachedArtifact {
class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact {
bool upToDate = false;
bool didUpdate = false;
Exception updateException;
Exception? updateException;
@override
Future<bool> isUpToDate(FileSystem fileSystem) async => upToDate;
......@@ -1089,7 +1088,7 @@ class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact {
@override
Future<void> update(ArtifactUpdater artifactUpdater, Logger logger, FileSystem fileSystem, OperatingSystemUtils operatingSystemUtils, {bool offline = false}) async {
if (updateException != null) {
throw updateException;
throw updateException!;
}
didUpdate = true;
}
......@@ -1107,10 +1106,10 @@ class FakeIosUsbArtifacts extends Fake implements IosUsbArtifacts {
}
class FakeSecondaryCache extends Fake implements Cache {
Directory downloadDir;
Directory artifactDirectory;
String version;
void Function(String artifactName, String version) onSetStamp;
Directory? downloadDir;
late Directory artifactDirectory;
String? version;
late void Function(String artifactName, String version) onSetStamp;
@override
String get storageBaseUrl => 'https://storage.googleapis.com';
......@@ -1132,7 +1131,7 @@ class FakeSecondaryCache extends Fake implements Cache {
}
@override
String getVersionFor(String artifactName) => version;
String? getVersionFor(String artifactName) => version;
@override
void setStampFor(String artifactName, String version) {
......@@ -1155,13 +1154,13 @@ class FakePub extends Fake implements Pub {
@override
Future<void> get({
PubContext context,
String directory,
PubContext? context,
String? directory,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
String flutterRootOverride,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true,
......@@ -1172,19 +1171,15 @@ class FakePub extends Fake implements Pub {
class FakeCache extends Cache {
FakeCache({
@required Logger logger,
@required FileSystem fileSystem,
@required Platform platform,
@required OperatingSystemUtils osUtils,
required super.logger,
required super.fileSystem,
required super.platform,
required super.osUtils,
}) : super(
logger: logger,
fileSystem: fileSystem,
platform: platform,
osUtils: osUtils,
artifacts: <ArtifactSet>[],
);
File stampFile;
late File stampFile;
@override
File getStampFileFor(String artifactName) {
......@@ -1202,8 +1197,8 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
}
class FakeArtifactUpdater extends Fake implements ArtifactUpdater {
void Function(String, Uri, Directory) onDownloadZipArchive;
void Function(String, Uri, Directory) onDownloadZipTarball;
void Function(String, Uri, Directory)? onDownloadZipArchive;
void Function(String, Uri, Directory)? onDownloadZipTarball;
@override
Future<void> downloadZippedTarball(String message, Uri url, Directory location) 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
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160
......@@ -24,7 +22,7 @@ import '../src/test_flutter_command_runner.dart';
void main() {
group('channel', () {
FakeProcessManager fakeProcessManager;
late FakeProcessManager fakeProcessManager;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -159,7 +157,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText
.split('\n')
.map((String line) => line.trim())
.where((String line) => line?.isNotEmpty == true)
.where((String line) => line.isNotEmpty == true)
.skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
......@@ -190,7 +188,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText
.split('\n')
.map((String line) => line.trim())
.where((String line) => line?.isNotEmpty == true)
.where((String line) => line.isNotEmpty == true)
.skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -17,11 +15,11 @@ const String _kTestFlutterRoot = '/flutter';
const String _kTestWindowsFlutterRoot = r'C:\flutter';
void main() {
FileSystem fileSystem;
ProcessManager processManager;
late FileSystem fileSystem;
late ProcessManager processManager;
setUp(() {
processManager = FakeProcessManager.any();
fileSystem = MemoryFileSystem.test();
});
......@@ -33,7 +31,7 @@ void main() {
..createSync(recursive: true)
..writeAsStringSync('set(BINARY_NAME "hello")');
final String name = getCmakeExecutableName(cmakeProject);
final String? name = getCmakeExecutableName(cmakeProject);
expect(name, 'hello');
}, overrides: <Type, Generator>{
......@@ -45,7 +43,7 @@ void main() {
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
final String name = getCmakeExecutableName(cmakeProject);
final String? name = getCmakeExecutableName(cmakeProject);
expect(name, isNull);
}, overrides: <Type, Generator>{
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
......@@ -15,7 +13,6 @@ import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_cold.dart';
import 'package:flutter_tools/src/tracing.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart';
......@@ -68,8 +65,9 @@ void main() {
});
group('cold run', () {
MemoryFileSystem memoryFileSystem;
FakePlatform fakePlatform;
late MemoryFileSystem memoryFileSystem;
late FakePlatform fakePlatform;
setUp(() {
memoryFileSystem = MemoryFileSystem();
fakePlatform = FakePlatform(environment: <String, String>{});
......@@ -159,7 +157,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
int runColdCode = 0;
@override
Future<int> runCold({ColdRunner coldRunner, String route}) async {
Future<int> runCold({ColdRunner? coldRunner, String? route}) async {
return runColdCode;
}
......@@ -175,10 +173,10 @@ class FakeDevice extends Fake implements Device {
bool isSupported() => true;
@override
bool supportsHotReload;
bool supportsHotReload = false;
@override
bool supportsHotRestart;
bool supportsHotRestart = false;
@override
Future<String> get sdkNameAndVersion async => 'Android 10';
......@@ -199,9 +197,9 @@ class FakeDevice extends Fake implements Device {
class TestFlutterDevice extends FlutterDevice {
TestFlutterDevice({
@required Device device,
@required this.exception,
@required ResidentCompiler generator,
required Device device,
required this.exception,
required ResidentCompiler generator,
}) : assert(exception != null),
super(device, buildInfo: BuildInfo.debug, generator: generator);
......@@ -210,17 +208,17 @@ class TestFlutterDevice extends FlutterDevice {
@override
Future<void> connect({
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
bool enableDds = true,
bool cacheStartupProfile = false,
bool disableServiceAuthCodes = false,
int hostVmServicePort,
int ddsPort,
bool ipv6 = false,
int? hostVmServicePort,
int? ddsPort,
bool? ipv6 = false,
bool allowExistingDdsInstance = false,
}) async {
throw exception;
......@@ -239,10 +237,10 @@ class FakeFlutterVmService extends Fake implements FlutterVmService {
}
@override
Future<bool> flutterAlreadyPaintedFirstUsefulFrame({String isolateId}) async => true;
Future<bool> flutterAlreadyPaintedFirstUsefulFrame({String? isolateId}) async => true;
@override
Future<Response> getTimeline() async {
Future<Response?> getTimeline() async {
return Response.parse(<String, dynamic>{
'traceEvents': <dynamic>[
<String, dynamic>{
......
......@@ -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_tools/src/test/coverage_collector.dart';
import 'package:vm_service/vm_service.dart';
......@@ -20,11 +18,11 @@ void main() {
),
FakeVmServiceRequest(
method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{})
jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{
'id': '1',
}),
})!,
]
).toJson(),
),
......@@ -40,10 +38,10 @@ void main() {
],
);
final Map<String, Object> result = await collect(
final Map<String, Object?> result = await collect(
null,
<String>{'foo'},
connector: (Uri uri) async {
connector: (Uri? uri) async {
return fakeVmServiceHost.vmService;
},
);
......@@ -61,11 +59,11 @@ void main() {
),
FakeVmServiceRequest(
method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{})
jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{
'id': '1',
}),
})!,
]
).toJson(),
),
......@@ -112,10 +110,10 @@ void main() {
],
);
final Map<String, Object> result = await collect(
final Map<String, Object?> result = await collect(
null,
<String>{'foo'},
connector: (Uri uri) async {
connector: (Uri? uri) async {
return fakeVmServiceHost.vmService;
},
);
......@@ -148,11 +146,11 @@ void main() {
),
FakeVmServiceRequest(
method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{})
jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{
'id': '1',
}),
})!,
]
).toJson(),
),
......@@ -229,10 +227,10 @@ void main() {
],
);
final Map<String, Object> result = await collect(
final Map<String, Object?> result = await collect(
null,
null,
connector: (Uri uri) async {
connector: (Uri? uri) async {
return fakeVmServiceHost.vmService;
},
);
......@@ -276,11 +274,11 @@ void main() {
),
FakeVmServiceRequest(
method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{})
jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{
'id': '1',
}),
})!,
]
).toJson(),
),
......@@ -317,10 +315,10 @@ void main() {
],
);
final Map<String, Object> result = await collect(
final Map<String, Object?> result = await collect(
null,
<String>{'foo'},
connector: (Uri uri) async {
connector: (Uri? uri) async {
return fakeVmServiceHost.vmService;
},
);
......@@ -353,11 +351,11 @@ void main() {
),
FakeVmServiceRequest(
method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{})
jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{
'id': '1',
}),
})!,
]
).toJson(),
),
......@@ -393,10 +391,10 @@ void main() {
],
);
final Map<String, Object> result = await collect(
final Map<String, Object?> result = await collect(
null,
null,
connector: (Uri uri) async {
connector: (Uri? uri) async {
return fakeVmServiceHost.vmService;
},
);
......
......@@ -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_tools/src/commands/create_base.dart';
import '../src/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:async';
import 'package:file/file.dart';
......@@ -116,9 +114,7 @@ void main() {
final CustomDeviceConfig disabledTestConfig = testConfig.copyWith(enabled: false);
final CustomDeviceConfig testConfigNonForwarding = testConfig.copyWith(
explicitForwardPortCommand: true,
forwardPortCommand: null,
explicitForwardPortSuccessRegex: true,
forwardPortSuccessRegex: null,
);
testUsingContext('CustomDevice defaults',
......@@ -339,12 +335,12 @@ void main() {
final CustomDevicePortForwarder forwarder = CustomDevicePortForwarder(
deviceName: 'testdevicename',
forwardPortCommand: testConfig.forwardPortCommand,
forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex,
forwardPortCommand: testConfig.forwardPortCommand!,
forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex!,
logger: BufferLogger.test(),
processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: testConfig.forwardPortCommand,
command: testConfig.forwardPortCommand!,
stdout: testConfigForwardPortSuccessOutput,
completer: forwardPortCommandCompleter,
),
......@@ -373,7 +369,7 @@ void main() {
stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n',
),
FakeCommand(
command: testConfig.forwardPortCommand,
command: testConfig.forwardPortCommand!,
completer: forwardPortCompleter,
stdout: testConfigForwardPortSuccessOutput,
),
......@@ -450,7 +446,7 @@ void main() {
command: testConfig.pingCommand,
stdout: testConfigPingSuccessOutput
),
FakeCommand(command: testConfig.postBuildCommand),
FakeCommand(command: testConfig.postBuildCommand!),
FakeCommand(command: testConfig.uninstallCommand),
FakeCommand(command: testConfig.installCommand),
FakeCommand(
......@@ -459,7 +455,7 @@ void main() {
stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n',
),
FakeCommand(
command: testConfig.forwardPortCommand,
command: testConfig.forwardPortCommand!,
completer: forwardPortCompleter,
stdout: testConfigForwardPortSuccessOutput,
),
......@@ -524,7 +520,7 @@ void main() {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: testConfig.screenshotCommand,
command: testConfig.screenshotCommand!,
onRun: () => screenshotCommandWasExecuted = true,
),
]);
......@@ -550,7 +546,7 @@ void main() {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: testConfig.screenshotCommand,
command: testConfig.screenshotCommand!,
onRun: () => screenshotCommandWasExecuted = true,
),
]);
......@@ -560,8 +556,7 @@ void main() {
final CustomDevice device = CustomDevice(
config: testConfig.copyWith(
explicitScreenshotCommand: true,
screenshotCommand: null
explicitScreenshotCommand: true
),
logger: BufferLogger.test(),
processManager: processManager
......@@ -640,14 +635,14 @@ class MyFakeStreamSubscription<T> extends Fake implements StreamSubscription<T>
class FakeBundleBuilder extends Fake implements BundleBuilder {
@override
Future<void> build({
TargetPlatform platform,
BuildInfo buildInfo,
FlutterProject project,
String mainPath,
TargetPlatform? platform,
BuildInfo? buildInfo,
FlutterProject? project,
String? mainPath,
String manifestPath = defaultManifestPath,
String applicationKernelFilePath,
String depfilePath,
String assetDirPath,
@visibleForTesting BuildSystem buildSystem
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
@visibleForTesting BuildSystem? buildSystem
}) 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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
......@@ -22,9 +20,9 @@ import '../src/context.dart';
void main() {
group('Dart plugin registrant', () {
FileSystem fs;
FakeFlutterProject flutterProject;
FakeFlutterManifest flutterManifest;
late FileSystem fs;
late FakeFlutterProject flutterProject;
late FakeFlutterManifest flutterManifest;
setUp(() async {
fs = MemoryFileSystem.test();
......@@ -1023,35 +1021,35 @@ class FakeFlutterProject extends Fake implements FlutterProject {
bool isModule = false;
@override
FlutterManifest manifest;
late FlutterManifest manifest;
@override
Directory directory;
late Directory directory;
@override
File flutterPluginsFile;
late File flutterPluginsFile;
@override
File flutterPluginsDependenciesFile;
late File flutterPluginsDependenciesFile;
@override
File dartPluginRegistrant;
late File dartPluginRegistrant;
@override
IosProject ios;
late IosProject ios;
@override
AndroidProject android;
late AndroidProject android;
@override
WebProject web;
late WebProject web;
@override
MacOSProject macos;
late MacOSProject macos;
@override
LinuxProject linux;
late LinuxProject linux;
@override
WindowsProject windows;
late WindowsProject windows;
}
......@@ -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:io' as io show ProcessSignal, Process;
......@@ -101,7 +99,6 @@ void main() {
final DateTime fiveSecondsAgo = file.statSync().modified.subtract(const Duration(seconds: 5));
expect(content.isModifiedAfter(fiveSecondsAgo), isTrue);
expect(content.isModifiedAfter(fiveSecondsAgo), isTrue);
expect(content.isModifiedAfter(null), isTrue);
file.writeAsBytesSync(<int>[2, 3, 4], flush: true);
......@@ -186,7 +183,7 @@ void main() {
requests: <VmServiceExpectation>[createDevFSRequest],
httpAddress: Uri.parse('http://localhost'),
);
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.dill')
..createSync(recursive: true)
..writeAsBytesSync(<int>[1, 2, 3, 4, 5]);
......@@ -250,10 +247,10 @@ void main() {
);
await devFS.create();
final DateTime previousCompile = devFS.lastCompiled;
final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
return const CompilerOutput('lib/foo.dill', 2, <Uri>[]);
};
......@@ -289,10 +286,10 @@ void main() {
);
await devFS.create();
final DateTime previousCompile = devFS.lastCompiled;
final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
};
......@@ -330,10 +327,10 @@ void main() {
);
await devFS.create();
final DateTime previousCompile = devFS.lastCompiled;
final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
};
......@@ -380,7 +377,7 @@ void main() {
await devFS.create();
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('example').createSync();
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
};
......@@ -456,7 +453,7 @@ void main() {
await devFS.create();
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async {
residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
};
......@@ -506,7 +503,7 @@ void main() {
await Future<dynamic>.delayed(const Duration(milliseconds: 5));
}
String boundaryKey;
String? boundaryKey;
while(processed < frontendServerStdIn.writes.length) {
final List<int> data = frontendServerStdIn.writes[processed];
final String stringData = utf8.decode(data);
......@@ -581,10 +578,10 @@ void main() {
}
class FakeResidentCompiler extends Fake implements ResidentCompiler {
Future<CompilerOutput> Function(Uri mainUri, List<Uri> invalidatedFiles) onRecompile;
Future<CompilerOutput> Function(Uri mainUri, List<Uri>? invalidatedFiles)? onRecompile;
@override
Future<CompilerOutput> recompile(Uri mainUri, List<Uri> invalidatedFiles, {String outputPath, PackageConfig packageConfig, String projectRootPath, FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) {
Future<CompilerOutput> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) {
return onRecompile?.call(mainUri, invalidatedFiles)
?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[]));
}
......@@ -605,12 +602,12 @@ class LoggingLogger extends BufferLogger {
List<String> messages = <String>[];
@override
void printError(String message, {StackTrace stackTrace, bool emphasis, TerminalColor color, int indent, int hangingIndent, bool wrap}) {
void printError(String message, {StackTrace? stackTrace, bool? emphasis, TerminalColor? color, int? indent, int? hangingIndent, bool? wrap}) {
messages.add(message);
}
@override
void printStatus(String message, {bool emphasis, TerminalColor color, bool newline, int indent, int hangingIndent, bool wrap}) {
void printStatus(String message, {bool? emphasis, TerminalColor? color, bool? newline, int? indent, int? hangingIndent, bool? wrap}) {
messages.add(message);
}
......@@ -625,7 +622,7 @@ class FakeBundle extends AssetBundle {
List<File> get additionalDependencies => <File>[];
@override
Future<int> build({String manifestPath = defaultManifestPath, String assetDirPath, String packagesPath, bool deferredComponentsEnabled = false, TargetPlatform targetPlatform}) async {
Future<int> build({String manifestPath = defaultManifestPath, String? assetDirPath, String? packagesPath, bool deferredComponentsEnabled = false, TargetPlatform? targetPlatform}) async {
return 0;
}
......@@ -657,7 +654,7 @@ class AnsweringFakeProcessManager implements ProcessManager {
final IOSink stdin;
@override
bool canRun(dynamic executable, {String workingDirectory}) {
bool canRun(dynamic executable, {String? workingDirectory}) {
return true;
}
......@@ -667,17 +664,17 @@ class AnsweringFakeProcessManager implements ProcessManager {
}
@override
Future<ProcessResult> run(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) async {
Future<ProcessResult> run(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) async {
throw UnimplementedError();
}
@override
ProcessResult runSync(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) {
ProcessResult runSync(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) {
throw UnimplementedError();
}
@override
Future<Process> start(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async {
Future<Process> start(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async {
return AnsweringFakeProcess(stdout, stderr, stdin);
}
}
......
......@@ -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 'package:flutter_tools/src/base/io.dart';
......@@ -17,7 +15,7 @@ import '../src/fake_process_manager.dart';
import '../src/fakes.dart';
void main() {
BufferLogger logger;
late BufferLogger logger;
Cache.flutterRoot = '';
......@@ -44,9 +42,9 @@ void main() {
]),
);
final DevToolsServerAddress address = await launcher.serve();
expect(address.host, '127.0.0.1');
expect(address.port, 9100);
final DevToolsServerAddress? address = await launcher.serve();
expect(address?.host, '127.0.0.1');
expect(address?.port, 9100);
});
testWithoutContext('DevtoolsLauncher does not launch a new DevTools instance if one is already active', () async {
......@@ -68,14 +66,14 @@ void main() {
]),
);
DevToolsServerAddress address = await launcher.serve();
expect(address.host, '127.0.0.1');
expect(address.port, 9100);
DevToolsServerAddress? address = await launcher.serve();
expect(address?.host, '127.0.0.1');
expect(address?.port, 9100);
// Call `serve` again and verify that the already running server is returned.
address = await launcher.serve();
expect(address.host, '127.0.0.1');
expect(address.port, 9100);
expect(address?.host, '127.0.0.1');
expect(address?.port, 9100);
});
testWithoutContext('DevtoolsLauncher can launch devtools with a memory profile', () 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:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
......@@ -17,12 +15,11 @@ import '../src/common.dart';
import '../src/context.dart';
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
fileSystem
.file('.dart_tool/package_config.json')
fileSystem.file('.dart_tool/package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
});
......@@ -80,7 +77,7 @@ void main() {
),
), throwsAssertionError);
FlutterPlatform capturedPlatform;
FlutterPlatform? capturedPlatform;
final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'};
final FlutterPlatform flutterPlatform = installHook(
shellPath: 'abc',
......
......@@ -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 'package:dds/dds.dart';
......@@ -16,7 +14,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/test/flutter_tester_device.dart';
import 'package:flutter_tools/src/test/font_config_manager.dart';
import 'package:meta/meta.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/fake.dart';
......@@ -25,10 +22,10 @@ import '../src/context.dart';
import '../src/fake_process_manager.dart';
void main() {
FakePlatform platform;
FileSystem fileSystem;
FakeProcessManager processManager;
FlutterTesterTestDevice device;
late FakePlatform platform;
late FileSystem fileSystem;
late FakeProcessManager processManager;
late FlutterTesterTestDevice device;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -265,17 +262,14 @@ void main() {
/// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterTesterDevice extends FlutterTesterTestDevice {
TestFlutterTesterDevice({
@required Platform platform,
@required FileSystem fileSystem,
@required ProcessManager processManager,
@required bool enableObservatory,
@required List<String> dartEntrypointArgs,
required super.platform,
required super.fileSystem,
required super.processManager,
required super.enableObservatory,
required List<String> dartEntrypointArgs,
}) : super(
id: 999,
shellPath: '/',
platform: platform,
fileSystem: fileSystem,
processManager: processManager,
logger: BufferLogger.test(),
debuggingOptions: DebuggingOptions.enabled(
const BuildInfo(
......@@ -286,7 +280,6 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
hostVmServicePort: 1234,
dartEntrypointArgs: dartEntrypointArgs,
),
enableObservatory: enableObservatory,
machine: false,
host: InternetAddress.loopbackIPv6,
testAssetDirectory: null,
......@@ -307,7 +300,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
}
@override
Future<HttpServer> bind(InternetAddress host, int port) async => FakeHttpServer();
Future<HttpServer> bind(InternetAddress? host, int port) async => FakeHttpServer();
@override
Future<StreamChannel<String>> get remoteChannel async => StreamChannelController<String>().foreign;
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart';
......@@ -16,13 +14,12 @@ import '../../src/fake_process_manager.dart';
void main() {
group('FuchsiaPM', () {
File pm;
FakeProcessManager fakeProcessManager;
FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
late File pm;
late FakeProcessManager fakeProcessManager;
late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
setUp(() {
pm = MemoryFileSystem.test().file('pm');
fakeFuchsiaArtifacts = FakeFuchsiaArtifacts(pm);
fakeProcessManager = FakeProcessManager.empty();
});
......
......@@ -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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/io.dart';
......@@ -16,8 +14,9 @@ import '../src/common.dart';
import '../src/context.dart';
void main() {
BufferLogger logger;
FileSystem fs;
late BufferLogger logger;
late FileSystem fs;
setUp(() {
logger = BufferLogger.test();
fs = MemoryFileSystem.test();
......@@ -144,8 +143,8 @@ void main() {
});
group('new issue template URL', () {
StackTrace stackTrace;
Error error;
late StackTrace stackTrace;
late Error error;
const String command = 'flutter test';
const String doctorText = ' [✓] Flutter (Channel report';
......@@ -220,7 +219,7 @@ project_type: app
''');
final String actualURL = await creator.toolCrashIssueTemplateGitHubURL(command, error, stackTrace, doctorText);
final String actualBody = Uri.parse(actualURL).queryParameters['body'];
final String? actualBody = Uri.parse(actualURL).queryParameters['body'];
const String expectedBody = '''
## Command
```
......
......@@ -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:file/file.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/io.dart' as io;
......@@ -64,8 +62,8 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest(
final Uri observatoryUri = Uri.parse('http://localhost:1234');
void main() {
FakeVmServiceHost fakeVmServiceHost;
TestDevice testDevice;
late FakeVmServiceHost fakeVmServiceHost;
late TestDevice testDevice;
setUp(() {
testDevice = IntegrationTestTestDevice(
......@@ -133,14 +131,14 @@ void main() {
}, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
io.CompressionOptions compression,
Device device,
Logger logger,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
Logger? logger,
}) async => fakeVmServiceHost.vmService,
});
......@@ -152,14 +150,14 @@ void main() {
}, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
io.CompressionOptions compression,
Device device,
Logger logger,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
Logger? logger,
}) async => fakeVmServiceHost.vmService,
});
......@@ -181,13 +179,13 @@ void main() {
expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>()));
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
io.CompressionOptions compression,
Device device,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
}) async => fakeVmServiceHost.vmService,
});
......@@ -209,13 +207,13 @@ void main() {
expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>()));
}, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
io.CompressionOptions compression,
Device device,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
}) async => fakeVmServiceHost.vmService,
});
......@@ -226,14 +224,14 @@ void main() {
}, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
io.CompressionOptions compression,
Device device,
Logger logger,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions? compression,
Device? device,
Logger? logger,
}) async => fakeVmServiceHost.vmService,
});
}
......@@ -242,8 +240,8 @@ class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFa
@override
Future<ApplicationPackage> getPackageForPlatform(
TargetPlatform platform, {
BuildInfo buildInfo,
File applicationBinary,
BuildInfo? buildInfo,
File? applicationBinary,
}) async => FakeApplicationPackage();
}
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -22,7 +20,7 @@ import '../../src/context.dart';
// FlutterProject still depends on context.
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
// This setup is required to inject the context.
setUp(() {
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
......@@ -34,9 +32,9 @@ final Platform macosPlatform = FakePlatform(
);
void main() {
FakePlatform osx;
FileSystemUtils fsUtils;
MemoryFileSystem fileSystem;
late FakePlatform osx;
late FileSystemUtils fsUtils;
late MemoryFileSystem fileSystem;
setUp(() {
osx = FakePlatform(
......@@ -48,8 +46,8 @@ void main() {
});
group('_IOSSimulatorDevicePortForwarder', () {
FakeSimControl simControl;
Xcode xcode;
late FakeSimControl simControl;
late Xcode xcode;
setUp(() {
simControl = FakeSimControl();
......@@ -100,7 +98,7 @@ void main() {
});
group('logFilePath', () {
FakeSimControl simControl;
late FakeSimControl simControl;
setUp(() {
simControl = FakeSimControl();
......@@ -163,7 +161,7 @@ void main() {
});
group('sdkMajorVersion', () {
FakeSimControl simControl;
late FakeSimControl simControl;
setUp(() {
simControl = FakeSimControl();
......@@ -205,7 +203,7 @@ void main() {
});
group('IOSSimulator.isSupported', () {
FakeSimControl simControl;
late FakeSimControl simControl;
setUp(() {
simControl = FakeSimControl();
......@@ -368,8 +366,8 @@ void main() {
});
group('device log tool', () {
FakeProcessManager fakeProcessManager;
FakeSimControl simControl;
late FakeProcessManager fakeProcessManager;
late FakeSimControl simControl;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -472,10 +470,10 @@ void main() {
});
group('log reader', () {
FakeProcessManager fakeProcessManager;
FakeIosProject mockIosProject;
FakeSimControl simControl;
Xcode xcode;
late FakeProcessManager fakeProcessManager;
late FakeIosProject mockIosProject;
late FakeSimControl simControl;
late Xcode xcode;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -616,7 +614,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
});
group('unified logging', () {
BufferLogger logger;
late BufferLogger logger;
setUp(() {
logger = BufferLogger.test();
......@@ -754,9 +752,9 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
}
''';
FakeProcessManager fakeProcessManager;
late FakeProcessManager fakeProcessManager;
Xcode xcode;
SimControl simControl;
late SimControl simControl;
const String deviceId = 'smart-phone';
const String appId = 'flutterApp';
......@@ -895,10 +893,10 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
});
group('startApp', () {
FakePlistParser testPlistParser;
FakeSimControl simControl;
Xcode xcode;
BufferLogger logger;
late FakePlistParser testPlistParser;
late FakeSimControl simControl;
late Xcode xcode;
late BufferLogger logger;
setUp(() {
simControl = FakeSimControl();
......@@ -1027,8 +1025,8 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
});
group('IOSDevice.isSupportedForProject', () {
FakeSimControl simControl;
Xcode xcode;
late FakeSimControl simControl;
late Xcode xcode;
setUp(() {
simControl = FakeSimControl();
......@@ -1113,17 +1111,17 @@ flutter:
class FakeIosProject extends Fake implements IosProject {
@override
Future<String> productBundleIdentifier(BuildInfo buildInfo) async => 'com.example.test';
Future<String> productBundleIdentifier(BuildInfo? buildInfo) async => 'com.example.test';
@override
Future<String> hostAppBundleName(BuildInfo buildInfo) async => 'My Super Awesome App.app';
Future<String> hostAppBundleName(BuildInfo? buildInfo) async => 'My Super Awesome App.app';
}
class FakeSimControl extends Fake implements SimControl {
final List<LaunchRequest> requests = <LaunchRequest>[];
@override
Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String> launchArgs ]) async {
Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String>? launchArgs ]) async {
requests.add(LaunchRequest(deviceId, appIdentifier, launchArgs));
return RunResult(ProcessResult(0, 0, '', ''), <String>['test']);
}
......@@ -1139,5 +1137,5 @@ class LaunchRequest {
final String deviceId;
final String appIdentifier;
final List<String> launchArgs;
final List<String>? launchArgs;
}
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -56,11 +54,11 @@ void main() {
stdout: 'hw.optional.arm64: 1',
);
FakeProcessManager fakeProcessManager;
XcodeProjectInterpreter xcodeProjectInterpreter;
FakePlatform platform;
FileSystem fileSystem;
BufferLogger logger;
late FakeProcessManager fakeProcessManager;
late XcodeProjectInterpreter xcodeProjectInterpreter;
late FakePlatform platform;
late FileSystem fileSystem;
late BufferLogger logger;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -660,7 +658,7 @@ Information about project "Runner":
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'Paid', treeShakeIcons: false), 'Paid'), null);
});
group('environmentVariablesAsXcodeBuildSettings', () {
FakePlatform platform;
late FakePlatform platform;
setUp(() {
platform = FakePlatform();
......@@ -679,9 +677,9 @@ Information about project "Runner":
});
group('updateGeneratedXcodeProperties', () {
Artifacts localIosArtifacts;
FakePlatform macOS;
FileSystem fs;
late Artifacts localIosArtifacts;
late FakePlatform macOS;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem.test();
......@@ -691,8 +689,8 @@ Information about project "Runner":
});
group('arm simulator', () {
FakeProcessManager fakeProcessManager;
XcodeProjectInterpreter xcodeProjectInterpreter;
late FakeProcessManager fakeProcessManager;
late XcodeProjectInterpreter xcodeProjectInterpreter;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -1047,7 +1045,7 @@ Build settings for action build and target plugin2:
});
});
String propertyFor(String key, File file) {
String? propertyFor(String key, File file) {
final List<String> properties = file
.readAsLinesSync()
.where((String line) => line.startsWith('$key='))
......@@ -1057,10 +1055,10 @@ Build settings for action build and target plugin2:
}
Future<void> checkBuildVersion({
String manifestString,
BuildInfo buildInfo,
String expectedBuildName,
String expectedBuildNumber,
required String manifestString,
required BuildInfo buildInfo,
String? expectedBuildName,
String? expectedBuildNumber,
}) async {
final File manifestFile = fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true);
......
......@@ -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';
import 'package:file/file.dart';
......@@ -23,9 +21,9 @@ import '../../src/context.dart';
void main() {
group('PrebuiltMacOSApp', () {
FakeOperatingSystemUtils os;
FileSystem fileSystem;
BufferLogger logger;
late FakeOperatingSystemUtils os;
late FileSystem fileSystem;
late BufferLogger logger;
final Map<Type, Generator> overrides = <Type, Generator>{
FileSystem: () => fileSystem,
......@@ -42,7 +40,7 @@ group('PrebuiltMacOSApp', () {
});
testUsingContext('Error on non-existing file', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('File "not_existing.app" does not exist.'));
......@@ -50,7 +48,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on non-app-bundle folder', () {
fileSystem.directory('regular_folder').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('regular_folder')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('regular_folder')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Folder "regular_folder" is not an app bundle.'));
......@@ -58,7 +56,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on no info.plist', () {
fileSystem.directory('bundle.app').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Does not contain Info.plist.'));
......@@ -67,10 +65,9 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on info.plist missing bundle identifier', () {
final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents');
fileSystem.directory(contentsDirectory).createSync(recursive: true);
fileSystem
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(badPlistData);
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier'));
......@@ -79,10 +76,9 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on info.plist missing executable', () {
final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents');
fileSystem.directory(contentsDirectory).createSync(recursive: true);
fileSystem
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(badPlistDataNoExecutable);
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle executable'));
......@@ -91,13 +87,11 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Success with app bundle', () {
final String appDirectory = fileSystem.path.join('bundle.app', 'Contents', 'MacOS');
fileSystem.directory(appDirectory).createSync(recursive: true);
fileSystem
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(plistData);
fileSystem
.file(fileSystem.path.join(appDirectory, executableName))
fileSystem.file(fileSystem.path.join(appDirectory, executableName))
.createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app'))! as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty);
expect(macosApp.uncompressedBundle.path, 'bundle.app');
......@@ -107,7 +101,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Bad zipped app, no payload dir', () {
fileSystem.file('app.zip').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.'));
......@@ -124,7 +118,7 @@ group('PrebuiltMacOSApp', () {
fileSystem.directory(bundlePath1).createSync(recursive: true);
fileSystem.directory(bundlePath2).createSync(recursive: true);
};
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp?;
expect(macosApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.'));
......@@ -138,18 +132,15 @@ group('PrebuiltMacOSApp', () {
}
final Directory bundleAppContentsDir = fileSystem.directory(fileSystem.path.join(targetDirectory.path, 'bundle.app', 'Contents'));
bundleAppContentsDir.createSync(recursive: true);
fileSystem
.file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist'))
fileSystem.file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist'))
.writeAsStringSync(plistData);
fileSystem
.directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS'))
fileSystem.directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS'))
.createSync();
fileSystem
.file(fileSystem.path
fileSystem.file(fileSystem.path
.join(bundleAppContentsDir.path, 'MacOS', executableName))
.createSync();
};
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp;
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip'))! as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty);
expect(macosApp.uncompressedBundle.path, endsWith('bundle.app'));
......@@ -170,7 +161,7 @@ group('PrebuiltMacOSApp', () {
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils();
void Function(File, Directory) unzipOverride;
void Function(File, Directory)? unzipOverride;
@override
void unzip(File file, Directory targetDirectory) {
......@@ -181,15 +172,15 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
class FakePlistUtils extends Fake implements PlistParser {
FakePlistUtils(this.fileSystem);
final FileSystem fileSystem;
final FileSystem? fileSystem;
@override
Map<String, dynamic> parseFile(String plistFilePath) {
final File file = fileSystem.file(plistFilePath);
Map<String, Object> parseFile(String plistFilePath) {
final File file = fileSystem!.file(plistFilePath);
if (!file.existsSync()) {
return <String, dynamic>{};
return <String, Object>{};
}
return castStringKeyedMap(json.decode(file.readAsStringSync()));
return castStringKeyedMap(json.decode(file.readAsStringSync()))!.cast();
}
}
......
......@@ -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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart';
......@@ -22,11 +20,11 @@ import '../../src/context.dart';
import '../../src/fake_process_manager.dart';
void main() {
FileSystem fileSystem;
FakeProcessManager fakeProcessManager;
CocoaPods cocoaPodsUnderTest;
BufferLogger logger;
TestUsage usage;
late FileSystem fileSystem;
late FakeProcessManager fakeProcessManager;
late CocoaPods cocoaPodsUnderTest;
late BufferLogger logger;
late TestUsage usage;
void pretendPodVersionFails() {
fakeProcessManager.addCommand(
......@@ -77,17 +75,17 @@ void main() {
usage: usage,
);
fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc',
Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc',
))
..createSync(recursive: true)
..writeAsStringSync('Objective-C iOS podfile template');
fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-swift',
Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-swift',
))
..createSync(recursive: true)
..writeAsStringSync('Swift iOS podfile template');
fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-macos',
Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-macos',
))
..createSync(recursive: true)
..writeAsStringSync('macOS podfile template');
......@@ -728,7 +726,6 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
final bool didInstall = await cocoaPodsUnderTest.processPods(
xcodeProject: projectUnderTest.ios,
buildMode: BuildMode.debug,
dependenciesChanged: true,
);
expect(didInstall, isTrue);
expect(fakeProcessManager, hasNoRemainingExpectations);
......@@ -828,7 +825,7 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
@override
Future<Map<String, String>> getBuildSettings(
String projectPath, {
XcodeProjectBuildContext buildContext,
XcodeProjectBuildContext? buildContext,
Duration timeout = const Duration(minutes: 1),
}) async => buildSettings;
......
......@@ -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 'package:flutter_tools/src/artifacts.dart';
......@@ -24,21 +22,21 @@ import '../../src/common.dart';
import '../../src/context.dart';
void main() {
BufferLogger logger;
late BufferLogger logger;
setUp(() {
logger = BufferLogger.test();
});
group('FakeProcessManager', () {
FakeProcessManager fakeProcessManager;
late FakeProcessManager fakeProcessManager;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
});
group('Xcode', () {
FakeXcodeProjectInterpreter xcodeProjectInterpreter;
late FakeXcodeProjectInterpreter xcodeProjectInterpreter;
setUp(() {
xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
......@@ -94,7 +92,7 @@ void main() {
});
group('macOS', () {
Xcode xcode;
late Xcode xcode;
setUp(() {
xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
......@@ -276,8 +274,8 @@ void main() {
});
group('xcdevice not installed', () {
XCDevice xcdevice;
Xcode xcode;
late XCDevice xcdevice;
late Xcode xcode;
setUp(() {
xcode = Xcode.test(
......@@ -310,8 +308,8 @@ void main() {
});
group('xcdevice', () {
XCDevice xcdevice;
Xcode xcode;
late XCDevice xcdevice;
late Xcode xcode;
setUp(() {
xcode = Xcode.test(processManager: FakeProcessManager.any());
......@@ -351,7 +349,7 @@ void main() {
// Attach: d83d5bc53967baa0ee18626ba87b6254b2ab5418
// Attach: 00008027-00192736010F802E
// Detach: d83d5bc53967baa0ee18626ba87b6254b2ab5418
xcdevice.observedDeviceEvents().listen((Map<XCDeviceEvent, String> event) {
xcdevice.observedDeviceEvents()!.listen((Map<XCDeviceEvent, String> event) {
expect(event.length, 1);
if (event.containsKey(XCDeviceEvent.attach)) {
if (event[XCDeviceEvent.attach] == 'd83d5bc53967baa0ee18626ba87b6254b2ab5418') {
......
......@@ -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 'package:file/memory.dart';
......@@ -93,15 +91,15 @@ class FakeBundleBuilder extends Fake implements BundleBuilder {
@override
Future<void> build({
@required TargetPlatform platform,
@required BuildInfo buildInfo,
FlutterProject project,
String mainPath,
required TargetPlatform platform,
required BuildInfo buildInfo,
FlutterProject? project,
String? mainPath,
String manifestPath = defaultManifestPath,
String applicationKernelFilePath,
String depfilePath,
String assetDirPath,
@visibleForTesting BuildSystem buildSystem
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
@visibleForTesting BuildSystem? buildSystem
}) async {
final Directory assetDirectory = fileSystem
.directory(assetDirPath)
......
......@@ -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:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.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 'package:flutter_tools/src/base/logger.dart';
......@@ -107,8 +105,8 @@ void main() {
flutterDevices: <FlutterDevice>[],
);
expect(handler.activeDevToolsServer.host, 'localhost');
expect(handler.activeDevToolsServer.port, 8181);
expect(handler.activeDevToolsServer!.host, 'localhost');
expect(handler.activeDevToolsServer!.port, 8181);
});
testWithoutContext('serveAndAnnounceDevTools with attached device does not fail on null vm service', () async {
......@@ -425,13 +423,13 @@ void main() {
class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
@override
DevToolsServerAddress activeDevToolsServer;
DevToolsServerAddress? activeDevToolsServer;
@override
Uri devToolsUrl;
Uri? devToolsUrl;
@override
Future<DevToolsServerAddress> serve() async => null;
Future<DevToolsServerAddress?> serve() async => null;
@override
Future<void> get ready => readyCompleter.future;
......@@ -452,7 +450,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
final Device device = FakeDevice();
@override
FlutterVmService vmService;
FlutterVmService? vmService;
@override
TargetPlatform targetPlatform = TargetPlatform.android_arm;
......
......@@ -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 'package:file/file.dart';
......@@ -945,14 +943,14 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -971,7 +969,7 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
......@@ -985,7 +983,7 @@ void main() {
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -1005,7 +1003,7 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
......@@ -1019,7 +1017,7 @@ void main() {
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -1090,7 +1088,7 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
......@@ -1115,7 +1113,7 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
......@@ -1127,7 +1125,7 @@ void main() {
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -1150,7 +1148,7 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
......@@ -1162,7 +1160,7 @@ void main() {
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -1186,14 +1184,14 @@ void main() {
listViews,
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false',
},
),
FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{
args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true',
},
......@@ -1309,7 +1307,7 @@ class FakeResidentRunner extends ResidentHandlers {
}
@override
void printHelp({bool details}) {
void printHelp({required bool details}) {
if (details) {
calledPrintWithDetails = true;
} else {
......@@ -1321,7 +1319,7 @@ class FakeResidentRunner extends ResidentHandlers {
Future<void> runSourceGenerators() async { }
@override
Future<OperationResult> restart({bool fullRestart = false, bool pause = false, String reason}) async {
Future<OperationResult> restart({bool fullRestart = false, bool pause = false, String? reason}) async {
if (fullRestart && !supportsRestart) {
throw StateError('illegal restart');
}
......@@ -1345,7 +1343,7 @@ class FakeResidentDevtoolsHandler extends Fake implements ResidentDevtoolsHandle
bool calledLaunchDevToolsInBrowser = false;
@override
bool launchDevToolsInBrowser({List<FlutterDevice> flutterDevices}) {
bool launchDevToolsInBrowser({List<FlutterDevice?>? flutterDevices}) {
return calledLaunchDevToolsInBrowser = true;
}
}
......@@ -1382,8 +1380,8 @@ TerminalHandler setUpTerminalHandler(List<FakeVmServiceRequest> requests, {
bool supportsScreenshot = false,
int reloadExitCode = 0,
BuildMode buildMode = BuildMode.debug,
Logger logger,
FileSystem fileSystem,
Logger? logger,
FileSystem? fileSystem,
}) {
final Logger testLogger = logger ?? BufferLogger.test();
final Signals signals = Signals.test();
......@@ -1440,7 +1438,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { }
class TestRunner extends Fake implements ResidentRunner {
bool hasHelpBeenPrinted = false;
String receivedCommand;
String? receivedCommand;
@override
Future<void> cleanupAfterSignal() async { }
......@@ -1449,22 +1447,22 @@ class TestRunner extends Fake implements ResidentRunner {
Future<void> cleanupAtFinish() async { }
@override
void printHelp({ bool details }) {
void printHelp({ bool? details }) {
hasHelpBeenPrinted = true;
}
@override
Future<int> run({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<void> appStartedCompleter,
Future<int?> run({
Completer<DebugConnectionInfo>? connectionInfoCompleter,
Completer<void>? appStartedCompleter,
bool enableDevTools = false,
String route,
String? route,
}) async => null;
@override
Future<int> attach({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<void> appStartedCompleter,
Future<int?> attach({
Completer<DebugConnectionInfo>? connectionInfoCompleter,
Completer<void>? appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
......@@ -1491,10 +1489,10 @@ class _TestSignals implements Signals {
if (!_handlersTable.containsKey(signal)) {
return false;
}
if (!_handlersTable[signal].containsKey(token)) {
if (!_handlersTable[signal]!.containsKey(token)) {
return false;
}
_handlersTable[signal].remove(token);
_handlersTable[signal]!.remove(token);
return true;
}
......
......@@ -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:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -33,8 +31,8 @@ final BuildInfo debugBuild = BuildInfo(
);
void main() {
FakeResidentCompiler residentCompiler;
FileSystem fileSystem;
late FakeResidentCompiler residentCompiler;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -149,8 +147,7 @@ environment:
await testCompiler.compile(Uri.parse('test/foo.dart'));
final File generatedMain = fileSystem
.directory('.dart_tool')
final File generatedMain = fileSystem.directory('.dart_tool')
.childDirectory('flutter_build')
.childFile('dart_plugin_registrant.dart');
......@@ -170,17 +167,17 @@ environment:
/// Override the creation of the Resident Compiler to simplify testing.
class FakeTestCompiler extends TestCompiler {
FakeTestCompiler(
BuildInfo buildInfo,
FlutterProject flutterProject,
super.buildInfo,
super.flutterProject,
this.residentCompiler, {
String precompiledDillPath,
super.precompiledDillPath,
}
) : super(buildInfo, flutterProject, precompiledDillPath: precompiledDillPath);
);
final FakeResidentCompiler residentCompiler;
final FakeResidentCompiler? residentCompiler;
@override
Future<ResidentCompiler> createCompiler() async {
Future<ResidentCompiler?> createCompiler() async {
return residentCompiler;
}
}
......@@ -188,24 +185,24 @@ class FakeTestCompiler extends TestCompiler {
class FakeResidentCompiler extends Fake implements ResidentCompiler {
FakeResidentCompiler(this.fileSystem);
final FileSystem fileSystem;
final FileSystem? fileSystem;
CompilerOutput compilerOutput;
CompilerOutput? compilerOutput;
bool didShutdown = false;
@override
Future<CompilerOutput> recompile(
Future<CompilerOutput?> recompile(
Uri mainUri,
List<Uri> invalidatedFiles, {
String outputPath,
PackageConfig packageConfig,
String projectRootPath,
FileSystem fs,
List<Uri>? invalidatedFiles, {
String? outputPath,
PackageConfig? packageConfig,
String? projectRootPath,
FileSystem? fs,
bool suppressErrors = false,
bool checkDartPluginRegistry = false,
}) async {
if (compilerOutput != null) {
fileSystem.file(compilerOutput.outputFilename).createSync(recursive: true);
fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true);
}
return compilerOutput;
}
......@@ -217,7 +214,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
void reset() { }
@override
Future<void> shutdown() async {
Future<Object> shutdown() async {
didShutdown = true;
return Object();
}
}
......@@ -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:io';
......@@ -24,7 +22,7 @@ void main() {
test('Can provide default interfaces', () async {
final Testbed testbed = Testbed();
FileSystem localFileSystem;
late FileSystem localFileSystem;
await testbed.run(() {
localFileSystem = globals.fs;
});
......@@ -39,7 +37,7 @@ void main() {
A: () => A(),
});
A instance;
A? instance;
await testbed.run(() {
instance = context.get<A>();
});
......@@ -52,7 +50,7 @@ void main() {
A: () => A(),
});
A instance;
A? instance;
await testbed.run(() {
instance = context.get<A>();
}, overrides: <Type, Generator>{
......
......@@ -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';
import 'package:flutter_tools/src/base/logger.dart';
......@@ -24,8 +22,8 @@ final DateTime _stampUpToDate = _testClock.ago(VersionFreshnessValidator.checkAg
final DateTime _stampOutOfDate = _testClock.ago(VersionFreshnessValidator.checkAgeConsideredUpToDate * 2);
void main() {
FakeCache cache;
FakeProcessManager processManager;
late FakeCache cache;
late FakeProcessManager processManager;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -323,15 +321,15 @@ void main() {
const String flutterNonStandardUrlDotGit = 'https://githubmirror.com/flutter/flutter.git';
const String flutterStandardSshUrlDotGit = 'git@github.com:flutter/flutter.git';
VersionCheckError runUpstreamValidator({
String versionUpstreamUrl,
String flutterGitUrl,
VersionCheckError? runUpstreamValidator({
String? versionUpstreamUrl,
String? flutterGitUrl,
}){
final Platform testPlatform = FakePlatform(environment: <String, String> {
if (flutterGitUrl != null) 'FLUTTER_GIT_URL': flutterGitUrl,
});
return VersionUpstreamValidator(
version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl),
version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl, channel: 'master'),
platform: testPlatform,
).run();
}
......@@ -339,7 +337,7 @@ void main() {
testWithoutContext('returns error if repository url is null', () {
final VersionCheckError error = runUpstreamValidator(
// repositoryUrl is null by default
);
)!;
expect(error, isNotNull);
expect(
error.message,
......@@ -352,7 +350,7 @@ void main() {
});
testWithoutContext('returns error at non-standard remote url with FLUTTER_GIT_URL unset', () {
final VersionCheckError error = runUpstreamValidator(versionUpstreamUrl: flutterNonStandardUrlDotGit);
final VersionCheckError error = runUpstreamValidator(versionUpstreamUrl: flutterNonStandardUrlDotGit)!;
expect(error, isNotNull);
expect(
error.message,
......@@ -375,7 +373,7 @@ void main() {
final VersionCheckError error = runUpstreamValidator(
versionUpstreamUrl: flutterStandardUrlDotGit,
flutterGitUrl: flutterNonStandardUrlDotGit,
);
)!;
expect(error, isNotNull);
expect(
error.message,
......@@ -673,7 +671,7 @@ void main() {
}
class FakeCache extends Fake implements Cache {
String versionStamp;
String? versionStamp;
bool setVersionStamp = false;
@override
......@@ -689,7 +687,7 @@ class FakeCache extends Fake implements Cache {
void checkLockAcquired() { }
@override
String getStampFor(String artifactName) {
String? getStampFor(String artifactName) {
if (artifactName == VersionCheckStamp.flutterVersionCheckStampFile) {
return versionStamp;
}
......@@ -705,11 +703,11 @@ class FakeCache extends Fake implements Cache {
}
class FakeFlutterVersion extends Fake implements FlutterVersion {
FakeFlutterVersion({this.channel, this.repositoryUrl});
FakeFlutterVersion({required this.channel, this.repositoryUrl});
@override
final String channel;
@override
final String repositoryUrl;
final String? repositoryUrl;
}
......@@ -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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -17,9 +15,9 @@ import '../../src/context.dart';
void main() {
group('PrebuiltWindowsApp', () {
FakeOperatingSystemUtils os;
FileSystem fileSystem;
BufferLogger logger;
late FakeOperatingSystemUtils os;
late FileSystem fileSystem;
late BufferLogger logger;
final Map<Type, Generator> overrides = <Type, Generator>{
FileSystem: () => fileSystem,
......@@ -35,7 +33,7 @@ void main() {
});
testUsingContext('Error on non-existing exe file', () {
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.exe')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.exe')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull);
expect(logger.errorText, contains('File "not_existing.exe" does not exist.'));
......@@ -43,13 +41,13 @@ void main() {
testUsingContext('Success on exe file', () {
fileSystem.file('file.exe').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('file.exe')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('file.exe'))! as PrebuiltWindowsApp;
expect(windowsApp.name, 'file.exe');
}, overrides: overrides);
testUsingContext('Error on non-existing zip file', () {
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.zip')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull);
expect(logger.errorText, contains('File "not_existing.zip" does not exist.'));
......@@ -57,7 +55,7 @@ void main() {
testUsingContext('Bad zipped app, no payload dir', () {
fileSystem.file('app.zip').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull);
expect(logger.errorText, contains('Cannot find .exe files in the zip archive.'));
......@@ -74,7 +72,7 @@ void main() {
fileSystem.directory(exePath1).createSync(recursive: true);
fileSystem.directory(exePath2).createSync(recursive: true);
};
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" contains more than one .exe files.'));
......@@ -82,7 +80,7 @@ void main() {
testUsingContext('Success with zipped app', () {
fileSystem.file('app.zip').createSync();
String exePath;
String? exePath;
os.unzipOverride = (File zipFile, Directory targetDirectory) {
if (zipFile.path != 'app.zip') {
return;
......@@ -90,7 +88,7 @@ void main() {
exePath = fileSystem.path.join(targetDirectory.path, 'app.exe');
fileSystem.directory(exePath).createSync(recursive: true);
};
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip'))! as PrebuiltWindowsApp;
expect(logger.errorText, isEmpty);
expect(windowsApp.name, exePath);
......@@ -99,7 +97,7 @@ void main() {
testUsingContext('Error on unknown file type', () {
fileSystem.file('not_existing.app').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltWindowsApp;
final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull);
expect(logger.errorText, contains('Unknown windows application type.'));
......@@ -110,7 +108,7 @@ void main() {
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils();
void Function(File, Directory) unzipOverride;
void Function(File, Directory)? unzipOverride;
@override
void unzip(File file, Directory targetDirectory) {
......
......@@ -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:file/file.dart';
import 'package:vm_service/vm_service.dart';
......@@ -16,8 +14,8 @@ import 'test_utils.dart';
void batch1() {
final BasicProject project = BasicProject();
Directory tempDir;
FlutterRunTestDriver flutter;
late Directory tempDir;
late FlutterRunTestDriver flutter;
Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
......@@ -95,8 +93,8 @@ void batch1() {
void batch2() {
final TestsProject project = TestsProject();
Directory tempDir;
FlutterTestTestDriver flutter;
late Directory tempDir;
late FlutterTestTestDriver flutter;
Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('test_expression_eval_test.');
......@@ -105,7 +103,7 @@ void batch2() {
}
Future<void> cleanProject() async {
await flutter?.waitForCompletion();
await flutter.waitForCompletion();
tryToDelete(tempDir);
}
......@@ -165,14 +163,14 @@ Future<void> evaluateComplexReturningExpressions(FlutterTestDriver flutter) asyn
final DateTime date = DateTime(2000);
final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)');
expectInstanceOfClass(resp, 'DateTime');
final ObjRef res = await flutter.evaluate(resp.id, r'"$year-$month-$day"');
final ObjRef res = await flutter.evaluate(resp.id!, r'"$year-$month-$day"');
expectValue(res, '${date.year}-${date.month}-${date.day}');
}
void expectInstanceOfClass(ObjRef result, String name) {
expect(result,
const TypeMatcher<InstanceRef>()
.having((InstanceRef instance) => instance.classRef.name, 'resp.classRef.name', name));
.having((InstanceRef instance) => instance.classRef!.name, 'resp.classRef.name', name));
}
void expectValueOfType(ObjRef result, String kind, String message) {
......
......@@ -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:file/file.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/flutter_project_metadata.dart';
......@@ -17,9 +15,9 @@ import 'test_utils.dart';
void main() {
Directory tempDir;
FlutterRunTestDriver flutter;
Logger logger;
late Directory tempDir;
late FlutterRunTestDriver flutter;
late Logger logger;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
......@@ -71,11 +69,11 @@ migration:
''', flush: true);
FlutterProjectMetadata metadata = FlutterProjectMetadata(metadataFile, logger);
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.unmanagedFiles[0], equals('lib/main.dart'));
expect(metadata.migrateConfig.unmanagedFiles[1], equals('ios/Runner.xcodeproj/project.pbxproj'));
......@@ -169,8 +167,6 @@ migration:
projectDirectory: tempDir,
currentRevision: currentRevision,
createRevision: createRevision,
create: true,
update: true,
logger: logger,
);
......@@ -179,16 +175,16 @@ migration:
final List<SupportedPlatform> keyList = List<SupportedPlatform>.from(metadata.migrateConfig.platformConfigs.keys);
expect(keyList[0], equals(SupportedPlatform.root));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals(createRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals(createRevision));
expect(keyList[1], equals(SupportedPlatform.android));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals(createRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals(createRevision));
expect(keyList[2], equals(SupportedPlatform.ios));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].createRevision, equals(createRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.createRevision, equals(createRevision));
final File metadataFileOutput = tempDir.childFile('.metadata_output');
metadata.writeFile(outputFile: metadataFileOutput);
......
......@@ -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:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
......@@ -15,7 +13,7 @@ import '../src/context.dart';
import '../src/test_flutter_command_runner.dart';
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
group('analyze project command', () {
......
......@@ -849,9 +849,9 @@ class FlutterTestTestDriver extends FlutterTestDriver {
await resume();
final Future<Object> timeoutFuture =
Future<Object>.delayed(defaultTimeout);
await Future.any<Object>(<Future<Object>>[done.future, timeoutFuture]);
final Future<void> timeoutFuture =
Future<void>.delayed(defaultTimeout);
await Future.any<void>(<Future<void>>[done.future, timeoutFuture]);
await subscription.cancel();
if (!done.isCompleted) {
await quit();
......
......@@ -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 'package:args/command_runner.dart';
......@@ -21,8 +19,8 @@ import '../src/context.dart';
import '../src/test_flutter_command_runner.dart';
void main() {
Directory tempDir;
Directory projectDir;
late Directory tempDir;
late Directory projectDir;
setUpAll(() async {
Cache.disableLocking();
......@@ -195,8 +193,8 @@ Future<void> _createProject(Directory dir, List<String> createArgs) async {
Future<void> _addDependency(
Directory projectDir,
String package, {
String version,
String path,
String? version,
String? path,
}) async {
assert(version != null || path != null,
'Need to define a source for the package.');
......@@ -249,7 +247,7 @@ Future<void> _analyzeEntity(FileSystemEntity target) async {
];
final ProcessResult exec = await Process.run(
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
args,
workingDirectory: target is Directory ? target.path : target.dirname,
);
......@@ -277,7 +275,7 @@ Future<void> _buildWebProject(Directory workingDir) async {
];
final ProcessResult exec = await Process.run(
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
args,
workingDirectory: workingDir.path,
);
......
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