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

[flutter_tools] enable LocalDevFSWriter for desktop devices, iOS simulator (#66678)

* [flutter_tools] enable LocalDevFSWriter for desktop devices, iOS simulator

* Update device.dart

* Update desktop_device_test.dart

* fix analysis errors
parent ccdaa370
......@@ -47,8 +47,10 @@ abstract class DesktopDevice extends Device {
final Set<Process> _runningProcesses = <Process>{};
final DesktopLogReader _deviceLogReader = DesktopLogReader();
DevFSWriter get devFSWriter => _desktopDevFSWriter ??= LocalDevFSWriter(fileSystem: _fileSystem);
LocalDevFSWriter _desktopDevFSWriter;
@override
DevFSWriter createDevFSWriter(covariant ApplicationPackage app, String userIdentifier) {
return LocalDevFSWriter(fileSystem: _fileSystem);
}
// Since the host and target devices are the same, no work needs to be done
// to install the application.
......
......@@ -27,6 +27,7 @@ import 'base/terminal.dart';
import 'base/user_messages.dart' hide userMessages;
import 'base/utils.dart';
import 'build_info.dart';
import 'devfs.dart';
import 'features.dart';
import 'fuchsia/fuchsia_device.dart';
import 'fuchsia/fuchsia_sdk.dart';
......@@ -622,6 +623,18 @@ abstract class Device {
Future<String> get sdkNameAndVersion;
/// Create a platform-specific [DevFSWriter] for the given [app], or
/// null if the device does not support them.
///
/// For example, the destkop device classes can use a writer which
/// copies the files across the local file system.
DevFSWriter createDevFSWriter(
covariant ApplicationPackage app,
String userIdentifier,
) {
return null;
}
/// Get a log reader for this device.
///
/// If `app` is specified, this will return a log reader specific to that
......
......@@ -296,8 +296,10 @@ class IOSSimulator extends Device {
final SimControl _simControl;
final Xcode _xcode;
DevFSWriter get devFSWriter => _desktopDevFSWriter ??= LocalDevFSWriter(fileSystem: globals.fs);
LocalDevFSWriter _desktopDevFSWriter;
@override
DevFSWriter createDevFSWriter(covariant ApplicationPackage app, String userIdentifier) {
return LocalDevFSWriter(fileSystem: globals.fs);
}
@override
Future<bool> get isLocalEmulator async => true;
......
......@@ -185,6 +185,8 @@ class FlutterDevice {
final ResidentCompiler generator;
final BuildInfo buildInfo;
final String userIdentifier;
DevFSWriter devFSWriter;
Stream<Uri> observatoryUris;
vm_service.VmService vmService;
DevFS devFS;
......@@ -573,6 +575,7 @@ class FlutterDevice {
globals.printError(message);
return 1;
}
devFSWriter = device.createDevFSWriter(package, userIdentifier);
final Map<String, dynamic> platformArgs = <String, dynamic>{};
......@@ -620,6 +623,7 @@ class FlutterDevice {
buildInfo: coldRunner.debuggingOptions.buildInfo,
applicationBinary: coldRunner.applicationBinary,
);
devFSWriter = device.createDevFSWriter(package, userIdentifier);
final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName;
final bool prebuiltMode = coldRunner.applicationBinary != null;
......@@ -715,7 +719,7 @@ class FlutterDevice {
pathToReload: pathToReload,
invalidatedFiles: invalidatedFiles,
packageConfig: packageConfig,
devFSWriter: null,
devFSWriter: devFSWriter,
);
} on DevFSException {
devFSStatus.cancel();
......
......@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/desktop_device.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
......@@ -242,6 +243,12 @@ void main() {
expect(result, 2);
expect(portForwarder.forwardedPorts.isEmpty, true);
});
testUsingContext('createDevFSWriter returns a LocalDevFSWriter', () {
final FakeDesktopDevice device = setUpDesktopDevice();
expect(device.createDevFSWriter(null, ''), isA<LocalDevFSWriter>());
});
}
FakeDesktopDevice setUpDesktopDevice({
......
......@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/mac.dart';
......@@ -1000,6 +1001,16 @@ flutter:
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('createDevFSWriter returns a LocalDevFSWriter', () {
final IOSSimulator simulator = IOSSimulator(
'test',
simControl: mockSimControl,
xcode: mockXcode,
);
expect(simulator.createDevFSWriter(null, ''), isA<LocalDevFSWriter>());
});
});
}
......
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