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

This commit is contained in:
Jonah Williams 2022-06-17 21:34:27 -07:00 committed by GitHub
parent 2af8250361
commit db829c1e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
70 changed files with 798 additions and 950 deletions

View File

@ -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');

View File

@ -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');
}

View File

@ -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))),
);

View File

@ -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;

View File

@ -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`.

View File

@ -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) {

View File

@ -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 {

View File

@ -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;
}

View File

@ -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) {

View File

@ -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();

View File

@ -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;

View File

@ -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)

View File

@ -2,23 +2,20 @@
// 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/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import '../../src/common.dart';
import '../../src/context.dart';
void main() {
MemoryFileSystem fileSystem;
FakeProcessManager processManager;
Config config;
late MemoryFileSystem fileSystem;
late FakeProcessManager processManager;
late Config config;
setUp(() {
fileSystem = MemoryFileSystem.test();
@ -27,22 +24,22 @@ void main() {
});
group('AndroidSdk', () {
Directory sdkDir;
Directory? sdkDir;
tearDown(() {
if (sdkDir != null) {
tryToDelete(sdkDir);
tryToDelete(sdkDir!);
sdkDir = null;
}
});
testUsingContext('parse sdk', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
expect(sdk.latestVersion, isNotNull);
expect(sdk.latestVersion.sdkLevel, 23);
expect(sdk.latestVersion!.sdkLevel, 23);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -51,11 +48,11 @@ void main() {
testUsingContext('parse sdk N', () {
sdkDir = createSdkDirectory(withAndroidN: true, fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
expect(sdk.latestVersion, isNotNull);
expect(sdk.latestVersion.sdkLevel, 24);
expect(sdk.latestVersion!.sdkLevel, 24);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -64,9 +61,9 @@ void main() {
testUsingContext('returns sdkmanager path under cmdline tools on Linux/macOS', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'sdkmanager')
).createSync(recursive: true);
@ -81,9 +78,9 @@ void main() {
testUsingContext('returns sdkmanager path under cmdline tools (highest version) on Linux/macOS', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
final List<String> versions = <String>['3.0', '2.1', '1.0'];
for (final String version in versions) {
fileSystem.file(
@ -101,9 +98,9 @@ void main() {
testUsingContext('Does not return sdkmanager under deprecated tools component', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'tools/bin/sdkmanager')
).createSync(recursive: true);
@ -118,14 +115,14 @@ void main() {
testUsingContext('Can look up cmdline tool from deprecated tools path', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'tools/bin/foo')
).createSync(recursive: true);
expect(sdk.getCmdlineToolsPath('foo', skipOldTools: false), '/.tmp_rand0/flutter_mock_android_sdk.rand0/tools/bin/foo');
expect(sdk.getCmdlineToolsPath('foo'), '/.tmp_rand0/flutter_mock_android_sdk.rand0/tools/bin/foo');
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -135,9 +132,9 @@ void main() {
testUsingContext('Caches adb location after first access', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
final File adbFile = fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'adb.exe')
)..createSync(recursive: true);
@ -156,9 +153,9 @@ void main() {
testUsingContext('returns sdkmanager.bat path under cmdline tools for windows', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'sdkmanager.bat')
).createSync(recursive: true);
@ -174,7 +171,7 @@ void main() {
testUsingContext('returns sdkmanager version', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
processManager.addCommand(
const FakeCommand(
command: <String>[
@ -184,7 +181,7 @@ void main() {
stdout: '26.1.1\n',
),
);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
expect(sdk.sdkManagerVersion, '26.1.1');
}, overrides: <Type, Generator>{
@ -202,8 +199,8 @@ void main() {
'/.tmp_rand0/flutter_mock_android_sdk.rand0/cmdline-tools/latest/bin/sdkmanager',
'--version',
]));
config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
final List<String> validationIssues = sdk.validateSdkWellFormed();
expect(validationIssues.first, 'No valid Android SDK platforms found in'
@ -219,7 +216,7 @@ void main() {
testUsingContext('does not throw on sdkmanager version check failure', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
processManager.addCommand(
const FakeCommand(
command: <String>[
@ -232,7 +229,7 @@ void main() {
),
);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
expect(sdk.sdkManagerVersion, isNull);
}, overrides: <Type, Generator>{
@ -244,11 +241,11 @@ void main() {
testUsingContext('throws on sdkmanager version check if sdkmanager not found', () {
sdkDir = createSdkDirectory(withSdkManager: false, fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
processManager.excludedExecutables.add('/.tmp_rand0/flutter_mock_android_sdk.rand0/cmdline-tools/latest/bin/sdkmanager');
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk? sdk = AndroidSdk.locateAndroidSdk();
expect(() => sdk.sdkManagerVersion, throwsToolExit());
expect(() => sdk!.sdkManagerVersion, throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
@ -258,9 +255,9 @@ void main() {
testUsingContext('returns avdmanager path under cmdline tools', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'avdmanager')
).createSync(recursive: true);
@ -275,9 +272,9 @@ void main() {
testUsingContext('returns avdmanager path under cmdline tools on windows', () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'avdmanager.bat')
).createSync(recursive: true);
@ -292,9 +289,9 @@ void main() {
testUsingContext("returns avdmanager path under tools if cmdline doesn't exist", () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'tools', 'bin', 'avdmanager')
).createSync(recursive: true);
@ -309,9 +306,9 @@ void main() {
testUsingContext("returns avdmanager path under tools if cmdline doesn't exist on windows", () {
sdkDir = createSdkDirectory(fileSystem: fileSystem);
config.setValue('android-sdk', sdkDir.path);
config.setValue('android-sdk', sdkDir!.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'tools', 'bin', 'avdmanager.bat')
).createSync(recursive: true);
@ -330,7 +327,7 @@ void main() {
Directory createBrokenSdkDirectory({
bool withAndroidN = false,
bool withSdkManager = true,
@required FileSystem fileSystem,
required FileSystem fileSystem,
}) {
final Directory dir = fileSystem.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
_createSdkFile(dir, 'licenses/dummy');
@ -346,7 +343,7 @@ Directory createBrokenSdkDirectory({
return dir;
}
void _createSdkFile(Directory dir, String filePath, { String contents }) {
void _createSdkFile(Directory dir, String filePath, { String? contents }) {
final File file = dir.childFile(filePath);
file.createSync(recursive: true);
if (contents != null) {
@ -359,7 +356,7 @@ Directory createSdkDirectory({
bool withSdkManager = true,
bool withPlatformTools = true,
bool withBuildTools = true,
@required FileSystem fileSystem,
required FileSystem fileSystem,
}) {
final Directory dir = fileSystem.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
final String exe = globals.platform.isWindows ? '.exe' : '';

View File

@ -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.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@ -20,24 +18,24 @@ import '../../src/fake_process_manager.dart';
const String homeLinux = '/home/me';
const String homeMac = '/Users/me';
const Map<String, dynamic> macStudioInfoPlist = <String, dynamic>{
const Map<String, Object> macStudioInfoPlist = <String, Object>{
'CFBundleGetInfoString': 'Android Studio 3.3, build AI-182.5107.16.33.5199772. Copyright JetBrains s.r.o., (c) 2000-2018',
'CFBundleShortVersionString': '3.3',
'CFBundleVersion': 'AI-182.5107.16.33.5199772',
'JVMOptions': <String, dynamic>{
'Properties': <String, dynamic>{
'JVMOptions': <String, Object>{
'Properties': <String, Object>{
'idea.paths.selector': 'AndroidStudio3.3',
'idea.platform.prefix': 'AndroidStudio',
},
},
};
const Map<String, dynamic> macStudioInfoPlist4_1 = <String, dynamic>{
const Map<String, Object> macStudioInfoPlist4_1 = <String, Object>{
'CFBundleGetInfoString': 'Android Studio 4.1, build AI-201.8743.12.41.6858069. Copyright JetBrains s.r.o., (c) 2000-2020',
'CFBundleShortVersionString': '4.1',
'CFBundleVersion': 'AI-201.8743.12.41.6858069',
'JVMOptions': <String, dynamic>{
'Properties': <String, dynamic>{
'JVMOptions': <String, Object>{
'Properties': <String, Object>{
'idea.vendor.name' : 'Google',
'idea.paths.selector': 'AndroidStudio4.1',
'idea.platform.prefix': 'AndroidStudio',
@ -45,12 +43,12 @@ const Map<String, dynamic> macStudioInfoPlist4_1 = <String, dynamic>{
},
};
const Map<String, dynamic> macStudioInfoPlist2020_3 = <String, dynamic>{
const Map<String, Object> macStudioInfoPlist2020_3 = <String, Object>{
'CFBundleGetInfoString': 'Android Studio 2020.3, build AI-203.7717.56.2031.7583922. Copyright JetBrains s.r.o., (c) 2000-2021',
'CFBundleShortVersionString': '2020.3',
'CFBundleVersion': 'AI-203.7717.56.2031.7583922',
'JVMOptions': <String, dynamic>{
'Properties': <String, dynamic>{
'JVMOptions': <String, Object>{
'Properties': <String, Object>{
'idea.vendor.name' : 'Google',
'idea.paths.selector': 'AndroidStudio2020.3',
'idea.platform.prefix': 'AndroidStudio',
@ -58,12 +56,12 @@ const Map<String, dynamic> macStudioInfoPlist2020_3 = <String, dynamic>{
},
};
const Map<String, dynamic> macStudioInfoPlistEAP = <String, dynamic>{
const Map<String, Object> macStudioInfoPlistEAP = <String, Object>{
'CFBundleGetInfoString': 'Android Studio EAP AI-212.5712.43.2112.8233820, build AI-212.5712.43.2112.8233820. Copyright JetBrains s.r.o., (c) 2000-2022',
'CFBundleShortVersionString': 'EAP AI-212.5712.43.2112.8233820',
'CFBundleVersion': 'AI-212.5712.43.2112.8233820',
'JVMOptions': <String, dynamic>{
'Properties': <String, dynamic>{
'JVMOptions': <String, Object>{
'Properties': <String, Object>{
'idea.vendor.name' : 'Google',
'idea.paths.selector': 'AndroidStudio2021.2',
'idea.platform.prefix': 'AndroidStudio',
@ -90,7 +88,7 @@ Platform macPlatform() {
}
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
@ -105,7 +103,7 @@ void main() {
globals.fs.file(homeFile).writeAsStringSync(installPath);
final AndroidStudio studio =
AndroidStudio.fromHomeDot(globals.fs.directory(studioHome));
AndroidStudio.fromHomeDot(globals.fs.directory(studioHome))!;
expect(studio, isNotNull);
expect(studio.pluginsPath,
equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins'));
@ -122,10 +120,10 @@ void main() {
});
group('pluginsPath on Mac', () {
FileSystemUtils fsUtils;
Platform platform;
FakePlistUtils plistUtils;
FakeProcessManager processManager;
late FileSystemUtils fsUtils;
late Platform platform;
late FakePlistUtils plistUtils;
late FakeProcessManager processManager;
setUp(() {
plistUtils = FakePlistUtils();
@ -157,8 +155,8 @@ void main() {
)
);
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
)!;
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
@ -199,8 +197,8 @@ void main() {
)
);
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
)!;
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
@ -241,8 +239,8 @@ void main() {
)
);
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
)!;
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
@ -282,8 +280,8 @@ void main() {
)
);
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
)!;
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
@ -313,13 +311,13 @@ void main() {
globals.fs.directory(applicationPlistFolder).createSync(recursive: true);
final String applicationsPlistFilePath = globals.fs.path.join(applicationPlistFolder, 'Info.plist');
const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
const Map<String, Object> jetbrainsInfoPlist = <String, Object>{
'JetBrainsToolboxApp': 'ignored',
};
plistUtils.fileContents[applicationsPlistFilePath] = jetbrainsInfoPlist;
final String homeDirectoryPlistFolder = globals.fs.path.join(
globals.fsUtils.homeDirPath,
globals.fsUtils.homeDirPath!,
'Applications',
'Android Studio.app',
'Contents',
@ -438,7 +436,7 @@ void main() {
plistUtils.fileContents[applicationsPlistFilePath] = macStudioInfoPlist;
final String homeDirectoryPlistFolder = globals.fs.path.join(
globals.fsUtils.homeDirPath,
globals.fsUtils.homeDirPath!,
'Applications',
'Android Studio.app',
'Contents',
@ -449,7 +447,7 @@ void main() {
plistUtils.fileContents[homeDirectoryPlistFilePath] = macStudioInfoPlist4_1;
expect(AndroidStudio.allInstalled().length, 2);
expect(AndroidStudio.latestValid().version, Version(4, 1, 0));
expect(AndroidStudio.latestValid()!.version, Version(4, 1, 0));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
FileSystemUtils: () => fsUtils,
@ -470,8 +468,8 @@ void main() {
final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist;
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
)!;
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
homeMac,
@ -490,7 +488,7 @@ void main() {
});
});
FileSystem windowsFileSystem;
late FileSystem windowsFileSystem;
setUp(() {
windowsFileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
@ -500,8 +498,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
final AndroidStudio studio = AndroidStudio.allInstalled().single;
@ -518,8 +515,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.2\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
final AndroidStudio studio = AndroidStudio.allInstalled().single;
@ -536,8 +532,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2020.3\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
final AndroidStudio studio = AndroidStudio.allInstalled().single;
@ -554,8 +549,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
expect(AndroidStudio.allInstalled(), isEmpty);
@ -572,8 +566,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.2\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
expect(AndroidStudio.allInstalled(), isEmpty);
@ -590,8 +583,7 @@ void main() {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2020.3\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
expect(AndroidStudio.allInstalled(), isEmpty);
@ -605,7 +597,7 @@ void main() {
});
group('Installation detection on Linux', () {
FileSystemUtils fsUtils;
late FileSystemUtils fsUtils;
setUp(() {
fsUtils = FileSystemUtils(
@ -698,10 +690,10 @@ void main() {
}
class FakePlistUtils extends Fake implements PlistParser {
final Map<String, Map<String, dynamic>> fileContents = <String, Map<String, dynamic>>{};
final Map<String, Map<String, Object>> fileContents = <String, Map<String, Object>>{};
@override
Map<String, dynamic> parseFile(String plistFilePath) {
return fileContents[plistFilePath];
Map<String, Object> parseFile(String plistFilePath) {
return fileContents[plistFilePath]!;
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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()),

View File

@ -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';

View File

@ -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>{

View File

@ -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' );

View File

@ -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';
@ -21,7 +19,7 @@ import '../src/context.dart';
void main() {
group('AssetBundle.build', () {
FileSystem testFileSystem;
late FileSystem testFileSystem;
setUp(() async {
testFileSystem = MemoryFileSystem(
@ -47,11 +45,11 @@ void main() {
..writeAsStringSync('');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 1);
const String expectedAssetManifest = '{}';
expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest,
);
}, overrides: <Type, Generator>{
@ -71,22 +69,22 @@ flutter:
- assets/foo/
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
// - license file
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
// Simulate modifying the files by updating the filestat time manually.
globals.fs.file(globals.fs.path.join('assets', 'foo', 'fizz.txt'))
..createSync(recursive: true)
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.needsBuild(), true);
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
@ -111,14 +109,14 @@ flutter:
''');
globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
// - license file
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
// Delete the wildcard directory and update pubspec file.
final DateTime modifiedTime = pubspec.lastModifiedSync().add(const Duration(hours: 1));
@ -136,8 +134,8 @@ name: example''')
// Even though the previous file was removed, it is left in the
// asset manifest and not updated. This is due to the devfs not
// supporting file deletion.
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.needsBuild(), true);
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
@ -165,14 +163,14 @@ flutter:
''');
globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
// - license file
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -202,7 +200,7 @@ flutter:
platform: globals.platform,
splitDeferredAssets: true,
).createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true);
await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true);
// Expected assets:
// - asset manifest
// - font manifest
@ -210,8 +208,8 @@ flutter:
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.deferredComponentsEntries.length, 1);
expect(bundle.deferredComponentsEntries['component1'].length, 2);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.deferredComponentsEntries['component1']!.length, 2);
expect(bundle.needsBuild(), false);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -236,7 +234,7 @@ flutter:
- assets/wild/
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: false);
await bundle.build(packagesPath: '.packages');
// Expected assets:
// - asset manifest
// - font manifest
@ -244,7 +242,7 @@ flutter:
// - assets/foo/bar.txt
expect(bundle.entries.length, 6);
expect(bundle.deferredComponentsEntries.isEmpty, true);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -274,7 +272,7 @@ flutter:
platform: globals.platform,
splitDeferredAssets: true,
).createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true);
await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true);
// Expected assets:
// - asset manifest
// - font manifest
@ -282,20 +280,20 @@ flutter:
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.deferredComponentsEntries.length, 1);
expect(bundle.deferredComponentsEntries['component1'].length, 2);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.deferredComponentsEntries['component1']!.length, 2);
expect(bundle.needsBuild(), false);
// Simulate modifying the files by updating the filestat time manually.
globals.fs.file(globals.fs.path.join('assets', 'wild', 'fizz.txt'))
..createSync(recursive: true)
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true);
expect(bundle.needsBuild(), true);
await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true);
expect(bundle.entries.length, 4);
expect(bundle.deferredComponentsEntries.length, 1);
expect(bundle.deferredComponentsEntries['component1'].length, 3);
expect(bundle.deferredComponentsEntries['component1']!.length, 3);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(),
@ -327,16 +325,16 @@ assets:
- assets/foo/bar.txt
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
final DevFSStringContent assetManifest = bundle.entries['AssetManifest.json']
as DevFSStringContent;
final DevFSStringContent fontManifest = bundle.entries['FontManifest.json']
as DevFSStringContent;
final DevFSStringContent license = bundle.entries['NOTICES']
as DevFSStringContent;
final DevFSStringContent? assetManifest = bundle.entries['AssetManifest.json']
as DevFSStringContent?;
final DevFSStringContent? fontManifest = bundle.entries['FontManifest.json']
as DevFSStringContent?;
final DevFSStringContent? license = bundle.entries['NOTICES']
as DevFSStringContent?;
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(assetManifest, bundle.entries['AssetManifest.json']);
expect(fontManifest, bundle.entries['FontManifest.json']);
@ -360,7 +358,7 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(await bundle.build(packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies.single.path, contains('DOES_NOT_EXIST_RERUN_FOR_WILDCARD'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -381,7 +379,7 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(await bundle.build(packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies, isEmpty);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -390,12 +388,12 @@ flutter:
group('Shaders: ', () {
MemoryFileSystem fileSystem;
Artifacts artifacts;
String impellerc;
Directory output;
String shaderPath;
String outputPath;
late MemoryFileSystem fileSystem;
late Artifacts artifacts;
late String impellerc;
late Directory output;
late String shaderPath;
late String outputPath;
setUp(() {
artifacts = Artifacts.test();
@ -422,7 +420,7 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(await bundle.build(packagesPath: '.packages'), 0);
await writeBundle(output, bundle.entries, loggerOverride: testLogger);
@ -472,7 +470,7 @@ flutter:
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(await bundle.build(packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies, isEmpty);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -506,16 +504,16 @@ flutter:
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
await bundle.build(packagesPath: '.packages');
expect(bundle.entries, hasLength(4));
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
// Does not track dependency's wildcard directories.
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
.deleteSync();
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
expect(bundle.needsBuild(), false);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
@ -548,7 +546,7 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1);
expect(await bundle.build(packagesPath: '.packages'), 1);
expect(testLogger.errorText, contains('This asset was included from package foo'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -571,7 +569,7 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1);
expect(await bundle.build(packagesPath: '.packages'), 1);
expect(testLogger.errorText, isNot(contains('This asset was included from')));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -605,9 +603,9 @@ flutter:
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]');
expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{}');
expect(await bundle.build(packagesPath: '.packages'), 0);
expect((bundle.entries['FontManifest.json']! as DevFSStringContent).string, '[]');
expect((bundle.entries['AssetManifest.json']! as DevFSStringContent).string, '{}');
expect(testLogger.errorText, contains(
'package:foo has `uses-material-design: true` set'
));
@ -642,7 +640,7 @@ flutter:
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(await bundle.build(packagesPath: '.packages'), 0);
expect(bundle.entries.length, 4);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
@ -676,11 +674,11 @@ flutter:
globals.fs.file('assets/zebra.jpg').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]');
expect(await bundle.build(packagesPath: '.packages'), 0);
expect((bundle.entries['FontManifest.json']! as DevFSStringContent).string, '[]');
// The assets from deferred components and regular assets
// are both included in alphabetical order
expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{"assets/apple.jpg":["assets/apple.jpg"],"assets/bar.jpg":["assets/bar.jpg"],"assets/foo.jpg":["assets/foo.jpg"],"assets/zebra.jpg":["assets/zebra.jpg"]}');
expect((bundle.entries['AssetManifest.json']! as DevFSStringContent).string, '{"assets/apple.jpg":["assets/apple.jpg"],"assets/bar.jpg":["assets/bar.jpg"],"assets/foo.jpg":["assets/foo.jpg"],"assets/zebra.jpg":["assets/zebra.jpg"]}');
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),

View File

@ -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,

View File

@ -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());
}

View File

@ -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.

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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

View File

@ -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');
});
}

View File

@ -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();

View File

@ -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();
});

View File

@ -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();

View File

@ -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: () {

View File

@ -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);

View File

@ -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(),

View File

@ -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 {

View File

@ -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.']);

View File

@ -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>{

View File

@ -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>{

View File

@ -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;
},
);

View File

@ -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';

View File

@ -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 {}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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',

View File

@ -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;

View File

@ -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();
});

View File

@ -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
```

View File

@ -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();
}

View File

@ -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(() {

View File

@ -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;
}

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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') {

View File

@ -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';
@ -21,7 +19,6 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/plugins.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import 'package:yaml/yaml.dart';
@ -42,16 +39,16 @@ class _PluginPlatformInfo {
assert(androidPackage == null || pluginClass != null);
/// The pluginClass entry, if any.
final String pluginClass;
final String? pluginClass;
/// The dartPluginClass entry, if any.
final String dartPluginClass;
final String? dartPluginClass;
/// The package entry for an Android plugin implementation using pluginClass.
final String androidPackage;
final String? androidPackage;
/// The fileName entry for a web plugin implementation.
final String fileName;
final String? fileName;
/// Returns the body of a platform section for a plugin's pubspec, properly
/// indented.
@ -72,21 +69,21 @@ class _PluginPlatformInfo {
void main() {
group('plugins', () {
FileSystem fs;
FakeFlutterProject flutterProject;
FakeFlutterManifest flutterManifest;
FakeIosProject iosProject;
FakeMacOSProject macosProject;
FakeAndroidProject androidProject;
FakeWebProject webProject;
FakeWindowsProject windowsProject;
FakeLinuxProject linuxProject;
FakeSystemClock systemClock;
FlutterVersion flutterVersion;
late FileSystem fs;
late FakeFlutterProject flutterProject;
late FakeFlutterManifest flutterManifest;
late FakeIosProject iosProject;
late FakeMacOSProject macosProject;
late FakeAndroidProject androidProject;
late FakeWebProject webProject;
late FakeWindowsProject windowsProject;
late FakeLinuxProject linuxProject;
late FakeSystemClock systemClock;
late FlutterVersion flutterVersion;
// A Windows-style filesystem. This is not populated by default, so tests
// using it instead of fs must re-run any necessary setup (e.g.,
// setUpProject).
FileSystem fsWindows;
late FileSystem fsWindows;
// Adds basic properties to the flutterProject and its subprojects.
void setUpProject(FileSystem fileSystem) {
@ -372,8 +369,8 @@ flutter:
}
Directory createLegacyPluginWithDependencies({
@required String name,
@required List<String> dependencies,
required String name,
required List<String> dependencies,
}) {
assert(name != null);
assert(dependencies != null);
@ -404,8 +401,8 @@ dependencies:
}
Directory createPlugin({
@required String name,
@required Map<String, _PluginPlatformInfo> platforms,
required String name,
required Map<String, _PluginPlatformInfo> platforms,
List<String> dependencies = const <String>[],
}) {
assert(name != null);
@ -619,15 +616,15 @@ dependencies:
expect(flutterProject.flutterPluginsDependenciesFile.existsSync(), true);
final String pluginsString = flutterProject.flutterPluginsDependenciesFile.readAsStringSync();
final Map<String, dynamic> jsonContent = json.decode(pluginsString) as Map<String, dynamic>;
final Map<String, dynamic> plugins = jsonContent['plugins'] as Map<String, dynamic>;
final Map<String, dynamic>? plugins = jsonContent['plugins'] as Map<String, dynamic>?;
// Extracts the native_build key (if any) from the first plugin for the
// given platform.
bool getNativeBuildValue(String platform) {
final List<Map<String, dynamic>> platformPlugins = (plugins[platform]
bool? getNativeBuildValue(String platform) {
final List<Map<String, dynamic>> platformPlugins = (plugins![platform]
as List<dynamic>).cast<Map<String, dynamic>>();
expect(platformPlugins.length, 1);
return platformPlugins[0]['native_build'] as bool;
return platformPlugins[0]['native_build'] as bool?;
}
expect(getNativeBuildValue('android'), true);
expect(getNativeBuildValue('ios'), true);
@ -682,7 +679,7 @@ dependencies:
});
group('injectPlugins', () {
FakeXcodeProjectInterpreter xcodeProjectInterpreter;
FakeXcodeProjectInterpreter? xcodeProjectInterpreter;
setUp(() {
xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
@ -1402,8 +1399,8 @@ flutter:
await injectPlugins(flutterProject, linuxPlatform: true, windowsPlatform: true);
for (final CmakeBasedProject project in <CmakeBasedProject>[linuxProject, windowsProject]) {
final File pluginCmakefile = project.generatedPluginCmakeFile;
for (final CmakeBasedProject? project in <CmakeBasedProject?>[linuxProject, windowsProject]) {
final File pluginCmakefile = project!.generatedPluginCmakeFile;
expect(pluginCmakefile.existsSync(), isTrue);
final String contents = pluginCmakefile.readAsStringSync();
@ -1416,7 +1413,7 @@ flutter:
});
group('createPluginSymlinks', () {
FeatureFlags featureFlags;
FeatureFlags? featureFlags;
setUp(() {
featureFlags = TestFeatureFlags(isLinuxEnabled: true, isWindowsEnabled: true);
@ -1546,8 +1543,8 @@ flutter:
});
group('pubspec', () {
Directory projectDir;
Directory tempDir;
late Directory projectDir;
late Directory tempDir;
setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_plugin_test.');
@ -1603,7 +1600,7 @@ flutter:
});
testUsingContext('createPlatformsYamlMap should create empty map', () async {
final YamlMap map = Plugin.createPlatformsYamlMap(<String>[], null, null);
final YamlMap map = Plugin.createPlatformsYamlMap(<String>[], 'foo', 'bar');
expect(map.isEmpty, true);
});
@ -1655,34 +1652,34 @@ 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
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;
}
class FakeMacOSProject extends Fake implements MacOSProject {
@ -1692,13 +1689,13 @@ class FakeMacOSProject extends Fake implements MacOSProject {
bool exists = false;
@override
File podfile;
late File podfile;
@override
File podManifestLock;
late File podManifestLock;
@override
Directory managedDirectory;
late Directory managedDirectory;
@override
bool existsSync() => exists;
@ -1717,7 +1714,7 @@ class FakeIosProject extends Fake implements IosProject {
bool get exists => testExists;
@override
Directory pluginRegistrantHost;
late Directory pluginRegistrantHost;
@override
File get pluginRegistrantHeader => pluginRegistrantHost.childFile('GeneratedPluginRegistrant.h');
@ -1726,10 +1723,10 @@ class FakeIosProject extends Fake implements IosProject {
File get pluginRegistrantImplementation => pluginRegistrantHost.childFile('GeneratedPluginRegistrant.m');
@override
File podfile;
late File podfile;
@override
File podManifestLock;
late File podManifestLock;
}
class FakeAndroidProject extends Fake implements AndroidProject {
@ -1739,15 +1736,15 @@ class FakeAndroidProject extends Fake implements AndroidProject {
bool exists = false;
@override
Directory pluginRegistrantHost;
late Directory pluginRegistrantHost;
@override
Directory hostAppGradleRoot;
late Directory hostAppGradleRoot;
@override
File appManifestFile;
late File appManifestFile;
AndroidEmbeddingVersion embeddingVersion;
late AndroidEmbeddingVersion embeddingVersion;
@override
bool existsSync() => exists;
@ -1768,7 +1765,7 @@ class FakeWebProject extends Fake implements WebProject {
String pluginConfigKey = 'web';
@override
Directory libDirectory;
late Directory libDirectory;
bool exists = false;
@ -1781,19 +1778,19 @@ class FakeWindowsProject extends Fake implements WindowsProject {
String pluginConfigKey = 'windows';
@override
Directory managedDirectory;
late Directory managedDirectory;
@override
Directory ephemeralDirectory;
late Directory ephemeralDirectory;
@override
Directory pluginSymlinkDirectory;
late Directory pluginSymlinkDirectory;
@override
File cmakeFile;
late File cmakeFile;
@override
File generatedPluginCmakeFile;
late File generatedPluginCmakeFile;
bool exists = false;
@override
@ -1805,19 +1802,19 @@ class FakeLinuxProject extends Fake implements LinuxProject {
String pluginConfigKey = 'linux';
@override
Directory managedDirectory;
late Directory managedDirectory;
@override
Directory ephemeralDirectory;
late Directory ephemeralDirectory;
@override
Directory pluginSymlinkDirectory;
late Directory pluginSymlinkDirectory;
@override
File cmakeFile;
late File cmakeFile;
@override
File generatedPluginCmakeFile;
late File generatedPluginCmakeFile;
bool exists = false;
@override
@ -1833,7 +1830,7 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
}
class FakeSystemClock extends Fake implements SystemClock {
DateTime currentTime;
late DateTime currentTime;
@override
DateTime now() {

View File

@ -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)

View File

@ -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';

View File

@ -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;

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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>{

View File

@ -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;
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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', () {

View File

@ -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();

View File

@ -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,
);