Unverified Commit 567a4b9c authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Switch asset_bundle_test.dart to use memory file system (#21425)

parent 05edc00a
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
import 'dart:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart';
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/base/platform.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'src/common.dart'; import 'src/common.dart';
...@@ -19,26 +21,23 @@ void main() { ...@@ -19,26 +21,23 @@ void main() {
}); });
group('AssetBundle.build', () { group('AssetBundle.build', () {
// These tests do not use a memory file system because we want to ensure that FileSystem testFileSystem;
// asset bundles work correctly on Windows and Posix systems.
Directory tempDir;
Directory oldCurrentDir;
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_asset_bundle_test.'); testFileSystem = new MemoryFileSystem(
oldCurrentDir = fs.currentDirectory; style: platform.isWindows
fs.currentDirectory = tempDir; ? FileSystemStyle.windows
}); : FileSystemStyle.posix,
);
tearDown(() { testFileSystem.currentDirectory = testFileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
fs.currentDirectory = oldCurrentDir;
tryToDelete(tempDir);
}); });
testUsingContext('nonempty', () async { testUsingContext('nonempty', () async {
final AssetBundle ab = AssetBundleFactory.instance.createBundle(); final AssetBundle ab = AssetBundleFactory.instance.createBundle();
expect(await ab.build(), 0); expect(await ab.build(), 0);
expect(ab.entries.length, greaterThan(0)); expect(ab.entries.length, greaterThan(0));
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
}); });
testUsingContext('empty pubspec', () async { testUsingContext('empty pubspec', () async {
...@@ -54,6 +53,8 @@ void main() { ...@@ -54,6 +53,8 @@ void main() {
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
}); });
}); });
......
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