Unverified Commit 59a6ba7c authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate desktop_device to null safety (#91705)

parent 00658736
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:pool/pool.dart'; import 'package:pool/pool.dart';
...@@ -29,15 +27,15 @@ class BundleBuilder { ...@@ -29,15 +27,15 @@ class BundleBuilder {
/// The default `mainPath` is `lib/main.dart`. /// The default `mainPath` is `lib/main.dart`.
/// The default `manifestPath` is `pubspec.yaml` /// The default `manifestPath` is `pubspec.yaml`
Future<void> build({ Future<void> build({
@required TargetPlatform platform, required TargetPlatform platform,
@required BuildInfo buildInfo, required BuildInfo buildInfo,
FlutterProject project, FlutterProject? project,
String mainPath, String? mainPath,
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String applicationKernelFilePath, String? applicationKernelFilePath,
String depfilePath, String? depfilePath,
String assetDirPath, String? assetDirPath,
@visibleForTesting BuildSystem buildSystem @visibleForTesting BuildSystem? buildSystem,
}) async { }) async {
project ??= FlutterProject.current(); project ??= FlutterProject.current();
mainPath ??= defaultMainPath; mainPath ??= defaultMainPath;
...@@ -52,7 +50,7 @@ class BundleBuilder { ...@@ -52,7 +50,7 @@ class BundleBuilder {
buildDir: project.dartTool.childDirectory('flutter_build'), buildDir: project.dartTool.childDirectory('flutter_build'),
cacheDir: globals.cache.getRoot(), cacheDir: globals.cache.getRoot(),
flutterRootDir: globals.fs.directory(Cache.flutterRoot), flutterRootDir: globals.fs.directory(Cache.flutterRoot),
engineVersion: globals.artifacts.isLocalEngine engineVersion: globals.artifacts!.isLocalEngine
? null ? null
: globals.flutterVersion.engineRevision, : globals.flutterVersion.engineRevision,
defines: <String, String>{ defines: <String, String>{
...@@ -62,7 +60,7 @@ class BundleBuilder { ...@@ -62,7 +60,7 @@ class BundleBuilder {
kDeferredComponents: 'false', kDeferredComponents: 'false',
...buildInfo.toBuildSystemEnvironment(), ...buildInfo.toBuildSystemEnvironment(),
}, },
artifacts: globals.artifacts, artifacts: globals.artifacts!,
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
processManager: globals.processManager, processManager: globals.processManager,
...@@ -72,7 +70,7 @@ class BundleBuilder { ...@@ -72,7 +70,7 @@ class BundleBuilder {
final Target target = buildInfo.mode == BuildMode.debug final Target target = buildInfo.mode == BuildMode.debug
? const CopyFlutterBundle() ? const CopyFlutterBundle()
: const ReleaseCopyFlutterBundle(); : const ReleaseCopyFlutterBundle();
final BuildResult result = await buildSystem.build(target, environment); final BuildResult result = await buildSystem!.build(target, environment);
if (!result.success) { if (!result.success) {
for (final ExceptionMeasurement measurement in result.exceptions.values) { for (final ExceptionMeasurement measurement in result.exceptions.values) {
...@@ -108,14 +106,14 @@ class BundleBuilder { ...@@ -108,14 +106,14 @@ class BundleBuilder {
} }
} }
Future<AssetBundle> buildAssets({ Future<AssetBundle?> buildAssets({
String manifestPath, required String manifestPath,
String assetDirPath, String? assetDirPath,
@required String packagesPath, String? packagesPath,
TargetPlatform targetPlatform, TargetPlatform? targetPlatform,
}) async { }) async {
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute(packagesPath); packagesPath ??= globals.fs.path.absolute('.packages');
// Build the asset bundle. // Build the asset bundle.
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle(); final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
...@@ -135,7 +133,7 @@ Future<AssetBundle> buildAssets({ ...@@ -135,7 +133,7 @@ Future<AssetBundle> buildAssets({
Future<void> writeBundle( Future<void> writeBundle(
Directory bundleDir, Directory bundleDir,
Map<String, DevFSContent> assetEntries, Map<String, DevFSContent> assetEntries,
{ Logger loggerOverride } { Logger? loggerOverride }
) async { ) async {
loggerOverride ??= globals.logger; loggerOverride ??= globals.logger;
if (bundleDir.existsSync()) { if (bundleDir.existsSync()) {
......
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'application_package.dart'; import 'application_package.dart';
...@@ -26,12 +23,12 @@ import 'protocol_discovery.dart'; ...@@ -26,12 +23,12 @@ import 'protocol_discovery.dart';
/// from, containing implementations that are common to all desktop devices. /// from, containing implementations that are common to all desktop devices.
abstract class DesktopDevice extends Device { abstract class DesktopDevice extends Device {
DesktopDevice(String identifier, { DesktopDevice(String identifier, {
@required PlatformType platformType, required PlatformType platformType,
@required bool ephemeral, required bool ephemeral,
@required Logger logger, required Logger logger,
@required ProcessManager processManager, required ProcessManager processManager,
@required FileSystem fileSystem, required FileSystem fileSystem,
@required OperatingSystemUtils operatingSystemUtils, required OperatingSystemUtils operatingSystemUtils,
}) : _logger = logger, }) : _logger = logger,
_processManager = processManager, _processManager = processManager,
_fileSystem = fileSystem, _fileSystem = fileSystem,
...@@ -60,7 +57,7 @@ abstract class DesktopDevice extends Device { ...@@ -60,7 +57,7 @@ abstract class DesktopDevice extends Device {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
ApplicationPackage app, { ApplicationPackage app, {
String userIdentifier, String? userIdentifier,
}) async => true; }) async => true;
// Since the host and target devices are the same, no work needs to be done // Since the host and target devices are the same, no work needs to be done
...@@ -73,7 +70,7 @@ abstract class DesktopDevice extends Device { ...@@ -73,7 +70,7 @@ abstract class DesktopDevice extends Device {
@override @override
Future<bool> installApp( Future<bool> installApp(
ApplicationPackage app, { ApplicationPackage app, {
String userIdentifier, String? userIdentifier,
}) async => true; }) async => true;
// Since the host and target devices are the same, no work needs to be done // Since the host and target devices are the same, no work needs to be done
...@@ -81,14 +78,14 @@ abstract class DesktopDevice extends Device { ...@@ -81,14 +78,14 @@ abstract class DesktopDevice extends Device {
@override @override
Future<bool> uninstallApp( Future<bool> uninstallApp(
ApplicationPackage app, { ApplicationPackage app, {
String userIdentifier, String? userIdentifier,
}) async => true; }) async => true;
@override @override
Future<bool> get isLocalEmulator async => false; Future<bool> get isLocalEmulator async => false;
@override @override
Future<String> get emulatorId async => null; Future<String?> get emulatorId async => null;
@override @override
DevicePortForwarder get portForwarder => const NoOpDevicePortForwarder(); DevicePortForwarder get portForwarder => const NoOpDevicePortForwarder();
...@@ -101,7 +98,7 @@ abstract class DesktopDevice extends Device { ...@@ -101,7 +98,7 @@ abstract class DesktopDevice extends Device {
@override @override
DeviceLogReader getLogReader({ DeviceLogReader getLogReader({
ApplicationPackage app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) { }) {
assert(!includePastLogs, 'Past log reading not supported on desktop.'); assert(!includePastLogs, 'Past log reading not supported on desktop.');
...@@ -114,13 +111,13 @@ abstract class DesktopDevice extends Device { ...@@ -114,13 +111,13 @@ abstract class DesktopDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage package, {
String mainPath, String? mainPath,
String route, String? route,
@required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs = const <String, dynamic>{}, Map<String, dynamic> platformArgs = const <String, dynamic>{},
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async { }) async {
if (!prebuiltApplication) { if (!prebuiltApplication) {
await buildForDevice( await buildForDevice(
...@@ -131,9 +128,9 @@ abstract class DesktopDevice extends Device { ...@@ -131,9 +128,9 @@ abstract class DesktopDevice extends Device {
} }
// Ensure that the executable is locatable. // Ensure that the executable is locatable.
final BuildMode buildMode = debuggingOptions?.buildInfo?.mode; final BuildMode buildMode = debuggingOptions.buildInfo.mode;
final bool traceStartup = platformArgs['trace-startup'] as bool ?? false; final bool traceStartup = platformArgs['trace-startup'] as bool? ?? false;
final String executable = executablePathForDevice(package, buildMode); final String? executable = executablePathForDevice(package, buildMode);
if (executable == null) { if (executable == null) {
_logger.printError('Unable to find executable to run'); _logger.printError('Unable to find executable to run');
return LaunchResult.failed(); return LaunchResult.failed();
...@@ -142,7 +139,7 @@ abstract class DesktopDevice extends Device { ...@@ -142,7 +139,7 @@ abstract class DesktopDevice extends Device {
Process process; Process process;
final List<String> command = <String>[ final List<String> command = <String>[
executable, executable,
...?debuggingOptions?.dartEntrypointArgs, ...debuggingOptions.dartEntrypointArgs,
]; ];
try { try {
process = await _processManager.start( process = await _processManager.start(
...@@ -157,17 +154,17 @@ abstract class DesktopDevice extends Device { ...@@ -157,17 +154,17 @@ abstract class DesktopDevice extends Device {
unawaited(process.exitCode.then((_) => _runningProcesses.remove(process))); unawaited(process.exitCode.then((_) => _runningProcesses.remove(process)));
_deviceLogReader.initializeProcess(process); _deviceLogReader.initializeProcess(process);
if (debuggingOptions?.buildInfo?.isRelease == true) { if (debuggingOptions.buildInfo.isRelease == true) {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_deviceLogReader, final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_deviceLogReader,
devicePort: debuggingOptions?.deviceVmServicePort, devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions?.hostVmServicePort, hostPort: debuggingOptions.hostVmServicePort,
ipv6: ipv6, ipv6: ipv6,
logger: _logger, logger: _logger,
); );
try { try {
final Uri observatoryUri = await observatoryDiscovery.uri; final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) { if (observatoryUri != null) {
onAttached(package, buildMode, process); onAttached(package, buildMode, process);
return LaunchResult.succeeded(observatoryUri: observatoryUri); return LaunchResult.succeeded(observatoryUri: observatoryUri);
...@@ -187,7 +184,7 @@ abstract class DesktopDevice extends Device { ...@@ -187,7 +184,7 @@ abstract class DesktopDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
ApplicationPackage app, { ApplicationPackage app, {
String userIdentifier, String? userIdentifier,
}) async { }) async {
bool succeeded = true; bool succeeded = true;
// Walk a copy of _runningProcesses, since the exit handler removes from the // Walk a copy of _runningProcesses, since the exit handler removes from the
...@@ -200,19 +197,19 @@ abstract class DesktopDevice extends Device { ...@@ -200,19 +197,19 @@ abstract class DesktopDevice extends Device {
@override @override
Future<void> dispose() async { Future<void> dispose() async {
await portForwarder?.dispose(); await portForwarder.dispose();
} }
/// Builds the current project for this device, with the given options. /// Builds the current project for this device, with the given options.
Future<void> buildForDevice( Future<void> buildForDevice(
ApplicationPackage package, { ApplicationPackage package, {
String mainPath, String? mainPath,
BuildInfo buildInfo, BuildInfo buildInfo,
}); });
/// Returns the path to the executable to run for [package] on this device for /// Returns the path to the executable to run for [package] on this device for
/// the given [buildMode]. /// the given [buildMode].
String executablePathForDevice(ApplicationPackage package, BuildMode buildMode); String? executablePathForDevice(ApplicationPackage package, BuildMode buildMode);
/// Called after a process is attached, allowing any device-specific extra /// Called after a process is attached, allowing any device-specific extra
/// steps to be run. /// steps to be run.
...@@ -225,7 +222,7 @@ abstract class DesktopDevice extends Device { ...@@ -225,7 +222,7 @@ abstract class DesktopDevice extends Device {
/// The format of the environment variables is: /// The format of the environment variables is:
/// * FLUTTER_ENGINE_SWITCHES to the number of switches. /// * FLUTTER_ENGINE_SWITCHES to the number of switches.
/// * FLUTTER_ENGINE_SWITCH_<N> (indexing from 1) to the individual switches. /// * FLUTTER_ENGINE_SWITCH_<N> (indexing from 1) to the individual switches.
Map<String, String> _computeEnvironment(DebuggingOptions debuggingOptions, bool traceStartup, String route) { Map<String, String> _computeEnvironment(DebuggingOptions debuggingOptions, bool traceStartup, String? route) {
int flags = 0; int flags = 0;
final Map<String, String> environment = <String, String>{}; final Map<String, String> environment = <String, String>{};
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
...@@ -37,10 +35,10 @@ BundleBuilder _defaultBundleBuilder() { ...@@ -37,10 +35,10 @@ BundleBuilder _defaultBundleBuilder() {
/// device is not currently discoverable. /// device is not currently discoverable.
class PreviewDevice extends Device { class PreviewDevice extends Device {
PreviewDevice({ PreviewDevice({
@required Platform platform, required Platform platform,
@required ProcessManager processManager, required ProcessManager processManager,
@required Logger logger, required Logger logger,
@required FileSystem fileSystem, required FileSystem fileSystem,
@visibleForTesting BundleBuilderFactory builderFactory = _defaultBundleBuilder, @visibleForTesting BundleBuilderFactory builderFactory = _defaultBundleBuilder,
}) : _platform = platform, }) : _platform = platform,
_processManager = processManager, _processManager = processManager,
...@@ -62,18 +60,18 @@ class PreviewDevice extends Device { ...@@ -62,18 +60,18 @@ class PreviewDevice extends Device {
Future<void> dispose() async { } Future<void> dispose() async { }
@override @override
Future<String> get emulatorId async => null; Future<String?> get emulatorId async => null;
final DesktopLogReader _logReader = DesktopLogReader(); final DesktopLogReader _logReader = DesktopLogReader();
@override @override
FutureOr<DeviceLogReader> getLogReader({covariant ApplicationPackage app, bool includePastLogs = false}) => _logReader; FutureOr<DeviceLogReader> getLogReader({covariant ApplicationPackage? app, bool includePastLogs = false}) => _logReader;
@override @override
Future<bool> installApp(covariant ApplicationPackage app, {String userIdentifier}) async => true; Future<bool> installApp(covariant ApplicationPackage? app, {String? userIdentifier}) async => true;
@override @override
Future<bool> isAppInstalled(covariant ApplicationPackage app, {String userIdentifier}) async => false; Future<bool> isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async => false;
@override @override
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) async => false; Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) async => false;
...@@ -96,24 +94,23 @@ class PreviewDevice extends Device { ...@@ -96,24 +94,23 @@ class PreviewDevice extends Device {
@override @override
Future<String> get sdkNameAndVersion async => 'preview'; Future<String> get sdkNameAndVersion async => 'preview';
Process _process; Process? _process;
Directory _assetDirectory;
@override @override
Future<LaunchResult> startApp(covariant ApplicationPackage package, { Future<LaunchResult> startApp(covariant ApplicationPackage package, {
String mainPath, String? mainPath,
String route, String? route,
@required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs, Map<String, dynamic> platformArgs = const <String, dynamic>{},
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async { }) async {
_assetDirectory = _fileSystem.systemTempDirectory final Directory assetDirectory = _fileSystem.systemTempDirectory
.createTempSync('flutter_preview.'); .createTempSync('flutter_preview.');
// Build assets and perform initial compilation. // Build assets and perform initial compilation.
Status status; Status? status;
try { try {
status = _logger.startProgress('Compiling application for preview...'); status = _logger.startProgress('Compiling application for preview...');
await _bundleBuilderFactory().build( await _bundleBuilderFactory().build(
...@@ -124,32 +121,32 @@ class PreviewDevice extends Device { ...@@ -124,32 +121,32 @@ class PreviewDevice extends Device {
); );
copyDirectory(_fileSystem.directory( copyDirectory(_fileSystem.directory(
getAssetBuildDirectory()), getAssetBuildDirectory()),
_assetDirectory.childDirectory('data').childDirectory('flutter_assets'), assetDirectory.childDirectory('data').childDirectory('flutter_assets'),
); );
} finally { } finally {
status.stop(); status?.stop();
} }
// Merge with precompiled executable. // Merge with precompiled executable.
final Directory precompiledDirectory = _fileSystem.directory(_fileSystem.path.join(Cache.flutterRoot, 'artifacts_temp', 'Debug')); final Directory precompiledDirectory = _fileSystem.directory(_fileSystem.path.join(Cache.flutterRoot!, 'artifacts_temp', 'Debug'));
copyDirectory(precompiledDirectory, _assetDirectory); copyDirectory(precompiledDirectory, assetDirectory);
final Process process = await _processManager.start( final Process process = await _processManager.start(
<String>[ <String>[
_assetDirectory.childFile('splash').path, assetDirectory.childFile('splash').path,
], ],
); );
_process = process; _process = process;
_logReader.initializeProcess(process); _logReader.initializeProcess(process);
final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_logReader, final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_logReader,
devicePort: debuggingOptions?.deviceVmServicePort, devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions?.hostVmServicePort, hostPort: debuggingOptions.hostVmServicePort,
ipv6: ipv6, ipv6: ipv6,
logger: _logger, logger: _logger,
); );
try { try {
final Uri observatoryUri = await observatoryDiscovery.uri; final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) { if (observatoryUri != null) {
return LaunchResult.succeeded(observatoryUri: observatoryUri); return LaunchResult.succeeded(observatoryUri: observatoryUri);
} }
...@@ -166,8 +163,8 @@ class PreviewDevice extends Device { ...@@ -166,8 +163,8 @@ class PreviewDevice extends Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, {String userIdentifier}) async { Future<bool> stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async {
return _process?.kill(); return _process?.kill() == true;
} }
@override @override
...@@ -179,7 +176,7 @@ class PreviewDevice extends Device { ...@@ -179,7 +176,7 @@ class PreviewDevice extends Device {
} }
@override @override
Future<bool> uninstallApp(covariant ApplicationPackage app, {String userIdentifier}) async { Future<bool> uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async {
return true; return true;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -18,7 +16,6 @@ import 'package:flutter_tools/src/device.dart'; ...@@ -18,7 +16,6 @@ import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/device_port_forwarder.dart'; import 'package:flutter_tools/src/device_port_forwarder.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../src/common.dart'; import '../src/common.dart';
...@@ -50,8 +47,8 @@ void main() { ...@@ -50,8 +47,8 @@ void main() {
testWithoutContext('Install checks always return true', () async { testWithoutContext('Install checks always return true', () async {
final FakeDesktopDevice device = setUpDesktopDevice(); final FakeDesktopDevice device = setUpDesktopDevice();
expect(await device.isAppInstalled(null), true); expect(await device.isAppInstalled(FakeApplicationPackage()), true);
expect(await device.isLatestBuildInstalled(null), true); expect(await device.isLatestBuildInstalled(FakeApplicationPackage()), true);
expect(device.category, Category.desktop); expect(device.category, Category.desktop);
}); });
...@@ -89,7 +86,7 @@ void main() { ...@@ -89,7 +86,7 @@ void main() {
), ),
]); ]);
final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager, fileSystem: fileSystem); final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager, fileSystem: fileSystem);
final String executableName = device.executablePathForDevice(null, BuildMode.debug); final String? executableName = device.executablePathForDevice(FakeApplicationPackage(), BuildMode.debug);
fileSystem.file(executableName).writeAsStringSync('\n'); fileSystem.file(executableName).writeAsStringSync('\n');
final FakeApplicationPackage package = FakeApplicationPackage(); final FakeApplicationPackage package = FakeApplicationPackage();
final LaunchResult result = await device.startApp( final LaunchResult result = await device.startApp(
...@@ -248,7 +245,7 @@ void main() { ...@@ -248,7 +245,7 @@ void main() {
testWithoutContext('createDevFSWriter returns a LocalDevFSWriter', () { testWithoutContext('createDevFSWriter returns a LocalDevFSWriter', () {
final FakeDesktopDevice device = setUpDesktopDevice(); final FakeDesktopDevice device = setUpDesktopDevice();
expect(device.createDevFSWriter(null, ''), isA<LocalDevFSWriter>()); expect(device.createDevFSWriter(FakeApplicationPackage(), ''), isA<LocalDevFSWriter>());
}); });
testWithoutContext('startApp supports dartEntrypointArgs', () async { testWithoutContext('startApp supports dartEntrypointArgs', () async {
...@@ -308,10 +305,10 @@ void main() { ...@@ -308,10 +305,10 @@ void main() {
} }
FakeDesktopDevice setUpDesktopDevice({ FakeDesktopDevice setUpDesktopDevice({
FileSystem fileSystem, FileSystem? fileSystem,
Logger logger, Logger? logger,
ProcessManager processManager, ProcessManager? processManager,
OperatingSystemUtils operatingSystemUtils, OperatingSystemUtils? operatingSystemUtils,
bool nullExecutablePathForDevice = false, bool nullExecutablePathForDevice = false,
}) { }) {
return FakeDesktopDevice( return FakeDesktopDevice(
...@@ -326,11 +323,11 @@ FakeDesktopDevice setUpDesktopDevice({ ...@@ -326,11 +323,11 @@ FakeDesktopDevice setUpDesktopDevice({
/// A trivial subclass of DesktopDevice for testing the shared functionality. /// A trivial subclass of DesktopDevice for testing the shared functionality.
class FakeDesktopDevice extends DesktopDevice { class FakeDesktopDevice extends DesktopDevice {
FakeDesktopDevice({ FakeDesktopDevice({
@required ProcessManager processManager, required ProcessManager processManager,
@required Logger logger, required Logger logger,
@required FileSystem fileSystem, required FileSystem fileSystem,
@required OperatingSystemUtils operatingSystemUtils, required OperatingSystemUtils operatingSystemUtils,
this.nullExecutablePathForDevice, this.nullExecutablePathForDevice = false,
}) : super( }) : super(
'dummy', 'dummy',
platformType: PlatformType.linux, platformType: PlatformType.linux,
...@@ -342,10 +339,10 @@ class FakeDesktopDevice extends DesktopDevice { ...@@ -342,10 +339,10 @@ class FakeDesktopDevice extends DesktopDevice {
); );
/// The [mainPath] last passed to [buildForDevice]. /// The [mainPath] last passed to [buildForDevice].
String lastBuiltMainPath; String? lastBuiltMainPath;
/// The [buildInfo] last passed to [buildForDevice]. /// The [buildInfo] last passed to [buildForDevice].
BuildInfo lastBuildInfo; BuildInfo? lastBuildInfo;
final bool nullExecutablePathForDevice; final bool nullExecutablePathForDevice;
...@@ -364,8 +361,8 @@ class FakeDesktopDevice extends DesktopDevice { ...@@ -364,8 +361,8 @@ class FakeDesktopDevice extends DesktopDevice {
@override @override
Future<void> buildForDevice( Future<void> buildForDevice(
ApplicationPackage package, { ApplicationPackage package, {
String mainPath, String? mainPath,
BuildInfo buildInfo, BuildInfo? buildInfo,
}) async { }) async {
lastBuiltMainPath = mainPath; lastBuiltMainPath = mainPath;
lastBuildInfo = buildInfo; lastBuildInfo = buildInfo;
...@@ -373,7 +370,7 @@ class FakeDesktopDevice extends DesktopDevice { ...@@ -373,7 +370,7 @@ class FakeDesktopDevice extends DesktopDevice {
// Dummy implementation that just returns the build mode name. // Dummy implementation that just returns the build mode name.
@override @override
String executablePathForDevice(ApplicationPackage package, BuildMode buildMode) { String? executablePathForDevice(ApplicationPackage package, BuildMode buildMode) {
if (nullExecutablePathForDevice) { if (nullExecutablePathForDevice) {
return null; return null;
} }
......
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