Unverified Commit 22cef489 authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Null safety migration of packages/flutter_tools/test/commands.shard/hermetic, part 2/3 (#110708)

* Migrate packages/flutter_tools/test/commands.shard/hermetic, part 2/3

* Fix tests

* Fix analysis

* Chris's comments
parent 9dbc09de
......@@ -598,39 +598,39 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
inputs = StreamQueue<String>(nonClosingKeystrokes.stream);
final String id = await (askForString(
final String id = (await askForString(
'id',
description:
'Please enter the id you want to device to have. Must contain only '
'alphanumeric or underscore characters.',
example: 'pi',
validator: (String s) async => RegExp(r'^\w+$').hasMatch(s),
) as FutureOr<String>);
))!;
final String label = await (askForString(
final String label = (await askForString(
'label',
description:
'Please enter the label of the device, which is a slightly more verbose '
'name for the device.',
example: 'Raspberry Pi',
) as FutureOr<String>);
))!;
final String sdkNameAndVersion = await (askForString(
final String sdkNameAndVersion = (await askForString(
'SDK name and version',
example: 'Raspberry Pi 4 Model B+',
) as FutureOr<String>);
))!;
final bool enabled = await askForBool(
'enabled',
description: 'Should the device be enabled?',
);
final String targetStr = await (askForString(
final String targetStr = (await askForString(
'target',
description: 'Please enter the hostname or IPv4/v6 address of the device.',
example: 'raspberrypi',
validator: (String s) async => _isValidHostname(s) || _isValidIpAddr(s)
) as FutureOr<String>);
))!;
final InternetAddress? targetIp = InternetAddress.tryParse(targetStr);
final bool useIp = targetIp != null;
......@@ -639,20 +639,20 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
? InternetAddress.loopbackIPv6
: InternetAddress.loopbackIPv4;
final String username = await (askForString(
final String username = (await askForString(
'username',
description: 'Please enter the username used for ssh-ing into the remote device.',
example: 'pi',
defaultsTo: 'no username',
) as FutureOr<String>);
))!;
final String remoteRunDebugCommand = await (askForString(
final String remoteRunDebugCommand = (await askForString(
'run command',
description:
'Please enter the command executed on the remote device for starting '
r'the app. "/tmp/${appName}" is the path to the asset bundle.',
example: r'flutter-pi /tmp/${appName}'
) as FutureOr<String>);
))!;
final bool usePortForwarding = await askForBool(
'use port forwarding',
......@@ -663,12 +663,12 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
'not using port forwarding.',
);
final String screenshotCommand = await (askForString(
final String screenshotCommand = (await askForString(
'screenshot command',
description: 'Enter the command executed on the remote device for taking a screenshot.',
example: r"fbgrab /tmp/screenshot.png && cat /tmp/screenshot.png | base64 | tr -d ' \n\t'",
defaultsTo: 'no screenshotting support',
) as FutureOr<String>);
))!;
// SSH expects IPv6 addresses to use the bracket syntax like URIs do too,
// but the IPv6 the user enters is a raw IPv6 address, so we need to wrap it.
......@@ -820,8 +820,8 @@ Delete a device from the config file.
Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled();
final String id = globalResults!['device-id'] as String;
if (!customDevicesConfig.contains(id)) {
final String? id = globalResults!['device-id'] as String?;
if (id == null || !customDevicesConfig.contains(id)) {
throwToolExit('Couldn\'t find device with id "$id" in config at "${customDevicesConfig.configPath}"');
}
......
......@@ -1590,7 +1590,7 @@ class DebounceOperationQueue<T, K> {
final Map<K, Future<T>> _operationQueue = <K, Future<T>>{};
Future<void>? _inProgressAction;
Future<T>? queueAndDebounce(
Future<T> queueAndDebounce(
K operationType,
Duration debounceDuration,
Future<T> Function() action,
......@@ -1599,7 +1599,7 @@ class DebounceOperationQueue<T, K> {
// debounce timer and return its future.
if (_operationQueue[operationType] != null) {
_debounceTimers[operationType]?.reset();
return _operationQueue[operationType];
return _operationQueue[operationType]!;
}
// Otherwise, put one in the queue with a timer.
......
......@@ -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/base/file_system.dart';
......@@ -23,7 +21,7 @@ import '../../src/test_build_system.dart';
import '../../src/test_flutter_command_runner.dart';
void main() {
FileSystem fileSystem;
late FileSystem fileSystem;
final Platform fakePlatform = FakePlatform(
environment: <String, String>{
'FLUTTER_ROOT': '/',
......@@ -243,7 +241,7 @@ class TestWebBuildCommand extends FlutterCommand {
final String description = 'Build a test executable app.';
@override
Future<FlutterCommandResult> runCommand() async => null;
Future<FlutterCommandResult> runCommand() async => FlutterCommandResult.fail();
@override
bool get shouldRunPub => false;
......
......@@ -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';
......@@ -43,10 +41,9 @@ final Platform notWindowsPlatform = FakePlatform(
);
void main() {
FileSystem fileSystem;
ProcessManager processManager;
TestUsage usage;
late FileSystem fileSystem;
late ProcessManager processManager;
late TestUsage usage;
setUpAll(() {
Cache.disableLocking();
......@@ -75,7 +72,7 @@ void main() {
// Returns the command matching the build_windows call to generate CMake
// files.
FakeCommand cmakeGenerationCommand({
void Function() onRun,
void Function()? onRun,
String generator = _defaultGenerator,
}) {
return FakeCommand(
......@@ -95,7 +92,7 @@ void main() {
// Returns the command matching the build_windows call to build.
FakeCommand buildCommand(String buildMode, {
bool verbose = false,
void Function() onRun,
void Function()? onRun,
String stdout = '',
}) {
return FakeCommand(
......@@ -974,7 +971,7 @@ class FakeVisualStudio extends Fake implements VisualStudio {
});
@override
final String cmakePath;
final String? cmakePath;
@override
final String cmakeGenerator;
......
......@@ -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/cache.dart';
......@@ -28,13 +26,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,
......@@ -50,8 +48,8 @@ class FakePub extends Fake implements Pub {
void main() {
group('usageValues', () {
Testbed testbed;
FakePub fakePub;
late Testbed testbed;
late FakePub fakePub;
setUpAll(() {
Cache.disableLocking();
......
......@@ -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:typed_data';
......@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/commands/custom_devices.dart';
import 'package:flutter_tools/src/custom_devices/custom_device_config.dart';
import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:meta/meta.dart';
import '../../src/common.dart';
import '../../src/context.dart';
......@@ -171,7 +168,7 @@ final Platform windowsPlatform = FakePlatform(
);
class FakeTerminal implements Terminal {
factory FakeTerminal({Platform platform}) {
factory FakeTerminal({required Platform platform}) {
return FakeTerminal._private(
stdio: FakeStdio(),
platform: platform
......@@ -179,8 +176,8 @@ class FakeTerminal implements Terminal {
}
FakeTerminal._private({
this.stdio,
Platform platform
required this.stdio,
required Platform platform
}) :
terminal = AnsiTerminal(
stdio: stdio,
......@@ -215,9 +212,9 @@ class FakeTerminal implements Terminal {
@override
Future<String> promptForCharInput(
List<String> acceptedCharacters, {
Logger logger,
String prompt,
int defaultChoiceIndex,
required Logger logger,
String? prompt,
int? defaultChoiceIndex,
bool displayAcceptedCharacters = true
}) => terminal.promptForCharInput(
acceptedCharacters,
......@@ -253,10 +250,10 @@ class FakeTerminal implements Terminal {
class FakeCommandRunner extends FlutterCommandRunner {
FakeCommandRunner({
@required Platform platform,
@required FileSystem fileSystem,
@required Logger logger,
UserMessages userMessages
required Platform platform,
required FileSystem fileSystem,
required Logger logger,
UserMessages? userMessages
}) : _platform = platform,
_fileSystem = fileSystem,
_logger = logger,
......@@ -285,7 +282,7 @@ class FakeCommandRunner extends FlutterCommandRunner {
userMessages: _userMessages,
);
// For compatibility with tests that set this to a relative path.
Cache.flutterRoot = _fileSystem.path.normalize(_fileSystem.path.absolute(Cache.flutterRoot));
Cache.flutterRoot = _fileSystem.path.normalize(_fileSystem.path.absolute(Cache.flutterRoot!));
return super.runCommand(topLevelResults);
}
);
......@@ -295,13 +292,13 @@ class FakeCommandRunner extends FlutterCommandRunner {
/// May take platform, logger, processManager and fileSystem from context if
/// not explicitly specified.
CustomDevicesCommand createCustomDevicesCommand({
CustomDevicesConfig Function(FileSystem, Logger) config,
Terminal Function(Platform) terminal,
Platform platform,
FileSystem fileSystem,
ProcessManager processManager,
Logger logger,
PrintFn usagePrintFn,
CustomDevicesConfig Function(FileSystem, Logger)? config,
Terminal Function(Platform)? terminal,
Platform? platform,
FileSystem? fileSystem,
ProcessManager? processManager,
Logger? logger,
PrintFn? usagePrintFn,
bool featureEnabled = false
}) {
platform ??= FakePlatform();
......@@ -340,13 +337,13 @@ CustomDevicesCommand createCustomDevicesCommand({
/// May take platform, logger, processManager and fileSystem from context if
/// not explicitly specified.
CommandRunner<void> createCustomDevicesCommandRunner({
CustomDevicesConfig Function(FileSystem, Logger) config,
Terminal Function(Platform) terminal,
Platform platform,
FileSystem fileSystem,
ProcessManager processManager,
Logger logger,
PrintFn usagePrintFn,
CustomDevicesConfig Function(FileSystem, Logger)? config,
Terminal Function(Platform)? terminal,
Platform? platform,
FileSystem? fileSystem,
ProcessManager? processManager,
Logger? logger,
PrintFn? usagePrintFn,
bool featureEnabled = false,
}) {
platform ??= FakePlatform();
......@@ -372,17 +369,17 @@ CommandRunner<void> createCustomDevicesCommandRunner({
}
FakeTerminal createFakeTerminalForAddingSshDevice({
@required Platform platform,
@required String id,
@required String label,
@required String sdkNameAndVersion,
@required String enabled,
@required String hostname,
@required String username,
@required String runDebug,
@required String usePortForwarding,
@required String screenshot,
@required String apply
required Platform platform,
required String id,
required String label,
required String sdkNameAndVersion,
required String enabled,
required String hostname,
required String username,
required String runDebug,
required String usePortForwarding,
required String screenshot,
required String apply
}) {
return FakeTerminal(platform: platform)
..simulateStdin(id)
......
......@@ -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' as io;
import 'dart:typed_data';
......@@ -57,7 +55,7 @@ class FakeDaemonStreams implements DaemonStreams {
}
@override
void send(Map<String, dynamic> message, [ List<int> binary ]) {
void send(Map<String, Object?> message, [ List<int>? binary ]) {
outputs.add(DaemonMessage(message, binary != null ? Stream<List<int>>.value(binary) : null));
}
......@@ -70,12 +68,12 @@ class FakeDaemonStreams implements DaemonStreams {
}
void main() {
Daemon daemon;
NotifyingLogger notifyingLogger;
late Daemon daemon;
late NotifyingLogger notifyingLogger;
group('daemon', () {
FakeDaemonStreams daemonStreams;
DaemonConnection daemonConnection;
late FakeDaemonStreams daemonStreams;
late DaemonConnection daemonConnection;
setUp(() {
BufferLogger bufferLogger;
bufferLogger = BufferLogger.test();
......@@ -100,7 +98,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'daemon.version'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'daemon.version'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['result'], isNotEmpty);
......@@ -115,7 +113,7 @@ void main() {
// Use the flutter_gallery project which has a known set of supported platforms.
final String projectPath = globals.fs.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'flutter_gallery');
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 0,
'method': 'daemon.getSupportedPlatforms',
'params': <String, Object>{'projectRoot': projectPath},
......@@ -124,7 +122,7 @@ void main() {
expect(response.data['id'], 0);
expect(response.data['result'], isNotEmpty);
expect((response.data['result'] as Map<String, dynamic>)['platforms'], <String>{'macos'});
expect((response.data['result']! as Map<String, Object?>)['platforms'], <String>{'macos'});
}, overrides: <Type, Generator>{
// Disable Android/iOS and enable macOS to make sure result is consistent and defaults are tested off.
FeatureFlags: () => TestFeatureFlags(isAndroidEnabled: false, isIOSEnabled: false, isMacOSEnabled: true),
......@@ -137,11 +135,11 @@ void main() {
);
globals.printError('daemon.logMessage test');
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere((DaemonMessage message) {
return message.data['event'] == 'daemon.logMessage' && (message.data['params'] as Map<String, dynamic>)['level'] == 'error';
return message.data['event'] == 'daemon.logMessage' && (message.data['params']! as Map<String, Object?>)['level'] == 'error';
});
expect(response.data['id'], isNull);
expect(response.data['event'], 'daemon.logMessage');
final Map<String, String> logMessage = castStringKeyedMap(response.data['params']).cast<String, String>();
final Map<String, String> logMessage = castStringKeyedMap(response.data['params'])!.cast<String, String>();
expect(logMessage['level'], 'error');
expect(logMessage['message'], 'daemon.logMessage test');
}, overrides: <Type, Generator>{
......@@ -155,11 +153,11 @@ void main() {
);
globals.printWarning('daemon.logMessage test');
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere((DaemonMessage message) {
return message.data['event'] == 'daemon.logMessage' && (message.data['params'] as Map<String, dynamic>)['level'] == 'warning';
return message.data['event'] == 'daemon.logMessage' && (message.data['params']! as Map<String, Object?>)['level'] == 'warning';
});
expect(response.data['id'], isNull);
expect(response.data['event'], 'daemon.logMessage');
final Map<String, String> logMessage = castStringKeyedMap(response.data['params']).cast<String, String>();
final Map<String, String> logMessage = castStringKeyedMap(response.data['params'])!.cast<String, String>();
expect(logMessage['level'], 'warning');
expect(logMessage['message'], 'daemon.logMessage test');
}, overrides: <Type, Generator>{
......@@ -203,7 +201,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'daemon.shutdown'}));
return daemon.onExit.then<void>((int code) async {
await daemonStreams.inputs.close();
expect(code, 0);
......@@ -216,7 +214,7 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'app.restart'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'app.restart'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['error'], contains('appId is required'));
......@@ -228,7 +226,7 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 0,
'method': 'app.callServiceExtension',
'params': <String, String>{
......@@ -246,7 +244,7 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'app.stop'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'app.stop'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['error'], contains('appId is required'));
......@@ -257,7 +255,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'device.getDevices'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'device.getDevices'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['result'], isList);
......@@ -271,10 +269,10 @@ void main() {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
daemon.deviceDomain.addDeviceDiscoverer(discoverer);
discoverer.addDevice(FakeAndroidDevice());
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'device.getDevices'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'device.getDevices'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
final dynamic result = response.data['result'];
final Object? result = response.data['result'];
expect(result, isList);
expect(result, isNotEmpty);
});
......@@ -293,7 +291,7 @@ void main() {
expect(response.data['event'], 'device.added');
expect(response.data['params'], isMap);
final Map<String, dynamic> params = castStringKeyedMap(response.data['params']);
final Map<String, Object?> params = castStringKeyedMap(response.data['params'])!;
expect(params['platform'], isNotEmpty); // the fake device has a platform of 'android-arm'
});
}, overrides: <Type, Generator>{
......@@ -307,7 +305,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'device.discoverDevices'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'device.discoverDevices'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['result'], isList);
......@@ -321,10 +319,10 @@ void main() {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
daemon.deviceDomain.addDeviceDiscoverer(discoverer);
discoverer.addDevice(FakeAndroidDevice());
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'device.discoverDevices'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'device.discoverDevices'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
final dynamic result = response.data['result'];
final Object? result = response.data['result'];
expect(result, isList);
expect(result, isNotEmpty);
expect(discoverer.discoverDevicesCalled, true);
......@@ -339,17 +337,17 @@ void main() {
daemon.deviceDomain.addDeviceDiscoverer(discoverer);
final FakeAndroidDevice device = FakeAndroidDevice();
discoverer.addDevice(device);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 0,
'method': 'device.supportsRuntimeMode',
'params': <String, dynamic>{
'params': <String, Object?>{
'deviceId': 'device',
'buildMode': 'profile',
},
}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
final dynamic result = response.data['result'];
final Object? result = response.data['result'];
expect(result, true);
expect(device.supportsRuntimeModeCalledBuildMode, BuildMode.profile);
});
......@@ -365,17 +363,17 @@ void main() {
discoverer.addDevice(device);
final FakeDeviceLogReader logReader = FakeDeviceLogReader();
device.logReader = logReader;
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 0,
'method': 'device.logReader.start',
'params': <String, dynamic>{
'params': <String, Object?>{
'deviceId': 'device',
},
}));
final Stream<DaemonMessage> broadcastOutput = daemonStreams.outputs.stream.asBroadcastStream();
final DaemonMessage firstResponse = await broadcastOutput.firstWhere(_notEvent);
expect(firstResponse.data['id'], 0);
final String logReaderId = firstResponse.data['result'] as String;
final String? logReaderId = firstResponse.data['result'] as String?;
expect(logReaderId, isNotNull);
// Try sending logs.
......@@ -387,10 +385,10 @@ void main() {
// Now try to stop the log reader.
expect(logReader.disposeCalled, false);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 1,
'method': 'device.logReader.stop',
'params': <String, dynamic>{
'params': <String, Object?>{
'id': logReaderId,
},
}));
......@@ -400,7 +398,7 @@ void main() {
});
group('device.startApp and .stopApp', () {
FakeApplicationPackageFactory applicationPackageFactory;
late FakeApplicationPackageFactory applicationPackageFactory;
setUp(() {
applicationPackageFactory = FakeApplicationPackageFactory();
});
......@@ -419,27 +417,27 @@ void main() {
// First upload the application package.
final FakeApplicationPackage applicationPackage = FakeApplicationPackage();
applicationPackageFactory.applicationPackage = applicationPackage;
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 0,
'method': 'device.uploadApplicationPackage',
'params': <String, dynamic>{
'params': <String, Object?>{
'targetPlatform': 'android',
'applicationBinary': 'test_file',
},
}));
final DaemonMessage applicationPackageIdResponse = await broadcastOutput.firstWhere(_notEvent);
expect(applicationPackageIdResponse.data['id'], 0);
expect(applicationPackageFactory.applicationBinaryRequested.basename, 'test_file');
expect(applicationPackageFactory.applicationBinaryRequested!.basename, 'test_file');
expect(applicationPackageFactory.platformRequested, TargetPlatform.android);
final String applicationPackageId = applicationPackageIdResponse.data['result'] as String;
final String? applicationPackageId = applicationPackageIdResponse.data['result'] as String?;
// Try starting the app.
final Uri observatoryUri = Uri.parse('http://127.0.0.1:12345/observatory');
device.launchResult = LaunchResult.succeeded(observatoryUri: observatoryUri);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 1,
'method': 'device.startApp',
'params': <String, dynamic>{
'params': <String, Object?>{
'deviceId': 'device',
'applicationPackageId': applicationPackageId,
'debuggingOptions': DebuggingOptions.enabled(BuildInfo.debug).toJson(),
......@@ -448,15 +446,15 @@ void main() {
final DaemonMessage startAppResponse = await broadcastOutput.firstWhere(_notEvent);
expect(startAppResponse.data['id'], 1);
expect(device.startAppPackage, applicationPackage);
final Map<String, dynamic> startAppResult = startAppResponse.data['result'] as Map<String, dynamic>;
final Map<String, Object?> startAppResult = startAppResponse.data['result']! as Map<String, Object?>;
expect(startAppResult['started'], true);
expect(startAppResult['observatoryUri'], observatoryUri.toString());
// Try stopping the app.
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
'id': 2,
'method': 'device.stopApp',
'params': <String, dynamic>{
'params': <String, Object?>{
'deviceId': 'device',
'applicationPackageId': applicationPackageId,
},
......@@ -464,7 +462,7 @@ void main() {
final DaemonMessage stopAppResponse = await broadcastOutput.firstWhere(_notEvent);
expect(stopAppResponse.data['id'], 2);
expect(device.stopAppPackage, applicationPackage);
final bool stopAppResult = stopAppResponse.data['result'] as bool;
final bool? stopAppResult = stopAppResponse.data['result'] as bool?;
expect(stopAppResult, true);
}, overrides: <Type, Generator>{
ApplicationPackageFactory: () => applicationPackageFactory,
......@@ -477,7 +475,7 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'emulator.launch'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'emulator.launch'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['error'], contains('emulatorId is required'));
......@@ -488,8 +486,8 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
final Map<String, dynamic> params = <String, dynamic>{'emulatorId': 'device', 'coldBoot': 1};
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'emulator.launch', 'params': params}));
final Map<String, Object?> params = <String, Object?>{'emulatorId': 'device', 'coldBoot': 1};
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'emulator.launch', 'params': params}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['error'], contains('coldBoot is not a bool'));
......@@ -500,7 +498,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'emulator.getEmulators'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'emulator.getEmulators'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
expect(response.data['id'], 0);
expect(response.data['result'], isList);
......@@ -519,8 +517,8 @@ void main() {
unawaited(daemonStreams.outputs.stream
.firstWhere((DaemonMessage request) => request.data['method'] == 'app.exposeUrl')
.then((DaemonMessage request) {
expect((request.data['params'] as Map<String, dynamic>)['url'], equals(originalUrl));
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': request.data['id'], 'result': <String, dynamic>{'url': mappedUrl}}));
expect((request.data['params']! as Map<String, Object?>)['url'], equals(originalUrl));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': request.data['id'], 'result': <String, Object?>{'url': mappedUrl}}));
})
);
......@@ -534,9 +532,9 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'devtools.serve'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'devtools.serve'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere((DaemonMessage response) => response.data['id'] == 0);
final Map<String, dynamic> result = response.data['result'] as Map<String, dynamic>;
final Map<String, Object?> result = response.data['result']! as Map<String, Object?>;
expect(result, isNotEmpty);
expect(result['host'], '127.0.0.1');
expect(result['port'], 1234);
......@@ -550,9 +548,9 @@ void main() {
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'devtools.serve'}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'devtools.serve'}));
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere((DaemonMessage response) => response.data['id'] == 0);
final Map<String, dynamic> result = response.data['result'] as Map<String, dynamic>;
final Map<String, Object?> result = response.data['result']! as Map<String, Object?>;
expect(result, isNotEmpty);
expect(result['host'], null);
expect(result['port'], null);
......@@ -565,8 +563,8 @@ void main() {
await io.IOOverrides.runWithIOOverrides(() async {
final FakeSocket socket = FakeSocket();
bool connectCalled = false;
int connectPort;
ioOverrides.connectCallback = (dynamic host, int port) async {
int? connectPort;
ioOverrides.connectCallback = (Object? host, int port) async {
connectCalled = true;
connectPort = port;
if (host == io.InternetAddress.loopbackIPv4) {
......@@ -579,7 +577,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'proxy.connect', 'params': <String, dynamic>{'port': 123}}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'proxy.connect', 'params': <String, Object?>{'port': 123}}));
final Stream<DaemonMessage> broadcastOutput = daemonStreams.outputs.stream.asBroadcastStream();
final DaemonMessage firstResponse = await broadcastOutput.firstWhere(_notEvent);
......@@ -588,7 +586,7 @@ void main() {
expect(connectCalled, true);
expect(connectPort, 123);
final Object id = firstResponse.data['result'];
final Object? id = firstResponse.data['result'];
// Can send received data as event.
socket.controller.add(Uint8List.fromList(<int>[10, 11, 12]));
......@@ -596,22 +594,22 @@ void main() {
(DaemonMessage message) => message.data['event'] != null && message.data['event'] == 'proxy.data.$id',
);
expect(dataEvent.binary, isNotNull);
final List<List<int>> data = await dataEvent.binary.toList();
final List<List<int>> data = await dataEvent.binary!.toList();
expect(data[0], <int>[10, 11, 12]);
// Can proxy data to the socket.
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'proxy.write', 'params': <String, dynamic>{'id': id}}, Stream<List<int>>.value(<int>[21, 22, 23])));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'proxy.write', 'params': <String, Object?>{'id': id}}, Stream<List<int>>.value(<int>[21, 22, 23])));
await pumpEventQueue();
expect(socket.addedData[0], <int>[21, 22, 23]);
// Closes the connection when disconnect request received.
expect(socket.closeCalled, false);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'proxy.disconnect', 'params': <String, dynamic>{'id': id}}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'proxy.disconnect', 'params': <String, Object?>{'id': id}}));
await pumpEventQueue();
expect(socket.closeCalled, true);
// Sends disconnected event when socket.done completer finishes.
socket.doneCompleter.complete();
socket.doneCompleter.complete(true);
final DaemonMessage disconnectEvent = await broadcastOutput.firstWhere(
(DaemonMessage message) => message.data['event'] != null && message.data['event'] == 'proxy.disconnected.$id',
);
......@@ -624,8 +622,8 @@ void main() {
await io.IOOverrides.runWithIOOverrides(() async {
final FakeSocket socket = FakeSocket();
bool connectIpv4Called = false;
int connectPort;
ioOverrides.connectCallback = (dynamic host, int port) async {
int? connectPort;
ioOverrides.connectCallback = (Object? host, int port) async {
connectPort = port;
if (host == io.InternetAddress.loopbackIPv4) {
connectIpv4Called = true;
......@@ -639,7 +637,7 @@ void main() {
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'proxy.connect', 'params': <String, dynamic>{'port': 123}}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'proxy.connect', 'params': <String, Object?>{'port': 123}}));
final Stream<DaemonMessage> broadcastOutput = daemonStreams.outputs.stream.asBroadcastStream();
final DaemonMessage firstResponse = await broadcastOutput.firstWhere(_notEvent);
......@@ -653,13 +651,13 @@ void main() {
testUsingContext('proxy.connect fails if both ipv6 and ipv4 failed', () async {
final TestIOOverrides ioOverrides = TestIOOverrides();
await io.IOOverrides.runWithIOOverrides(() async {
ioOverrides.connectCallback = (dynamic host, int port) => throw const io.SocketException('fail');
ioOverrides.connectCallback = (Object? host, int port) => throw const io.SocketException('fail');
daemon = Daemon(
daemonConnection,
notifyingLogger: notifyingLogger,
);
daemonStreams.inputs.add(DaemonMessage(<String, dynamic>{'id': 0, 'method': 'proxy.connect', 'params': <String, dynamic>{'port': 123}}));
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{'id': 0, 'method': 'proxy.connect', 'params': <String, Object?>{'port': 123}}));
final Stream<DaemonMessage> broadcastOutput = daemonStreams.outputs.stream.asBroadcastStream();
final DaemonMessage firstResponse = await broadcastOutput.firstWhere(_notEvent);
......@@ -671,7 +669,7 @@ void main() {
});
group('notifyingLogger', () {
BufferLogger bufferLogger;
late BufferLogger bufferLogger;
setUp(() {
bufferLogger = BufferLogger.test();
});
......@@ -713,7 +711,7 @@ void main() {
});
group('daemon queue', () {
DebounceOperationQueue<int, String> queue;
late DebounceOperationQueue<int, String> queue;
const Duration debounceDuration = Duration(seconds: 1);
setUp(() {
......@@ -741,7 +739,7 @@ void main() {
await _runFakeAsync((FakeAsync time) async {
final List<Future<int>> operations = <Future<int>>[
queue.queueAndDebounce('OP1', debounceDuration, () async => 1),
Future<int>.delayed(debounceDuration * 2).then((_) =>
Future<void>.delayed(debounceDuration * 2).then((_) =>
queue.queueAndDebounce('OP1', debounceDuration, () async => 2)),
];
......@@ -873,42 +871,42 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
@override
bool get supportsStartPaused => true;
BuildMode supportsRuntimeModeCalledBuildMode;
BuildMode? supportsRuntimeModeCalledBuildMode;
@override
Future<bool> supportsRuntimeMode(BuildMode buildMode) async {
supportsRuntimeModeCalledBuildMode = buildMode;
return true;
}
DeviceLogReader logReader;
late DeviceLogReader logReader;
@override
FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage app,
covariant ApplicationPackage? app,
bool includePastLogs = false,
}) => logReader;
ApplicationPackage startAppPackage;
LaunchResult launchResult;
ApplicationPackage? startAppPackage;
late LaunchResult launchResult;
@override
Future<LaunchResult> startApp(
ApplicationPackage package, {
String mainPath,
String route,
DebuggingOptions debuggingOptions,
Map<String, Object> platformArgs = const <String, Object>{},
String? mainPath,
String? route,
DebuggingOptions? debuggingOptions,
Map<String, Object?> platformArgs = const <String, Object>{},
bool prebuiltApplication = false,
bool ipv6 = false,
String userIdentifier,
String? userIdentifier,
}) async {
startAppPackage = package;
return launchResult;
}
ApplicationPackage stopAppPackage;
ApplicationPackage? stopAppPackage;
@override
Future<bool> stopApp(
ApplicationPackage app, {
String userIdentifier,
String? userIdentifier,
}) async {
stopAppPackage = app;
return true;
......@@ -920,10 +918,10 @@ class FakeDeviceLogReader implements DeviceLogReader {
bool disposeCalled = false;
@override
int appPid;
int? appPid;
@override
FlutterVmService connectedVMService;
FlutterVmService? connectedVMService;
@override
void dispose() {
......@@ -941,22 +939,22 @@ class FakeDeviceLogReader implements DeviceLogReader {
class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
FakeDevtoolsLauncher(this._serverAddress);
final DevToolsServerAddress _serverAddress;
final DevToolsServerAddress? _serverAddress;
@override
Future<DevToolsServerAddress> serve() async => _serverAddress;
Future<DevToolsServerAddress?> serve() async => _serverAddress;
@override
Future<void> close() async {}
}
class FakeApplicationPackageFactory implements ApplicationPackageFactory {
TargetPlatform platformRequested;
File applicationBinaryRequested;
ApplicationPackage applicationPackage;
TargetPlatform? platformRequested;
File? applicationBinaryRequested;
ApplicationPackage? applicationPackage;
@override
Future<ApplicationPackage> getPackageForPlatform(TargetPlatform platform, {BuildInfo buildInfo, File applicationBinary}) async {
Future<ApplicationPackage?> getPackageForPlatform(TargetPlatform platform, {BuildInfo? buildInfo, File? applicationBinary}) async {
platformRequested = platform;
applicationBinaryRequested = applicationBinary;
return applicationPackage;
......@@ -966,11 +964,11 @@ class FakeApplicationPackageFactory implements ApplicationPackageFactory {
class FakeApplicationPackage extends Fake implements ApplicationPackage {}
class TestIOOverrides extends io.IOOverrides {
Future<io.Socket> Function(dynamic host, int port) connectCallback;
late Future<io.Socket> Function(Object? host, int port) connectCallback;
@override
Future<io.Socket> socketConnect(dynamic host, int port,
{dynamic sourceAddress, int sourcePort = 0, Duration timeout}) {
Future<io.Socket> socketConnect(Object? host, int port,
{Object? sourceAddress, int sourcePort = 0, Duration? timeout}) {
return connectCallback(host, port);
}
}
......@@ -983,10 +981,10 @@ class FakeSocket extends Fake implements io.Socket {
@override
StreamSubscription<Uint8List> listen(
void Function(Uint8List event) onData, {
Function onError,
void Function() onDone,
bool cancelOnError,
void Function(Uint8List event)? onData, {
Function? onError,
void Function()? onDone,
bool? cancelOnError,
}) {
return controller.stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
......
......@@ -2,12 +2,12 @@
// 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/android/android_sdk.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/devices.dart';
import 'package:flutter_tools/src/device.dart';
......@@ -24,7 +24,7 @@ void main() {
Cache.disableLocking();
});
Cache cache;
late Cache cache;
setUp(() {
cache = Cache.test(processManager: FakeProcessManager.any());
......@@ -52,7 +52,7 @@ void main() {
testUsingContext("get devices' platform types", () async {
final List<String> platformTypes = Device.devicesPlatformTypes(
await globals.deviceManager.getAllConnectedDevices(),
await globals.deviceManager!.getAllConnectedDevices(),
);
expect(platformTypes, <String>['android', 'web']);
}, overrides: <Type, Generator>{
......@@ -133,14 +133,14 @@ webby (mobile) • webby • web-javascript • Web SDK (1.2.4) (emulato
}
class _FakeDeviceManager extends DeviceManager {
_FakeDeviceManager();
_FakeDeviceManager() : super(logger: testLogger, terminal: Terminal.test(), userMessages: userMessages);
@override
Future<List<Device>> getAllConnectedDevices() =>
Future<List<Device>>.value(fakeDevices.map((FakeDeviceJsonData d) => d.dev).toList());
@override
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) =>
Future<List<Device>> refreshAllConnectedDevices({Duration? timeout}) =>
getAllConnectedDevices();
@override
......@@ -153,11 +153,13 @@ class _FakeDeviceManager extends DeviceManager {
}
class NoDevicesManager extends DeviceManager {
NoDevicesManager() : super(logger: testLogger, terminal: Terminal.test(), userMessages: userMessages);
@override
Future<List<Device>> getAllConnectedDevices() async => <Device>[];
@override
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) =>
Future<List<Device>> refreshAllConnectedDevices({Duration? timeout}) =>
getAllConnectedDevices();
@override
......
......@@ -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';
......@@ -20,11 +18,11 @@ import '../../src/fakes.dart';
import '../../src/test_flutter_command_runner.dart';
void main() {
FileSystem fileSystem;
BufferLogger bufferLogger;
FakeTerminal terminal;
ProcessManager processManager;
FakeStdio stdio;
late FileSystem fileSystem;
late BufferLogger bufferLogger;
late FakeTerminal terminal;
late ProcessManager processManager;
late FakeStdio stdio;
setUpAll(() {
Cache.disableLocking();
......@@ -224,11 +222,11 @@ class FakeTerminal extends Fake implements Terminal {
_selected = selected;
}
List<String> _characters;
String _selected;
List<String>? _characters;
late String _selected;
@override
Future<String> promptForCharInput(List<String> acceptedCharacters, {Logger logger, String prompt, int defaultChoiceIndex, bool displayAcceptedCharacters = true}) async {
Future<String> promptForCharInput(List<String> acceptedCharacters, {Logger? logger, String? prompt, int? defaultChoiceIndex, bool displayAcceptedCharacters = true}) async {
expect(acceptedCharacters, _characters);
return _selected;
}
......
......@@ -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/application_package.dart';
import 'package:flutter_tools/src/base/common.dart';
......@@ -25,10 +23,10 @@ import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart';
void main() {
FileSystem fileSystem;
BufferLogger logger;
Platform platform;
FakeDeviceManager fakeDeviceManager;
late FileSystem fileSystem;
late BufferLogger logger;
late Platform platform;
late FakeDeviceManager fakeDeviceManager;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -254,15 +252,15 @@ void main() {
class ThrowingScreenshotDevice extends ScreenshotDevice {
@override
Future<LaunchResult> startApp(
ApplicationPackage package, {
String mainPath,
String route,
DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs,
ApplicationPackage? package, {
String? mainPath,
String? route,
DebuggingOptions? debuggingOptions,
Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false,
bool usesTerminalUi = true,
bool ipv6 = false,
String userIdentifier,
String? userIdentifier,
}) async {
throwToolExit('cannot start app');
}
......@@ -289,15 +287,15 @@ class ScreenshotDevice extends Fake implements Device {
@override
Future<LaunchResult> startApp(
ApplicationPackage package, {
String mainPath,
String route,
DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs,
ApplicationPackage? package, {
String? mainPath,
String? route,
DebuggingOptions? debuggingOptions,
Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false,
bool usesTerminalUi = true,
bool ipv6 = false,
String userIdentifier,
String? userIdentifier,
}) async => LaunchResult.succeeded();
@override
......@@ -307,13 +305,13 @@ class ScreenshotDevice extends Fake implements Device {
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,
......@@ -324,13 +322,13 @@ class FakeDeviceManager extends Fake implements DeviceManager {
List<Device> devices = <Device>[];
@override
String specifiedDeviceId;
String? specifiedDeviceId;
@override
Future<List<Device>> getDevices() async => devices;
@override
Future<List<Device>> findTargetDevices(FlutterProject flutterProject, {Duration timeout}) async => devices;
Future<List<Device>> findTargetDevices(FlutterProject? flutterProject, {Duration? timeout}) async => devices;
}
class FailingFakeFlutterDriverFactory extends Fake implements FlutterDriverFactory {
......@@ -348,13 +346,13 @@ class FailingFakeDriverService extends Fake implements DriverService {
List<String> arguments,
Map<String, String> environment,
PackageConfig packageConfig, {
bool headless,
String chromeBinary,
String browserName,
bool androidEmulator,
int driverPort,
List<String> webBrowserFlags,
List<String> browserDimension,
String profileMemory,
bool? headless,
String? chromeBinary,
String? browserName,
bool? androidEmulator,
int? driverPort,
List<String>? webBrowserFlags,
List<String>? browserDimension,
String? profileMemory,
}) async => 1;
}
......@@ -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';
......@@ -18,10 +16,10 @@ import '../../src/fake_process_manager.dart';
import '../../src/test_flutter_command_runner.dart';
void main() {
FileSystem fileSystem;
BufferLogger logger;
Artifacts artifacts;
FakeProcessManager processManager;
late FileSystem fileSystem;
late BufferLogger logger;
late Artifacts artifacts;
late FakeProcessManager processManager;
setUpAll(() {
Cache.disableLocking();
......
......@@ -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/cache.dart';
......@@ -17,12 +15,12 @@ import '../../src/test_flutter_command_runner.dart';
void main() {
group('ide_config', () {
Directory tempDir;
Directory templateDir;
Directory intellijDir;
Directory toolsDir;
late Directory tempDir;
late Directory templateDir;
late Directory intellijDir;
late Directory toolsDir;
Map<String, String> getFilesystemContents([ Directory root ]) {
Map<String, String> getFilesystemContents([ Directory? root ]) {
final String tempPath = tempDir.absolute.path;
final List<String> paths =
(root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) {
......@@ -67,7 +65,7 @@ void main() {
if (manifest[key] != 'dir') {
tempDir.childFile(key)
..createSync(recursive: true)
..writeAsStringSync(manifest[key]);
..writeAsStringSync(manifest[key]!);
}
}
}
......@@ -78,7 +76,7 @@ void main() {
}
Future<void> updateIdeConfig({
Directory dir,
Directory? dir,
List<String> args = const <String>[],
Map<String, String> expectedContents = const <String, String>{},
List<String> unexpectedPaths = const <String>[],
......
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