Unverified Commit 27876e09 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Devfs cleanup and testing (#33374)" (#33673)

This reverts commit 445505d6.
parent b7bd5768
...@@ -36,9 +36,10 @@ Future<void> main(List<String> args) { ...@@ -36,9 +36,10 @@ Future<void> main(List<String> args) {
}); });
} }
void writeFile(libfs.File outputFile, DevFSContent content) { Future<void> writeFile(libfs.File outputFile, DevFSContent content) async {
outputFile.createSync(recursive: true); outputFile.createSync(recursive: true);
content.copyToFile(outputFile); final List<int> data = await content.contentsAsBytes();
outputFile.writeAsBytesSync(data);
} }
Future<void> run(List<String> args) async { Future<void> run(List<String> args) async {
...@@ -70,10 +71,12 @@ Future<void> run(List<String> args) async { ...@@ -70,10 +71,12 @@ Future<void> run(List<String> args) async {
exit(1); exit(1);
} }
final List<Future<void>> calls = <Future<void>>[];
assets.entries.forEach((String fileName, DevFSContent content) { assets.entries.forEach((String fileName, DevFSContent content) {
final libfs.File outputFile = libfs.fs.file(libfs.fs.path.join(assetDir, fileName)); final libfs.File outputFile = libfs.fs.file(libfs.fs.path.join(assetDir, fileName));
writeFile(outputFile, content); calls.add(writeFile(outputFile, content));
}); });
await Future.wait<void>(calls);
final String outputMan = argResults[_kOptionAssetManifestOut]; final String outputMan = argResults[_kOptionAssetManifestOut];
await writeFuchsiaManifest(assets, argResults[_kOptionAsset], outputMan, argResults[_kOptionComponentName]); await writeFuchsiaManifest(assets, argResults[_kOptionAsset], outputMan, argResults[_kOptionComponentName]);
......
...@@ -147,7 +147,7 @@ Future<void> build({ ...@@ -147,7 +147,7 @@ Future<void> build({
if (assets == null) if (assets == null)
throwToolExit('Error building assets', exitCode: 1); throwToolExit('Error building assets', exitCode: 1);
assemble( await assemble(
buildMode: buildMode, buildMode: buildMode,
assetBundle: assets, assetBundle: assets,
kernelContent: kernelContent, kernelContent: kernelContent,
...@@ -182,14 +182,14 @@ Future<AssetBundle> buildAssets({ ...@@ -182,14 +182,14 @@ Future<AssetBundle> buildAssets({
return assetBundle; return assetBundle;
} }
void assemble({ Future<void> assemble({
BuildMode buildMode, BuildMode buildMode,
AssetBundle assetBundle, AssetBundle assetBundle,
DevFSContent kernelContent, DevFSContent kernelContent,
String privateKeyPath = defaultPrivateKeyPath, String privateKeyPath = defaultPrivateKeyPath,
String assetDirPath, String assetDirPath,
String compilationTraceFilePath, String compilationTraceFilePath,
}) { }) async {
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
printTrace('Building bundle'); printTrace('Building bundle');
...@@ -214,21 +214,22 @@ void assemble({ ...@@ -214,21 +214,22 @@ void assemble({
printTrace('Writing asset files to $assetDirPath'); printTrace('Writing asset files to $assetDirPath');
ensureDirectoryExists(assetDirPath); ensureDirectoryExists(assetDirPath);
writeBundle(fs.directory(assetDirPath), assetEntries); await writeBundle(fs.directory(assetDirPath), assetEntries);
printTrace('Wrote $assetDirPath'); printTrace('Wrote $assetDirPath');
} }
void writeBundle( Future<void> writeBundle(
Directory bundleDir, Directory bundleDir,
Map<String, DevFSContent> assetEntries, Map<String, DevFSContent> assetEntries,
) { ) async {
if (bundleDir.existsSync()) if (bundleDir.existsSync())
bundleDir.deleteSync(recursive: true); bundleDir.deleteSync(recursive: true);
bundleDir.createSync(recursive: true); bundleDir.createSync(recursive: true);
for (MapEntry<String, DevFSContent> entry in assetEntries.entries) { await Future.wait<void>(
assetEntries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async {
final File file = fs.file(fs.path.join(bundleDir.path, entry.key)); final File file = fs.file(fs.path.join(bundleDir.path, entry.key));
file.parent.createSync(recursive: true); file.parent.createSync(recursive: true);
entry.value.copyToFile(file); await file.writeAsBytes(await entry.value.contentsAsBytes());
} }));
} }
...@@ -242,7 +242,7 @@ class TestCommand extends FastFlutterCommand { ...@@ -242,7 +242,7 @@ class TestCommand extends FastFlutterCommand {
throwToolExit('Error: Failed to build asset bundle'); throwToolExit('Error: Failed to build asset bundle');
} }
if (_needRebuild(assetBundle.entries)) { if (_needRebuild(assetBundle.entries)) {
writeBundle(fs.directory(fs.path.join('build', 'unit_test_assets')), await writeBundle(fs.directory(fs.path.join('build', 'unit_test_assets')),
assetBundle.entries); assetBundle.entries);
} }
} }
......
...@@ -38,25 +38,21 @@ abstract class DevFSContent { ...@@ -38,25 +38,21 @@ abstract class DevFSContent {
/// or if the given time is null. /// or if the given time is null.
bool isModifiedAfter(DateTime time); bool isModifiedAfter(DateTime time);
/// The number of bytes in this file.
int get size; int get size;
/// Returns the raw bytes of this file. Future<List<int>> contentsAsBytes();
List<int> contentsAsBytes();
/// Returns a gzipped representation of the contents of this file. Stream<List<int>> contentsAsStream();
List<int> contentsAsCompressedBytes() {
return gzip.encode(contentsAsBytes()); Stream<List<int>> contentsAsCompressedStream() {
return contentsAsStream().cast<List<int>>().transform<List<int>>(gzip.encoder);
} }
/// Copies the content into the provided file. /// Return the list of files this content depends on.
/// List<String> get fileDependencies => <String>[];
/// Requires that the `destination` directory already exists, but the target
/// file need not.
void copyToFile(File destination);
} }
/// File content to be copied to the device. // File content to be copied to the device.
class DevFSFileContent extends DevFSContent { class DevFSFileContent extends DevFSContent {
DevFSFileContent(this.file); DevFSFileContent(this.file);
...@@ -106,6 +102,9 @@ class DevFSFileContent extends DevFSContent { ...@@ -106,6 +102,9 @@ class DevFSFileContent extends DevFSContent {
} }
} }
@override
List<String> get fileDependencies => <String>[_getFile().path];
@override @override
bool get isModified { bool get isModified {
final FileStat _oldFileStat = _fileStat; final FileStat _oldFileStat = _fileStat;
...@@ -136,12 +135,10 @@ class DevFSFileContent extends DevFSContent { ...@@ -136,12 +135,10 @@ class DevFSFileContent extends DevFSContent {
} }
@override @override
List<int> contentsAsBytes() => _getFile().readAsBytesSync().cast<int>(); Future<List<int>> contentsAsBytes() => _getFile().readAsBytes();
@override @override
void copyToFile(File destination) { Stream<List<int>> contentsAsStream() => _getFile().openRead();
_getFile().copySync(destination.path);
}
} }
/// Byte content to be copied to the device. /// Byte content to be copied to the device.
...@@ -178,15 +175,14 @@ class DevFSByteContent extends DevFSContent { ...@@ -178,15 +175,14 @@ class DevFSByteContent extends DevFSContent {
int get size => _bytes.length; int get size => _bytes.length;
@override @override
List<int> contentsAsBytes() => _bytes; Future<List<int>> contentsAsBytes() async => _bytes;
@override @override
void copyToFile(File destination) { Stream<List<int>> contentsAsStream() =>
destination.writeAsBytesSync(contentsAsBytes()); Stream<List<int>>.fromIterable(<List<int>>[_bytes]);
}
} }
/// String content to be copied to the device encoded as utf8. /// String content to be copied to the device.
class DevFSStringContent extends DevFSByteContent { class DevFSStringContent extends DevFSByteContent {
DevFSStringContent(String string) DevFSStringContent(String string)
: _string = string, : _string = string,
...@@ -207,30 +203,76 @@ class DevFSStringContent extends DevFSByteContent { ...@@ -207,30 +203,76 @@ class DevFSStringContent extends DevFSByteContent {
} }
} }
class DevFSOperations { /// Abstract DevFS operations interface.
DevFSOperations(this.vmService, this.fsName) abstract class DevFSOperations {
: httpAddress = vmService.httpAddress; Future<Uri> create(String fsName);
Future<dynamic> destroy(String fsName);
final VMService vmService; Future<dynamic> writeFile(String fsName, Uri deviceUri, DevFSContent content);
final String fsName; }
final Uri httpAddress;
final HttpClient _client = HttpClient();
static const int kMaxInFlight = 6; /// An implementation of [DevFSOperations] that speaks to the
/// vm service.
class ServiceProtocolDevFSOperations implements DevFSOperations {
ServiceProtocolDevFSOperations(this.vmService);
int _inFlight = 0; final VMService vmService;
Map<Uri, DevFSContent> _outstanding;
Completer<void> _completer;
@override
Future<Uri> create(String fsName) async { Future<Uri> create(String fsName) async {
final Map<String, dynamic> response = await vmService.vm.createDevFS(fsName); final Map<String, dynamic> response = await vmService.vm.createDevFS(fsName);
return Uri.parse(response['uri']); return Uri.parse(response['uri']);
} }
Future<void> destroy(String fsName) async { @override
Future<dynamic> destroy(String fsName) async {
await vmService.vm.deleteDevFS(fsName); await vmService.vm.deleteDevFS(fsName);
} }
@override
Future<dynamic> writeFile(String fsName, Uri deviceUri, DevFSContent content) async {
List<int> bytes;
try {
bytes = await content.contentsAsBytes();
} catch (e) {
return e;
}
final String fileContents = base64.encode(bytes);
try {
return await vmService.vm.invokeRpcRaw(
'_writeDevFSFile',
params: <String, dynamic>{
'fsName': fsName,
'uri': deviceUri.toString(),
'fileContents': fileContents,
},
);
} catch (error) {
printTrace('DevFS: Failed to write $deviceUri: $error');
}
}
}
class DevFSException implements Exception {
DevFSException(this.message, [this.error, this.stackTrace]);
final String message;
final dynamic error;
final StackTrace stackTrace;
}
class _DevFSHttpWriter {
_DevFSHttpWriter(this.fsName, VMService serviceProtocol)
: httpAddress = serviceProtocol.httpAddress;
final String fsName;
final Uri httpAddress;
static const int kMaxInFlight = 6;
int _inFlight = 0;
Map<Uri, DevFSContent> _outstanding;
Completer<void> _completer;
final HttpClient _client = HttpClient();
Future<void> write(Map<Uri, DevFSContent> entries) async { Future<void> write(Map<Uri, DevFSContent> entries) async {
_client.maxConnectionsPerHost = kMaxInFlight; _client.maxConnectionsPerHost = kMaxInFlight;
_completer = Completer<void>(); _completer = Completer<void>();
...@@ -259,9 +301,9 @@ class DevFSOperations { ...@@ -259,9 +301,9 @@ class DevFSOperations {
final HttpClientRequest request = await _client.putUrl(httpAddress); final HttpClientRequest request = await _client.putUrl(httpAddress);
request.headers.removeAll(HttpHeaders.acceptEncodingHeader); request.headers.removeAll(HttpHeaders.acceptEncodingHeader);
request.headers.add('dev_fs_name', fsName); request.headers.add('dev_fs_name', fsName);
request.headers.add('dev_fs_uri_b64', request.headers.add('dev_fs_uri_b64', base64.encode(utf8.encode('$deviceUri')));
base64.encode(utf8.encode(deviceUri.toString()))); final Stream<List<int>> contents = content.contentsAsCompressedStream();
request.add(content.contentsAsCompressedBytes()); await request.addStream(contents);
final HttpClientResponse response = await request.close(); final HttpClientResponse response = await request.close();
await response.drain<void>(); await response.drain<void>();
} catch (error, trace) { } catch (error, trace) {
...@@ -275,14 +317,6 @@ class DevFSOperations { ...@@ -275,14 +317,6 @@ class DevFSOperations {
} }
} }
class DevFSException implements Exception {
DevFSException(this.message, [this.error, this.stackTrace]);
final String message;
final dynamic error;
final StackTrace stackTrace;
}
// Basic statistics for DevFS update operation. // Basic statistics for DevFS update operation.
class UpdateFSReport { class UpdateFSReport {
UpdateFSReport({ UpdateFSReport({
...@@ -319,7 +353,8 @@ class DevFS { ...@@ -319,7 +353,8 @@ class DevFS {
this.fsName, this.fsName,
this.rootDirectory, { this.rootDirectory, {
String packagesFilePath, String packagesFilePath,
}) : _operations = DevFSOperations(serviceProtocol, fsName), }) : _operations = ServiceProtocolDevFSOperations(serviceProtocol),
_httpWriter = _DevFSHttpWriter(fsName, serviceProtocol),
_packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName); _packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
DevFS.operations( DevFS.operations(
...@@ -327,9 +362,11 @@ class DevFS { ...@@ -327,9 +362,11 @@ class DevFS {
this.fsName, this.fsName,
this.rootDirectory, { this.rootDirectory, {
String packagesFilePath, String packagesFilePath,
}) : _packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName); }) : _httpWriter = null,
_packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
final DevFSOperations _operations; final DevFSOperations _operations;
final _DevFSHttpWriter _httpWriter;
final String fsName; final String fsName;
final Directory rootDirectory; final Directory rootDirectory;
String _packagesFilePath; String _packagesFilePath;
...@@ -452,7 +489,7 @@ class DevFS { ...@@ -452,7 +489,7 @@ class DevFS {
printTrace('Updating files'); printTrace('Updating files');
if (dirtyEntries.isNotEmpty) { if (dirtyEntries.isNotEmpty) {
try { try {
await _operations.write(dirtyEntries); await _httpWriter.write(dirtyEntries);
} on SocketException catch (socketException, stackTrace) { } on SocketException catch (socketException, stackTrace) {
printTrace('DevFS sync failed. Lost connection to device: $socketException'); printTrace('DevFS sync failed. Lost connection to device: $socketException');
throw DevFSException('Lost connection to device.', socketException, stackTrace); throw DevFSException('Lost connection to device.', socketException, stackTrace);
......
...@@ -52,7 +52,7 @@ Future<void> _buildAssets( ...@@ -52,7 +52,7 @@ Future<void> _buildAssets(
final Map<String, DevFSContent> assetEntries = final Map<String, DevFSContent> assetEntries =
Map<String, DevFSContent>.from(assets.entries); Map<String, DevFSContent>.from(assets.entries);
writeBundle(fs.directory(assetDir), assetEntries); await writeBundle(fs.directory(assetDir), assetEntries);
final String appName = fuchsiaProject.project.manifest.appName; final String appName = fuchsiaProject.project.manifest.appName;
final String outDir = getFuchsiaBuildDirectory(); final String outDir = getFuchsiaBuildDirectory();
......
...@@ -120,7 +120,8 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -120,7 +120,8 @@ class ResidentWebRunner extends ResidentRunner {
if (build != 0) { if (build != 0) {
throwToolExit('Error: Failed to build asset bundle'); throwToolExit('Error: Failed to build asset bundle');
} }
writeBundle(fs.directory(getAssetBuildDirectory()), assetBundle.entries); await writeBundle(
fs.directory(getAssetBuildDirectory()), assetBundle.entries);
// Step 2: Start an HTTP server // Step 2: Start an HTTP server
_server = WebAssetServer(flutterProject, target, ipv6); _server = WebAssetServer(flutterProject, target, ipv6);
......
...@@ -119,7 +119,7 @@ class WebDevice extends Device { ...@@ -119,7 +119,7 @@ class WebDevice extends Device {
if (build != 0) { if (build != 0) {
throwToolExit('Error: Failed to build asset bundle'); throwToolExit('Error: Failed to build asset bundle');
} }
writeBundle(fs.directory(getAssetBuildDirectory()), assetBundle.entries); await writeBundle(fs.directory(getAssetBuildDirectory()), assetBundle.entries);
_package = package; _package = package;
_server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0); _server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
......
...@@ -74,7 +74,7 @@ $fontsSection ...@@ -74,7 +74,7 @@ $fontsSection
final String entryKey = 'packages/$packageName/$packageFont'; final String entryKey = 'packages/$packageName/$packageFont';
expect(bundle.entries.containsKey(entryKey), true); expect(bundle.entries.containsKey(entryKey), true);
expect( expect(
utf8.decode(bundle.entries[entryKey].contentsAsBytes()), utf8.decode(await bundle.entries[entryKey].contentsAsBytes()),
packageFont, packageFont,
); );
} }
...@@ -82,14 +82,14 @@ $fontsSection ...@@ -82,14 +82,14 @@ $fontsSection
for (String localFont in localFonts) { for (String localFont in localFonts) {
expect(bundle.entries.containsKey(localFont), true); expect(bundle.entries.containsKey(localFont), true);
expect( expect(
utf8.decode(bundle.entries[localFont].contentsAsBytes()), utf8.decode(await bundle.entries[localFont].contentsAsBytes()),
localFont, localFont,
); );
} }
} }
expect( expect(
json.decode(utf8.decode(bundle.entries['FontManifest.json'].contentsAsBytes())), json.decode(utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes())),
json.decode(expectedAssetManifest), json.decode(expectedAssetManifest),
); );
} }
......
...@@ -79,14 +79,14 @@ $assetsSection ...@@ -79,14 +79,14 @@ $assetsSection
final String entryKey = Uri.encodeFull('packages/$packageName/$asset'); final String entryKey = Uri.encodeFull('packages/$packageName/$asset');
expect(bundle.entries.containsKey(entryKey), true, reason: 'Cannot find key on bundle: $entryKey'); expect(bundle.entries.containsKey(entryKey), true, reason: 'Cannot find key on bundle: $entryKey');
expect( expect(
utf8.decode(bundle.entries[entryKey].contentsAsBytes()), utf8.decode(await bundle.entries[entryKey].contentsAsBytes()),
asset, asset,
); );
} }
} }
expect( expect(
utf8.decode(bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
} }
...@@ -126,11 +126,11 @@ $assetsSection ...@@ -126,11 +126,11 @@ $assetsSection
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
utf8.decode(bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
expect( expect(
utf8.decode(bundle.entries['FontManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
'[]', '[]',
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -153,11 +153,11 @@ $assetsSection ...@@ -153,11 +153,11 @@ $assetsSection
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
utf8.decode(bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
expect( expect(
utf8.decode(bundle.entries['FontManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()),
'[]', '[]',
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -50,7 +50,7 @@ void main() { ...@@ -50,7 +50,7 @@ void main() {
expect(bundle.entries.length, 1); expect(bundle.entries.length, 1);
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
utf8.decode(bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -76,7 +76,7 @@ flutter: ...@@ -76,7 +76,7 @@ flutter:
// The main asset file, /a/b/c/foo, and its variants exist. // The main asset file, /a/b/c/foo, and its variants exist.
for (String asset in assets) { for (String asset in assets) {
expect(bundle.entries.containsKey(asset), true); expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(bundle.entries[asset].contentsAsBytes()), asset); expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset);
} }
fs.file(fixPath('a/b/c/foo')).deleteSync(); fs.file(fixPath('a/b/c/foo')).deleteSync();
...@@ -88,7 +88,7 @@ flutter: ...@@ -88,7 +88,7 @@ flutter:
expect(bundle.entries.containsKey('a/b/c/foo'), false); expect(bundle.entries.containsKey('a/b/c/foo'), false);
for (String asset in assets.skip(1)) { for (String asset in assets.skip(1)) {
expect(bundle.entries.containsKey(asset), true); expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(bundle.entries[asset].contentsAsBytes()), asset); expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset);
} }
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => testFileSystem, FileSystem: () => testFileSystem,
......
...@@ -7,7 +7,6 @@ import 'dart:async'; ...@@ -7,7 +7,6 @@ import 'dart:async';
import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/convert.dart';
import 'src/common.dart'; import 'src/common.dart';
import 'src/context.dart'; import 'src/context.dart';
...@@ -66,5 +65,5 @@ void main() { ...@@ -66,5 +65,5 @@ void main() {
} }
Future<String> getValueAsString(String key, AssetBundle asset) async { Future<String> getValueAsString(String key, AssetBundle asset) async {
return utf8.decode(asset.entries[key].contentsAsBytes()); return String.fromCharCodes(await asset.entries[key].contentsAsBytes());
} }
This diff is collapsed.
...@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/ios/devices.dart'; import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/simulators.dart'; import 'package:flutter_tools/src/ios/simulators.dart';
...@@ -477,6 +478,30 @@ class BasicMock { ...@@ -477,6 +478,30 @@ class BasicMock {
} }
} }
class MockDevFSOperations extends BasicMock implements DevFSOperations {
Map<Uri, DevFSContent> devicePathToContent = <Uri, DevFSContent>{};
@override
Future<Uri> create(String fsName) async {
messages.add('create $fsName');
return Uri.parse('file:///$fsName');
}
@override
Future<dynamic> destroy(String fsName) async {
messages.add('destroy $fsName');
}
@override
Future<dynamic> writeFile(String fsName, Uri deviceUri, DevFSContent content) async {
String message = 'writeFile $fsName $deviceUri';
if (content is DevFSFileContent) {
message += ' ${content.file.path}';
}
messages.add(message);
devicePathToContent[deviceUri] = content;
}
}
class MockResidentCompiler extends BasicMock implements ResidentCompiler { class MockResidentCompiler extends BasicMock implements ResidentCompiler {
@override @override
......
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