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

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

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

* Fix analysis

* Fix tests

* Fix analysis

* Apply suggestions from code review
Co-authored-by: 's avatarChristopher Fujino <fujino@google.com>
Co-authored-by: 's avatarChristopher Fujino <fujino@google.com>
parent 6c79dcca
......@@ -707,7 +707,7 @@ abstract class ResidentHandlers {
}
final List<FlutterView> views = await device!.vmService!.getFlutterViews();
for (final FlutterView view in views) {
final Map<String, Object>? rasterData =
final Map<String, Object?>? rasterData =
await device.vmService!.renderFrameWithRasterStats(
viewId: view.id,
uiIsolateId: view.uiIsolate!.id,
......
......@@ -557,7 +557,7 @@ class FlutterVmService {
/// for rasterization which is not reflective of how long the frame takes in
/// production. This is primarily intended to be used to identify the layers
/// that result in the most raster perf degradation.
Future<Map<String, Object>?> renderFrameWithRasterStats({
Future<Map<String, Object?>?> renderFrameWithRasterStats({
required String? viewId,
required String? uiIsolateId,
}) async {
......@@ -568,7 +568,7 @@ class FlutterVmService {
'viewId': viewId,
},
);
return response?.json as Map<String, Object>?;
return response?.json;
}
Future<String> flutterDebugDumpApp({
......
......@@ -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/android_sdk.dart';
......@@ -30,10 +28,10 @@ import '../src/fakes.dart';
void main() {
group('Apk with partial Android SDK works', () {
FakeAndroidSdk sdk;
FakeProcessManager fakeProcessManager;
MemoryFileSystem fs;
Cache cache;
late FakeAndroidSdk sdk;
late FakeProcessManager fakeProcessManager;
late MemoryFileSystem fs;
late Cache cache;
final Map<Type, Generator> overrides = <Type, Generator>{
AndroidSdk: () => sdk,
......@@ -79,11 +77,10 @@ void main() {
)
);
final ApplicationPackage applicationPackage = await ApplicationPackageFactory.instance.getPackageForPlatform(
final ApplicationPackage applicationPackage = (await ApplicationPackageFactory.instance!.getPackageForPlatform(
TargetPlatform.android_arm,
buildInfo: null,
applicationBinary: apkFile,
);
))!;
expect(applicationPackage.name, 'app.apk');
expect(applicationPackage, isA<PrebuiltApplicationPackage>());
expect((applicationPackage as PrebuiltApplicationPackage).applicationPackage.path, apkFile.path);
......@@ -104,9 +101,8 @@ void main() {
gradleWrapperDir.childFile('gradlew').writeAsStringSync('irrelevant');
gradleWrapperDir.childFile('gradlew.bat').writeAsStringSync('irrelevant');
await ApplicationPackageFactory.instance.getPackageForPlatform(
await ApplicationPackageFactory.instance!.getPackageForPlatform(
TargetPlatform.android_arm,
buildInfo: null,
applicationBinary: globals.fs.file('app.apk'),
);
expect(fakeProcessManager, hasNoRemainingExpectations);
......@@ -116,19 +112,16 @@ void main() {
final AndroidSdkVersion sdkVersion = FakeAndroidSdkVersion();
sdk.latestVersion = sdkVersion;
await ApplicationPackageFactory.instance.getPackageForPlatform(
await ApplicationPackageFactory.instance!.getPackageForPlatform(
TargetPlatform.android_arm,
buildInfo: null,
);
expect(fakeProcessManager, hasNoRemainingExpectations);
}, overrides: overrides);
testWithoutContext('returns null when failed to extract manifest', () async {
final AndroidSdkVersion sdkVersion = FakeAndroidSdkVersion();
sdk.latestVersion = sdkVersion;
final Logger logger = BufferLogger.test();
final AndroidApk androidApk = AndroidApk.fromApk(
null,
final AndroidApk? androidApk = AndroidApk.fromApk(
fs.file(''),
processManager: fakeProcessManager,
logger: logger,
userMessages: UserMessages(),
......@@ -146,7 +139,7 @@ void main() {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
_aaptDataWithExplicitEnabledAndMainLauncherActivity,
BufferLogger.test(),
);
)!;
expect(data, isNotNull);
expect(data.packageName, 'io.flutter.examples.hello_world');
......@@ -157,7 +150,7 @@ void main() {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
_aaptDataWithDefaultEnabledAndMainLauncherActivity,
BufferLogger.test(),
);
)!;
expect(data, isNotNull);
expect(data.packageName, 'io.flutter.examples.hello_world');
......@@ -168,7 +161,7 @@ void main() {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
_aaptDataWithDistNamespace,
BufferLogger.test(),
);
)!;
expect(data, isNotNull);
expect(data.packageName, 'io.flutter.examples.hello_world');
......@@ -177,7 +170,7 @@ void main() {
testWithoutContext('Error when parsing manifest with no Activity that has enabled set to true nor has no value for its enabled field', () {
final BufferLogger logger = BufferLogger.test();
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
final ApkManifestData? data = ApkManifestData.parseFromXmlDump(
_aaptDataWithNoEnabledActivity,
logger,
);
......@@ -191,7 +184,7 @@ void main() {
testWithoutContext('Error when parsing manifest with no Activity that has action set to android.intent.action.MAIN', () {
final BufferLogger logger = BufferLogger.test();
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
final ApkManifestData? data = ApkManifestData.parseFromXmlDump(
_aaptDataWithNoMainActivity,
logger,
);
......@@ -205,7 +198,7 @@ void main() {
testWithoutContext('Error when parsing manifest with no Activity that has category set to android.intent.category.LAUNCHER', () {
final BufferLogger logger = BufferLogger.test();
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
final ApkManifestData? data = ApkManifestData.parseFromXmlDump(
_aaptDataWithNoLauncherActivity,
logger,
);
......@@ -221,7 +214,7 @@ void main() {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
_aaptDataWithLauncherAndDefaultActivity,
BufferLogger.test(),
);
)!;
expect(data, isNotNull);
expect(data.packageName, 'io.flutter.examples.hello_world');
......@@ -229,7 +222,7 @@ void main() {
});
testWithoutContext('Parses manifest with missing application tag', () async {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(
final ApkManifestData? data = ApkManifestData.parseFromXmlDump(
_aaptDataWithoutApplication,
BufferLogger.test(),
);
......@@ -239,8 +232,8 @@ void main() {
});
group('PrebuiltIOSApp', () {
FakeOperatingSystemUtils os;
FakePlistParser testPlistParser;
late FakeOperatingSystemUtils os;
late FakePlistParser testPlistParser;
final Map<Type, Generator> overrides = <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
......@@ -255,8 +248,8 @@ void main() {
});
testUsingContext('Error on non-existing file', () {
final PrebuiltIOSApp iosApp =
IOSApp.fromPrebuiltApp(globals.fs.file('not_existing.ipa')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp =
IOSApp.fromPrebuiltApp(globals.fs.file('not_existing.ipa')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(
testLogger.errorText,
......@@ -266,8 +259,8 @@ void main() {
testUsingContext('Error on non-app-bundle folder', () {
globals.fs.directory('regular_folder').createSync();
final PrebuiltIOSApp iosApp =
IOSApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp =
IOSApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(
testLogger.errorText, 'Folder "regular_folder" is not an app bundle.\n');
......@@ -275,7 +268,7 @@ void main() {
testUsingContext('Error on no info.plist', () {
globals.fs.directory('bundle.app').createSync();
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(
testLogger.errorText,
......@@ -286,7 +279,7 @@ void main() {
testUsingContext('Error on bad info.plist', () {
globals.fs.directory('bundle.app').createSync();
globals.fs.file('bundle.app/Info.plist').createSync();
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(
testLogger.errorText,
......@@ -299,7 +292,7 @@ void main() {
globals.fs.directory('bundle.app').createSync();
globals.fs.file('bundle.app/Info.plist').createSync();
testPlistParser.setProperty('CFBundleIdentifier', 'fooBundleId');
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
final PrebuiltIOSApp iosApp = (IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp?)!;
expect(testLogger.errorText, isEmpty);
expect(iosApp.uncompressedBundle.path, 'bundle.app');
expect(iosApp.id, 'fooBundleId');
......@@ -309,7 +302,7 @@ void main() {
testUsingContext('Bad ipa zip-file, no payload dir', () {
globals.fs.file('app.ipa').createSync();
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(
testLogger.errorText,
......@@ -330,7 +323,7 @@ void main() {
globals.fs.directory(bundlePath1).createSync(recursive: true);
globals.fs.directory(bundlePath2).createSync(recursive: true);
};
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
final PrebuiltIOSApp? iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp?;
expect(iosApp, isNull);
expect(testLogger.errorText,
'Invalid prebuilt iOS ipa. Does not contain a single app bundle.\n');
......@@ -350,7 +343,7 @@ void main() {
.file(globals.fs.path.join(bundleAppDir.path, 'Info.plist'))
.createSync();
};
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
final PrebuiltIOSApp iosApp = (IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp?)!;
expect(testLogger.errorText, isEmpty);
expect(iosApp.uncompressedBundle.path, endsWith('bundle.app'));
expect(iosApp.id, 'fooBundleId');
......@@ -361,8 +354,8 @@ void main() {
testUsingContext('returns null when there is no ios or .ios directory', () async {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp;
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
expect(iosApp, null);
}, overrides: overrides);
......@@ -371,8 +364,8 @@ void main() {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
globals.fs.file('ios/FooBar.xcodeproj').createSync(recursive: true);
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp;
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
expect(iosApp, null);
}, overrides: overrides);
......@@ -381,8 +374,8 @@ void main() {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
globals.fs.file('ios/Runner.xcodeproj').createSync(recursive: true);
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp;
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
expect(iosApp, null);
}, overrides: overrides);
......@@ -392,8 +385,8 @@ void main() {
globals.fs.file('.packages').createSync();
final Directory project = globals.fs.directory('ios/Runner.xcodeproj')..createSync(recursive: true);
project.childFile('project.pbxproj').createSync();
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp;
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
expect(iosApp, null);
}, overrides: overrides);
......@@ -407,8 +400,8 @@ void main() {
};
testUsingContext('Error on non-existing file', () {
final PrebuiltFuchsiaApp fuchsiaApp =
FuchsiaApp.fromPrebuiltApp(globals.fs.file('not_existing.far')) as PrebuiltFuchsiaApp;
final PrebuiltFuchsiaApp? fuchsiaApp =
FuchsiaApp.fromPrebuiltApp(globals.fs.file('not_existing.far')) as PrebuiltFuchsiaApp?;
expect(fuchsiaApp, isNull);
expect(
testLogger.errorText,
......@@ -418,8 +411,8 @@ void main() {
testUsingContext('Error on non-far file', () {
globals.fs.directory('regular_folder').createSync();
final PrebuiltFuchsiaApp fuchsiaApp =
FuchsiaApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltFuchsiaApp;
final PrebuiltFuchsiaApp? fuchsiaApp =
FuchsiaApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltFuchsiaApp?;
expect(fuchsiaApp, isNull);
expect(
testLogger.errorText,
......@@ -429,7 +422,7 @@ void main() {
testUsingContext('Success with far file', () {
globals.fs.file('bundle.far').createSync();
final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp;
final PrebuiltFuchsiaApp fuchsiaApp = (FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp?)!;
expect(testLogger.errorText, isEmpty);
expect(fuchsiaApp.id, 'bundle.far');
expect(fuchsiaApp.applicationPackage.path, globals.fs.file('bundle.far').path);
......@@ -438,7 +431,7 @@ void main() {
testUsingContext('returns null when there is no fuchsia', () async {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final BuildableFuchsiaApp fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(globals.fs.currentDirectory).fuchsia) as BuildableFuchsiaApp;
final BuildableFuchsiaApp? fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(globals.fs.currentDirectory).fuchsia) as BuildableFuchsiaApp?;
expect(fuchsiaApp, null);
}, overrides: overrides);
......@@ -707,7 +700,7 @@ N: android=http://schemas.android.com/apk/res/android
''';
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
void Function(File, Directory) onUnzip;
void Function(File, Directory)? onUnzip;
@override
void unzip(File file, Directory targetDirectory) {
......@@ -717,16 +710,16 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
class FakeAndroidSdk extends Fake implements AndroidSdk {
@override
bool platformToolsAvailable;
late bool platformToolsAvailable;
@override
bool licensesAvailable;
late bool licensesAvailable;
@override
AndroidSdkVersion latestVersion;
AndroidSdkVersion? latestVersion;
}
class FakeAndroidSdkVersion extends Fake implements AndroidSdkVersion {
@override
String aaptPath;
late String aaptPath;
}
......@@ -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/args.dart';
import 'package:args/command_runner.dart';
import 'package:flutter_tools/executable.dart' as executable;
......@@ -111,7 +109,7 @@ void main() {
});
}
void verifyCommandRunner(CommandRunner<Object> runner) {
void verifyCommandRunner(CommandRunner<Object?> runner) {
expect(runner.argParser, isNotNull, reason: '${runner.runtimeType} has no argParser');
expect(runner.argParser.allowsAnything, isFalse, reason: '${runner.runtimeType} allows anything');
expect(runner.argParser.allowTrailingOptions, isFalse, reason: '${runner.runtimeType} allows trailing options');
......@@ -119,7 +117,7 @@ void verifyCommandRunner(CommandRunner<Object> runner) {
runner.commands.values.forEach(verifyCommand);
}
void verifyCommand(Command<Object> runner) {
void verifyCommand(Command<Object?> runner) {
expect(runner.argParser, isNotNull, reason: 'command ${runner.name} has no argParser');
verifyOptions(runner.name, runner.argParser.options.values);
......@@ -161,7 +159,7 @@ const String _needHelp = "Every option must have help explaining what it does, e
const String _header = ' Comment: ';
void verifyOptions(String command, Iterable<Option> options) {
void verifyOptions(String? command, Iterable<Option> options) {
String target;
if (command == null) {
target = 'the global argument "';
......@@ -191,10 +189,11 @@ void verifyOptions(String command, Iterable<Option> options) {
if (option.defaultsTo != null) {
expect(option.help, isNot(contains('Default')), reason: '${_header}Help for $target--${option.name}" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).');
if (option.allowedHelp != null) {
for (final String allowedValue in option.allowedHelp.keys) {
final Map<String, String>? allowedHelp = option.allowedHelp;
if (allowedHelp != null) {
for (final String allowedValue in allowedHelp.keys) {
expect(
option.allowedHelp[allowedValue],
allowedHelp[allowedValue],
isNot(anyOf(contains('default'), contains('Default'))),
reason: '${_header}Help for $target--${option.name} $allowedValue" mentions the default value but that is redundant with the defaultsTo option which is also specified (and preferred).',
);
......@@ -202,7 +201,7 @@ void verifyOptions(String command, Iterable<Option> options) {
}
}
expect(option.help, isNot(matches(_bannedArgumentReferencePatterns)), reason: '${_header}Help for $target--${option.name}" contains the string "--" in an unexpected way. If it\'s trying to mention another argument, it should be quoted, as in "--foo".');
for (final String line in option.help.split('\n')) {
for (final String line in option.help!.split('\n')) {
if (!line.startsWith(' ')) {
expect(line, isNot(contains(' ')), reason: '${_header}Help for $target--${option.name}" has excessive whitespace (check e.g. for double spaces after periods or round line breaks in the source).');
expect(line, matches(_allowedTrailingPatterns), reason: '${_header}A line in the help for $target--${option.name}" does not end with the expected period that a full sentence should end with. (If the help ends with a URL, place it after a colon, don\'t leave a trailing period; if it\'s sample code, prefix the line with four spaces.)');
......
......@@ -2,7 +2,7 @@
// 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';
......@@ -45,10 +45,10 @@ const FakeCommand kListEmulatorsCommand = FakeCommand(
);
void main() {
FakeProcessManager fakeProcessManager;
FakeAndroidSdk sdk;
FileSystem fileSystem;
Xcode xcode;
late FakeProcessManager fakeProcessManager;
late FakeAndroidSdk sdk;
late FileSystem fileSystem;
late Xcode xcode;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -110,7 +110,16 @@ void main() {
});
testWithoutContext('getEmulatorsById', () async {
final TestEmulatorManager testEmulatorManager = TestEmulatorManager(emulators);
final TestEmulatorManager testEmulatorManager = TestEmulatorManager(emulators,
logger: BufferLogger.test(),
processManager: fakeProcessManager,
androidWorkflow: AndroidWorkflow(
androidSdk: sdk,
featureFlags: TestFeatureFlags(),
operatingSystemUtils: FakeOperatingSystemUtils(),
),
fileSystem: fileSystem,
);
expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5'), <Emulator>[emulator1]);
expect(await testEmulatorManager.getEmulatorsMatching('Nexus_5X'), <Emulator>[emulator2]);
......@@ -340,7 +349,12 @@ void main() {
}
class TestEmulatorManager extends EmulatorManager {
TestEmulatorManager(this.allEmulators);
TestEmulatorManager(this.allEmulators, {
required super.logger,
required super.processManager,
required super.androidWorkflow,
required super.fileSystem,
});
final List<Emulator> allEmulators;
......@@ -374,16 +388,16 @@ class FakeEmulator extends Emulator {
class FakeAndroidSdk extends Fake implements AndroidSdk {
@override
String avdManagerPath;
String? avdManagerPath;
@override
String emulatorPath;
String? emulatorPath;
@override
String adbPath;
String? adbPath;
@override
String getAvdManagerPath() => avdManagerPath;
String? getAvdManagerPath() => avdManagerPath;
@override
String getAvdPath() => 'avd';
......
......@@ -2,7 +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:file/memory.dart';
import 'package:flutter_tools/src/application_package.dart';
......@@ -21,7 +21,6 @@ import 'package:flutter_tools/src/resident_devtools_handler.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
......@@ -116,8 +115,8 @@ void main() {
group('hotRestart', () {
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
FileSystem fileSystem;
TestUsage testUsage;
late FileSystem fileSystem;
late TestUsage testUsage;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -125,7 +124,7 @@ void main() {
});
group('fails to setup', () {
TestHotRunnerConfig failingTestingConfig;
late TestHotRunnerConfig failingTestingConfig;
setUp(() {
failingTestingConfig = TestHotRunnerConfig(
successfulHotRestartSetup: false,
......@@ -174,13 +173,13 @@ void main() {
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
reassembleHelper: (
List<FlutterDevice> flutterDevices,
Map<FlutterDevice, List<FlutterView>> viewCache,
void Function(String message) onSlow,
List<FlutterDevice?> flutterDevices,
Map<FlutterDevice?, List<FlutterView>> viewCache,
void Function(String message)? onSlow,
String reloadMessage,
String fastReassembleClassName,
String? fastReassembleClassName,
) async => ReassembleResult(
<FlutterView, FlutterVmService>{null: null},
<FlutterView?, FlutterVmService?>{null: null},
false,
true,
),
......@@ -198,7 +197,7 @@ void main() {
});
group('shutdown hook tests', () {
TestHotRunnerConfig shutdownTestingConfig;
late TestHotRunnerConfig shutdownTestingConfig;
setUp(() {
shutdownTestingConfig = TestHotRunnerConfig();
......@@ -250,7 +249,7 @@ void main() {
});
group('successful hot restart', () {
TestHotRunnerConfig testingConfig;
late TestHotRunnerConfig testingConfig;
setUp(() {
testingConfig = TestHotRunnerConfig(
successfulHotRestartSetup: true,
......@@ -279,7 +278,7 @@ void main() {
},
);
(fakeFlutterDevice.devFS as FakeDevFs).baseUri = Uri.parse('file:///base_uri');
(fakeFlutterDevice.devFS! as FakeDevFs).baseUri = Uri.parse('file:///base_uri');
final OperationResult result = await HotRunner(
devices,
......@@ -318,7 +317,7 @@ void main() {
});
group('successful hot reload', () {
TestHotRunnerConfig testingConfig;
late TestHotRunnerConfig testingConfig;
setUp(() {
testingConfig = TestHotRunnerConfig(
successfulHotReloadSetup: true,
......@@ -349,7 +348,7 @@ void main() {
},
);
(fakeFlutterDevice.devFS as FakeDevFs).baseUri = Uri.parse('file:///base_uri');
(fakeFlutterDevice.devFS! as FakeDevFs).baseUri = Uri.parse('file:///base_uri');
final OperationResult result = await HotRunner(
devices,
......@@ -359,13 +358,13 @@ void main() {
stopwatchFactory: fakeStopwatchFactory,
reloadSourcesHelper: (
HotRunner hotRunner,
List<FlutterDevice> flutterDevices,
bool pause,
List<FlutterDevice?> flutterDevices,
bool? pause,
Map<String, dynamic> firstReloadDetails,
String targetPlatform,
String sdkName,
bool emulator,
String reason,
String? targetPlatform,
String? sdkName,
bool? emulator,
String? reason,
) async {
firstReloadDetails['finalLibraryCount'] = 2;
firstReloadDetails['receivedLibraryCount'] = 3;
......@@ -374,13 +373,13 @@ void main() {
return OperationResult.ok;
},
reassembleHelper: (
List<FlutterDevice> flutterDevices,
Map<FlutterDevice, List<FlutterView>> viewCache,
void Function(String message) onSlow,
List<FlutterDevice?> flutterDevices,
Map<FlutterDevice?, List<FlutterView>> viewCache,
void Function(String message)? onSlow,
String reloadMessage,
String fastReassembleClassName,
String? fastReassembleClassName,
) async => ReassembleResult(
<FlutterView, FlutterVmService>{null: null},
<FlutterView?, FlutterVmService?>{null: null},
false,
true,
),
......@@ -421,7 +420,7 @@ void main() {
});
group('hot restart that failed to sync dev fs', () {
TestHotRunnerConfig testingConfig;
late TestHotRunnerConfig testingConfig;
setUp(() {
testingConfig = TestHotRunnerConfig(
successfulHotRestartSetup: true,
......@@ -455,7 +454,7 @@ void main() {
});
group('hot reload that failed to sync dev fs', () {
TestHotRunnerConfig testingConfig;
late TestHotRunnerConfig testingConfig;
setUp(() {
testingConfig = TestHotRunnerConfig(
successfulHotReloadSetup: true,
......@@ -490,7 +489,7 @@ void main() {
});
group('hot attach', () {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -561,10 +560,10 @@ class FakeDevFs extends Fake implements DevFS {
List<Uri> sources = <Uri>[];
@override
DateTime lastCompiled;
DateTime? lastCompiled;
@override
PackageConfig lastPackageConfig;
PackageConfig? lastPackageConfig;
@override
Set<String> assetPathsToEvict = <String>{};
......@@ -573,7 +572,7 @@ class FakeDevFs extends Fake implements DevFS {
Set<String> shaderPathsToEvict= <String>{};
@override
Uri baseUri;
Uri? baseUri;
}
// Unfortunately Device, despite not being immutable, has an `operator ==`.
......@@ -608,8 +607,8 @@ class FakeDevice extends Fake implements Device {
@override
Future<bool> stopApp(
covariant ApplicationPackage app, {
String userIdentifier,
covariant ApplicationPackage? app, {
String? userIdentifier,
}) async {
return true;
}
......@@ -624,7 +623,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
FakeFlutterDevice(this.device);
bool stoppedEchoingDeviceLog = false;
Future<UpdateFSReport> Function() updateDevFSReportCallback;
late Future<UpdateFSReport> Function() updateDevFSReportCallback;
@override
final FakeDevice device;
......@@ -635,36 +634,36 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
}
@override
DevFS devFS = FakeDevFs();
DevFS? devFS = FakeDevFs();
@override
FlutterVmService get vmService => FakeFlutterVmService();
@override
ResidentCompiler generator;
ResidentCompiler? generator;
@override
Future<UpdateFSReport> updateDevFS({
Uri mainUri,
String target,
AssetBundle bundle,
DateTime firstBuildTime,
Uri? mainUri,
String? target,
AssetBundle? bundle,
DateTime? firstBuildTime,
bool bundleFirstUpload = false,
bool bundleDirty = false,
bool fullRestart = false,
String projectRootPath,
String pathToReload,
@required String dillOutputPath,
@required List<Uri> invalidatedFiles,
@required PackageConfig packageConfig,
String? projectRootPath,
String? pathToReload,
required String dillOutputPath,
required List<Uri> invalidatedFiles,
required PackageConfig packageConfig,
}) => updateDevFSReportCallback();
}
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, developmentShaderCompiler: const FakeShaderCompiler());
......@@ -673,17 +672,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 disableServiceAuthCodes = false,
bool enableDds = true,
bool cacheStartupProfile = false,
bool ipv6 = false,
int hostVmServicePort,
int ddsPort,
bool? ipv6 = false,
int? hostVmServicePort,
int? ddsPort,
bool allowExistingDdsInstance = false,
}) async {
throw exception;
......@@ -692,19 +691,19 @@ class TestFlutterDevice extends FlutterDevice {
class TestHotRunnerConfig extends HotRunnerConfig {
TestHotRunnerConfig({this.successfulHotRestartSetup, this.successfulHotReloadSetup});
bool successfulHotRestartSetup;
bool successfulHotReloadSetup;
bool? successfulHotRestartSetup;
bool? successfulHotReloadSetup;
bool shutdownHookCalled = false;
bool updateDevFSCompleteCalled = false;
@override
Future<bool> setupHotRestart() async {
Future<bool?> setupHotRestart() async {
assert(successfulHotRestartSetup != null, 'setupHotRestart is not expected to be called in this test.');
return successfulHotRestartSetup;
}
@override
Future<bool> setupHotReload() async {
Future<bool?> setupHotReload() async {
assert(successfulHotReloadSetup != null, 'setupHotReload is not expected to be called in this test.');
return successfulHotReloadSetup;
}
......@@ -749,7 +748,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform platform, { @required bool enableImpeller }) { }
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -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';
......@@ -28,9 +26,9 @@ import '../src/context.dart';
import '../src/test_build_system.dart';
void main() {
FakeFlutterDevice mockFlutterDevice;
FakeWebDevFS mockWebDevFS;
FileSystem fileSystem;
late FakeFlutterDevice mockFlutterDevice;
late FakeWebDevFS mockWebDevFS;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -191,22 +189,22 @@ class FakeWebDevice extends Fake implements Device {
@override
Future<bool> stopApp(
covariant ApplicationPackage app, {
String userIdentifier,
covariant ApplicationPackage? app, {
String? userIdentifier,
}) async {
return true;
}
@override
Future<LaunchResult> startApp(
covariant ApplicationPackage package, {
String mainPath,
String route,
DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs,
covariant ApplicationPackage? package, {
String? mainPath,
String? route,
DebuggingOptions? debuggingOptions,
Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false,
bool ipv6 = false,
String userIdentifier,
String? userIdentifier,
}) async {
return LaunchResult.succeeded();
}
......@@ -219,14 +217,14 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
final FakeWebDevice device;
DevFS _devFS;
DevFS? _devFS;
@override
DevFS get devFS => _devFS;
DevFS? get devFS => _devFS;
@override
set devFS(DevFS value) { }
set devFS(DevFS? value) { }
@override
FlutterVmService vmService;
FlutterVmService? vmService;
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:convert';
import 'dart:io';
......@@ -32,7 +30,6 @@ import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/web/web_device.dart';
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart';
import 'package:package_config/package_config_types.dart';
import 'package:test/fake.dart';
......@@ -90,20 +87,20 @@ const List<VmServiceExpectation> kAttachExpectations = <VmServiceExpectation>[
];
void main() {
FakeDebugConnection debugConnection;
FakeChromeDevice chromeDevice;
FakeAppConnection appConnection;
FakeFlutterDevice flutterDevice;
FakeWebDevFS webDevFS;
FakeResidentCompiler residentCompiler;
FakeChromeConnection chromeConnection;
FakeChromeTab chromeTab;
FakeWebServerDevice webServerDevice;
FakeDevice mockDevice;
FakeVmServiceHost fakeVmServiceHost;
FileSystem fileSystem;
ProcessManager processManager;
TestUsage testUsage;
late FakeDebugConnection debugConnection;
late FakeChromeDevice chromeDevice;
late FakeAppConnection appConnection;
late FakeFlutterDevice flutterDevice;
late FakeWebDevFS webDevFS;
late FakeResidentCompiler residentCompiler;
late FakeChromeConnection chromeConnection;
late FakeChromeTab chromeTab;
late FakeWebServerDevice webServerDevice;
late FakeDevice mockDevice;
late FakeVmServiceHost fakeVmServiceHost;
late FileSystem fileSystem;
late ProcessManager processManager;
late TestUsage testUsage;
setUp(() {
testUsage = TestUsage();
......@@ -114,6 +111,7 @@ void main() {
appConnection = FakeAppConnection();
webDevFS = FakeWebDevFS();
residentCompiler = FakeResidentCompiler();
chromeDevice = FakeChromeDevice();
chromeConnection = FakeChromeConnection();
chromeTab = FakeChromeTab('index.html');
webServerDevice = FakeWebServerDevice();
......@@ -161,7 +159,7 @@ void main() {
expect(profileResidentWebRunner.debuggingEnabled, false);
flutterDevice.device = FakeChromeDevice();
flutterDevice.device = chromeDevice;
expect(residentWebRunner.debuggingEnabled, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false);
......@@ -897,7 +895,7 @@ void main() {
setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter =
Completer<DebugConnectionInfo>();
final Future<int> result = residentWebRunner.run(
final Future<int?> result = residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
);
await connectionInfoCompleter.future;
......@@ -1192,7 +1190,9 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
setupMocks();
webDevFS.exception = ChromeDebugException(<String, dynamic>{});
webDevFS.exception = ChromeDebugException(<String, Object?>{
'text': 'error',
});
await expectLater(residentWebRunner.run, throwsToolExit());
expect(fakeVmServiceHost.hasRemainingExpectations, false);
......@@ -1232,9 +1232,9 @@ flutter:
ResidentRunner setUpResidentRunner(
FlutterDevice flutterDevice, {
Logger logger,
SystemClock systemClock,
DebuggingOptions debuggingOptions,
Logger? logger,
SystemClock? systemClock,
DebuggingOptions? debuggingOptions,
}) {
return ResidentWebRunner(
flutterDevice,
......@@ -1261,7 +1261,7 @@ class FakeWebServerDevice extends FakeDevice implements WebServerDevice {}
// ignore: avoid_implementing_value_types
class FakeDevice extends Fake implements Device {
@override
String name;
String name = 'FakeDevice';
int count = 0;
......@@ -1269,26 +1269,26 @@ class FakeDevice extends Fake implements Device {
Future<String> get sdkNameAndVersion async => 'SDK Name and Version';
@override
DartDevelopmentService dds;
late DartDevelopmentService dds;
@override
Future<LaunchResult> startApp(
covariant ApplicationPackage package, {
String mainPath,
String route,
DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs,
covariant ApplicationPackage? package, {
String? mainPath,
String? route,
DebuggingOptions? debuggingOptions,
Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false,
bool ipv6 = false,
String userIdentifier,
String? userIdentifier,
}) async {
return LaunchResult.succeeded();
}
@override
Future<bool> stopApp(
covariant ApplicationPackage app, {
String userIdentifier,
covariant ApplicationPackage? app, {
String? userIdentifier,
}) async {
if (count > 0) {
throw StateError('stopApp called more than once.');
......@@ -1299,14 +1299,14 @@ class FakeDevice extends Fake implements Device {
}
class FakeDebugConnection extends Fake implements DebugConnection {
FakeVmServiceHost Function() fakeVmServiceHost;
late FakeVmServiceHost Function() fakeVmServiceHost;
@override
vm_service.VmService get vmService =>
fakeVmServiceHost.call().vmService.service;
@override
String uri;
late String uri;
final Completer<void> completer = Completer<void>();
bool didClose = false;
......@@ -1340,14 +1340,14 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
@override
Future<CompilerOutput> recompile(
Uri mainUri,
List<Uri> invalidatedFiles, {
@required String outputPath,
@required PackageConfig packageConfig,
@required String projectRootPath,
@required FileSystem fs,
List<Uri>? invalidatedFiles, {
required String outputPath,
required PackageConfig packageConfig,
required FileSystem fs,
String? projectRootPath,
bool suppressErrors = false,
bool checkDartPluginRegistry = false,
File dartPluginRegistrant,
File? dartPluginRegistrant,
}) async {
return const CompilerOutput('foo.dill', 0, <Uri>[]);
}
......@@ -1368,11 +1368,11 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
}
class FakeWebDevFS extends Fake implements WebDevFS {
Object exception;
ConnectionResult result;
UpdateFSReport report;
Object? exception;
ConnectionResult? result;
late UpdateFSReport report;
Uri mainUri;
Uri? mainUri;
@override
List<Uri> sources = <Uri>[];
......@@ -1381,10 +1381,10 @@ class FakeWebDevFS extends Fake implements WebDevFS {
Uri baseUri = Uri.parse('http://localhost:12345');
@override
DateTime lastCompiled = DateTime.now();
DateTime? lastCompiled = DateTime.now();
@override
PackageConfig lastPackageConfig = PackageConfig.empty;
PackageConfig? lastPackageConfig = PackageConfig.empty;
@override
Future<Uri> create() async {
......@@ -1393,33 +1393,33 @@ class FakeWebDevFS extends Fake implements WebDevFS {
@override
Future<UpdateFSReport> update({
@required Uri mainUri,
@required ResidentCompiler generator,
@required bool trackWidgetCreation,
@required String pathToReload,
@required List<Uri> invalidatedFiles,
@required PackageConfig packageConfig,
@required String dillOutputPath,
@required DevelopmentShaderCompiler shaderCompiler,
DevFSWriter devFSWriter,
String target,
AssetBundle bundle,
DateTime firstBuildTime,
required Uri mainUri,
required ResidentCompiler generator,
required bool trackWidgetCreation,
required String pathToReload,
required List<Uri> invalidatedFiles,
required PackageConfig packageConfig,
required String dillOutputPath,
required DevelopmentShaderCompiler shaderCompiler,
DevFSWriter? devFSWriter,
String? target,
AssetBundle? bundle,
DateTime? firstBuildTime,
bool bundleFirstUpload = false,
bool fullRestart = false,
String projectRootPath,
File dartPluginRegistrant,
String? projectRootPath,
File? dartPluginRegistrant,
}) async {
this.mainUri = mainUri;
return report;
}
@override
Future<ConnectionResult> connect(bool useDebugExtension, {VmServiceFactory vmServiceFactory = createVmServiceDelegate}) async {
Future<ConnectionResult?> connect(bool useDebugExtension, {VmServiceFactory vmServiceFactory = createVmServiceDelegate}) async {
if (exception != null) {
assert(exception is Exception || exception is Error);
// ignore: only_throw_errors, exception is either Error or Exception here.
throw exception;
throw exception!;
}
return result;
}
......@@ -1430,12 +1430,12 @@ class FakeChromeConnection extends Fake implements ChromeConnection {
@override
Future<ChromeTab> getTab(bool Function(ChromeTab tab) accept,
{Duration retryFor}) async {
{Duration? retryFor}) async {
return tabs.firstWhere(accept);
}
@override
Future<List<ChromeTab>> getTabs({Duration retryFor}) async {
Future<List<ChromeTab>> getTabs({Duration? retryFor}) async {
return tabs;
}
}
......@@ -1448,7 +1448,7 @@ class FakeChromeTab extends Fake implements ChromeTab {
final FakeWipConnection connection = FakeWipConnection();
@override
Future<WipConnection> connect({Function/*?*/ onError}) async {
Future<WipConnection> connect({Function? onError}) async {
return connection;
}
}
......@@ -1491,9 +1491,9 @@ class TestChromiumLauncher implements ChromiumLauncher {
Future<Chromium> launch(
String url, {
bool headless = false,
int debugPort,
int? debugPort,
bool skipCheck = false,
Directory cacheDir,
Directory? cacheDir,
List<String> webBrowserFlags = const <String>[],
}) async {
return currentCompleter.future;
......@@ -1506,35 +1506,35 @@ class TestChromiumLauncher implements ChromiumLauncher {
}
class FakeFlutterDevice extends Fake implements FlutterDevice {
Uri testUri;
Uri? testUri;
UpdateFSReport report = UpdateFSReport(
success: true,
invalidatedSourcesCount: 1,
);
Exception reportError;
Exception? reportError;
@override
ResidentCompiler generator;
ResidentCompiler? generator;
@override
Stream<Uri> get observatoryUris => Stream<Uri>.value(testUri);
Stream<Uri?> get observatoryUris => Stream<Uri?>.value(testUri);
@override
DevelopmentShaderCompiler get developmentShaderCompiler => const FakeShaderCompiler();
@override
FlutterVmService vmService;
FlutterVmService? vmService;
DevFS _devFS;
DevFS? _devFS;
@override
DevFS get devFS => _devFS;
DevFS? get devFS => _devFS;
@override
set devFS(DevFS value) {}
set devFS(DevFS? value) {}
@override
Device device;
Device? device;
@override
Future<void> stopEchoingDeviceLog() async {}
......@@ -1543,7 +1543,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
Future<void> initLogReader() async {}
@override
Future<Uri> setupDevFS(String fsName, Directory rootDirectory) async {
Future<Uri?> setupDevFS(String fsName, Directory rootDirectory) async {
return testUri;
}
......@@ -1553,38 +1553,38 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
@override
Future<void> connect({
ReloadSources reloadSources,
Restart restart,
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
int hostVmServicePort,
int ddsPort,
ReloadSources? reloadSources,
Restart? restart,
CompileExpression? compileExpression,
GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
int? hostVmServicePort,
int? ddsPort,
bool disableServiceAuthCodes = false,
bool enableDds = true,
bool cacheStartupProfile = false,
@required bool allowExistingDdsInstance,
bool ipv6 = false,
required bool allowExistingDdsInstance,
bool? ipv6 = false,
}) async {}
@override
Future<UpdateFSReport> updateDevFS({
Uri mainUri,
String target,
AssetBundle bundle,
DateTime firstBuildTime,
Uri? mainUri,
String? target,
AssetBundle? bundle,
DateTime? firstBuildTime,
bool bundleFirstUpload = false,
bool bundleDirty = false,
bool fullRestart = false,
String projectRootPath,
String pathToReload,
String dillOutputPath,
List<Uri> invalidatedFiles,
PackageConfig packageConfig,
File dartPluginRegistrant,
String? projectRootPath,
String? pathToReload,
String? dillOutputPath,
List<Uri>? invalidatedFiles,
PackageConfig? packageConfig,
File? dartPluginRegistrant,
}) async {
if (reportError != null) {
throw reportError;
throw reportError!;
}
return report;
}
......@@ -1597,7 +1597,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform platform, { @required bool enableImpeller }) { }
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -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:fake_async/fake_async.dart';
......@@ -62,7 +60,7 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest(
void main() {
testWithoutContext('VmService registers reloadSources', () async {
Future<void> reloadSources(String isolateId, { bool pause, bool force}) async {}
Future<void> reloadSources(String isolateId, { bool? pause, bool? force}) async {}
final MockVMService mockVMService = MockVMService();
await setUpVmService(
......@@ -217,7 +215,7 @@ void main() {
windows: false,
));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[
containsPair('method', kSetAssetBundlePathMethod),
......@@ -245,7 +243,7 @@ void main() {
windows: true,
));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[
containsPair('method', kSetAssetBundlePathMethod),
......@@ -269,7 +267,7 @@ void main() {
viewId: 'abc',
));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[
containsPair('method', kGetSkSLsMethod),
......@@ -291,7 +289,7 @@ void main() {
uiIsolateId: 'def',
));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
final Map<String, Object?>? rawRequest = json.decode(await completer.future) as Map<String, Object?>?;
expect(rawRequest, allOf(<Matcher>[
containsPair('method', kFlushUIThreadTasksMethod),
......@@ -469,7 +467,7 @@ void main() {
]
);
final Map<String, Object> skSLs = await fakeVmServiceHost.vmService.getSkSLs(
final Map<String, Object?>? skSLs = await fakeVmServiceHost.vmService.getSkSLs(
viewId: '1234',
);
expect(skSLs, isNull);
......@@ -477,19 +475,19 @@ void main() {
final List<FlutterView> views = await fakeVmServiceHost.vmService.getFlutterViews();
expect(views, isEmpty);
final vm_service.Response screenshot = await fakeVmServiceHost.vmService.screenshot();
final vm_service.Response? screenshot = await fakeVmServiceHost.vmService.screenshot();
expect(screenshot, isNull);
final vm_service.Response screenshotSkp = await fakeVmServiceHost.vmService.screenshotSkp();
final vm_service.Response? screenshotSkp = await fakeVmServiceHost.vmService.screenshotSkp();
expect(screenshotSkp, isNull);
// Checking that this doesn't throw.
await fakeVmServiceHost.vmService.setTimelineFlags(<String>['test']);
final vm_service.Response timeline = await fakeVmServiceHost.vmService.getTimeline();
final vm_service.Response? timeline = await fakeVmServiceHost.vmService.getTimeline();
expect(timeline, isNull);
final Map<String, Object> rasterStats =
final Map<String, Object?>? rasterStats =
await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: '1', uiIsolateId: '12');
expect(rasterStats, isNull);
......@@ -505,7 +503,7 @@ void main() {
]
);
final vm_service.Isolate isolate = await fakeVmServiceHost.vmService.getIsolateOrNull(
final vm_service.Isolate? isolate = await fakeVmServiceHost.vmService.getIsolateOrNull(
'isolate/123',
);
expect(isolate, null);
......@@ -535,7 +533,7 @@ void main() {
]
);
final Map<String, Object> rasterStats =
final Map<String, Object?>? rasterStats =
await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: 'view/1', uiIsolateId: 'isolate/123');
expect(rasterStats, equals(response));
......@@ -629,7 +627,7 @@ void main() {
isolate.toJson()
..['id'] = '2'
..['extensionRPCs'] = <String>[otherExtensionName],
);
)!;
final FlutterView fakeFlutterView2 = FlutterView(
id: '2',
......@@ -680,7 +678,7 @@ void main() {
testWithoutContext('does not rethrow a sentinel exception if the initially queried flutter view disappears', () async {
const String otherExtensionName = 'ext.flutter.test.otherExtension';
final vm_service.Isolate isolate2 = vm_service.Isolate.parse(
final vm_service.Isolate? isolate2 = vm_service.Isolate.parse(
isolate.toJson()
..['id'] = '2'
..['extensionRPCs'] = <String>[otherExtensionName],
......@@ -836,7 +834,7 @@ void main() {
testUsingContext('WebSocket URL construction uses correct URI join primitives', () async {
final Completer<String> completer = Completer<String>();
openChannelForTesting = (String url, {io.CompressionOptions compression, Logger logger}) async {
openChannelForTesting = (String url, {io.CompressionOptions compression = io.CompressionOptions.compressionDefault, required Logger logger}) async {
completer.complete(url);
throw Exception('');
};
......@@ -883,8 +881,8 @@ class FakeDevice extends Fake implements Device { }
/// A [WebSocketConnector] that always throws an [io.SocketException].
Future<io.WebSocket> failingWebSocketConnector(
String url, {
io.CompressionOptions compression,
Logger logger,
io.CompressionOptions? compression,
Logger? logger,
}) {
throw const io.SocketException('Failed WebSocket connection');
}
......@@ -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' hide Directory, File;
......@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/isolated/devfs_web.dart';
import 'package:flutter_tools/src/web/compile.dart';
import 'package:logging/logging.dart' as logging;
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart';
import 'package:shelf/shelf.dart';
import 'package:test/fake.dart';
......@@ -41,14 +38,14 @@ const List<int> kTransparentImage = <int>[
];
void main() {
Testbed testbed;
WebAssetServer webAssetServer;
ReleaseAssetServer releaseAssetServer;
Platform linux;
PackageConfig packages;
Platform windows;
FakeHttpServer httpServer;
BufferLogger logger;
late Testbed testbed;
late WebAssetServer webAssetServer;
late ReleaseAssetServer releaseAssetServer;
late Platform linux;
late PackageConfig packages;
late Platform windows;
late FakeHttpServer httpServer;
late BufferLogger logger;
setUpAll(() async {
packages = PackageConfig(<Package>[
......@@ -66,15 +63,15 @@ void main() {
httpServer,
packages,
InternetAddress.loopbackIPv4,
null,
null,
null,
<String, String>{},
<String, String>{},
NullSafetyMode.unsound,
);
releaseAssetServer = ReleaseAssetServer(
globals.fs.file('main.dart').uri,
fileSystem: null, // ignore: avoid_redundant_argument_values
fileSystem: globals.fs,
flutterRoot: null, // ignore: avoid_redundant_argument_values
platform: null, // ignore: avoid_redundant_argument_values
platform: FakePlatform(),
webBuildDirectory: null, // ignore: avoid_redundant_argument_values
basePath: null,
);
......@@ -183,10 +180,10 @@ void main() {
}));
webAssetServer.write(source, manifest, sourcemap, metadata);
final String merged = await webAssetServer.metadataContents('main_module.ddc_merged_metadata');
final String? merged = await webAssetServer.metadataContents('main_module.ddc_merged_metadata');
expect(merged, equals(metadataContents));
final String single = await webAssetServer.metadataContents('foo.js.metadata');
final String? single = await webAssetServer.metadataContents('foo.js.metadata');
expect(single, equals(metadataContents));
}, overrides: <Type, Generator>{
Platform: () => linux,
......@@ -292,9 +289,9 @@ void main() {
httpServer,
packages,
InternetAddress.loopbackIPv4,
null,
null,
null,
<String, String>{},
<String, String>{},
NullSafetyMode.unsound,
);
expect(webAssetServer.basePath, 'foo/bar');
......@@ -311,9 +308,9 @@ void main() {
httpServer,
packages,
InternetAddress.loopbackIPv4,
null,
null,
null,
<String, String>{},
<String, String>{},
NullSafetyMode.unsound,
);
// Defaults to "/" when there's no base element.
......@@ -332,9 +329,9 @@ void main() {
httpServer,
packages,
InternetAddress.loopbackIPv4,
null,
null,
null,
<String, String>{},
<String, String>{},
NullSafetyMode.unsound,
),
throwsToolExit(),
);
......@@ -352,9 +349,9 @@ void main() {
httpServer,
packages,
InternetAddress.loopbackIPv4,
null,
null,
null,
<String, String>{},
<String, String>{},
NullSafetyMode.unsound,
),
throwsToolExit(),
);
......@@ -380,7 +377,7 @@ void main() {
final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/foo.js')));
final String etag = response.headers[HttpHeaders.etagHeader];
final String etag = response.headers[HttpHeaders.etagHeader]!;
final Response cachedResponse = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/foo.js'), headers: <String, String>{
......@@ -622,14 +619,14 @@ void main() {
final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/fooπ')));
final String etag = response.headers[HttpHeaders.etagHeader];
final String etag = response.headers[HttpHeaders.etagHeader]!;
expect(etag.runes, everyElement(predicate((int char) => char < 255)));
}));
test('serves /packages/<package>/<path> files as if they were '
'package:<package>/<path> uris', () => testbed.run(() async {
final Uri expectedUri = packages.resolve(
final Uri? expectedUri = packages.resolve(
Uri.parse('package:flutter_tools/foo.dart'));
final File source = globals.fs.file(globals.fs.path.fromUri(expectedUri))
..createSync(recursive: true)
......@@ -691,13 +688,13 @@ void main() {
final Uri uri = await webDevFS.create();
webDevFS.webAssetServer.entrypointCacheDirectory = globals.fs.currentDirectory;
final String webPrecompiledSdk = globals.artifacts
final String webPrecompiledSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSdk).path;
final String webPrecompiledSdkSourcemaps = globals.artifacts
final String webPrecompiledSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSdkSourcemaps).path;
final String webPrecompiledCanvaskitSdk = globals.artifacts
final String webPrecompiledCanvaskitSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdk).path;
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdkSourcemaps).path;
globals.fs.currentDirectory
.childDirectory('lib')
......@@ -808,13 +805,13 @@ void main() {
.childFile('web_entrypoint.dart')
..createSync(recursive: true)
..writeAsStringSync('GENERATED');
final String webPrecompiledSdk = globals.artifacts
final String webPrecompiledSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSoundSdk).path;
final String webPrecompiledSdkSourcemaps = globals.artifacts
final String webPrecompiledSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledSoundSdkSourcemaps).path;
final String webPrecompiledCanvaskitSdk = globals.artifacts
final String webPrecompiledCanvaskitSdk = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdk).path;
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts!
.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdkSourcemaps).path;
globals.fs.file(webPrecompiledSdk)
..createSync(recursive: true)
......@@ -917,7 +914,7 @@ void main() {
webDevFS.webAssetServer.dwds = FakeDwds(<AppConnection>[firstConnection, secondConnection]);
int vmServiceFactoryInvocationCount = 0;
Future<vm_service.VmService> vmServiceFactory(Uri uri, {CompressionOptions compression, @required Logger logger}) {
Future<vm_service.VmService> vmServiceFactory(Uri uri, {CompressionOptions? compression, required Logger logger}) {
if (vmServiceFactoryInvocationCount > 0) {
fail('Called vmServiceFactory twice!');
}
......@@ -927,7 +924,7 @@ void main() {
() => FakeVmService(),
);
}
return webDevFS.connect(false, vmServiceFactory: vmServiceFactory).then<void>((ConnectionResult firstConnectionResult) {
return webDevFS.connect(false, vmServiceFactory: vmServiceFactory).then<void>((ConnectionResult? firstConnectionResult) {
return webDevFS.destroy();
});
});
......@@ -1078,7 +1075,7 @@ void main() {
false,
Uri.base,
null,
null,
NullSafetyMode.unsound,
testMode: true);
expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null);
......@@ -1179,20 +1176,20 @@ class FakeHttpServer extends Fake implements HttpServer {
}
class FakeResidentCompiler extends Fake implements ResidentCompiler {
CompilerOutput output;
CompilerOutput? output;
@override
void addFileSystemRoot(String root) { }
@override
Future<CompilerOutput> recompile(Uri mainUri, List<Uri> invalidatedFiles, {
String outputPath,
PackageConfig packageConfig,
String projectRootPath,
FileSystem fs,
Future<CompilerOutput?> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {
String? outputPath,
PackageConfig? packageConfig,
String? projectRootPath,
FileSystem? fs,
bool suppressErrors = false,
bool checkDartPluginRegistry = false,
File dartPluginRegistrant,
File? dartPluginRegistrant,
}) async {
return output;
}
......@@ -1202,7 +1199,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(TargetPlatform platform, { @required bool enableImpeller }) { }
void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
......@@ -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/file_system.dart';
......@@ -16,11 +14,11 @@ import '../../src/fakes.dart';
void main() {
group('Test that TestGoldenComparatorProcess', () {
File imageFile;
Uri goldenKey;
File imageFile2;
Uri goldenKey2;
FakeProcess Function(String) createFakeProcess;
late File imageFile;
late Uri goldenKey;
late File imageFile2;
late Uri goldenKey2;
late FakeProcess Function(String) createFakeProcess;
setUpAll(() {
imageFile = globals.fs.file('test_image_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/build_system/build_system.dart';
......@@ -22,13 +20,13 @@ void main() {
group('ScrubGeneratedPluginRegistrant', () {
// The files this migration deals with
File gitignore;
File registrant;
late File gitignore;
late File registrant;
// Environment overrides
FileSystem fileSystem;
ProcessManager processManager;
BuildSystem buildSystem;
late FileSystem fileSystem;
late ProcessManager processManager;
late BuildSystem buildSystem;
setUp(() {
// Prepare environment overrides
......
......@@ -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';
......@@ -28,7 +26,7 @@ final Platform platform = FakePlatform(
);
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:dwds/dwds.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -14,7 +12,7 @@ import 'package:test/fake.dart';
import '../../src/common.dart';
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -27,7 +25,7 @@ void main() {
final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, null);
'', '', 1, 1, <String, String>{}, <String, String>{}, '', '');
expectResult(result, false, 'a');
});
......@@ -39,7 +37,7 @@ void main() {
final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, null);
'', '', 1, 1, <String, String>{}, <String, String>{}, '', '');
expectResult(result, true, 'Error: a');
});
......@@ -50,7 +48,7 @@ void main() {
final ExpressionCompilationResult result =
await expressionCompiler.compileExpressionToJs(
null, null, 1, 1, null, null, null, 'a');
'', '', 1, 1, <String, String>{}, <String, String>{}, '', 'a');
expectResult(result, true, "InternalError: frontend server failed to compile 'a'");
});
......@@ -66,10 +64,10 @@ void expectResult(ExpressionCompilationResult result, bool isError, String value
class FakeResidentCompiler extends Fake implements ResidentCompiler {
FakeResidentCompiler(this.output);
final CompilerOutput output;
final CompilerOutput? output;
@override
Future<CompilerOutput> compileExpressionToJs(
Future<CompilerOutput?> compileExpressionToJs(
String libraryUri,
int line,
int column,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment