Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: pkg/front_end/test/physical_file_system_test.dart

Issue 2844903002: Extend file-system abstraction with a couple methods, remove context (Closed)
Patch Set: fix test in windows bot Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/test/physical_file_system_test.dart
diff --git a/pkg/front_end/test/physical_file_system_test.dart b/pkg/front_end/test/physical_file_system_test.dart
index d1a026bbe8550006ae2d4627923b2ebdcef8f120..d34457a787a3401992af8d4714b5b32f6ed8d575 100644
--- a/pkg/front_end/test/physical_file_system_test.dart
+++ b/pkg/front_end/test/physical_file_system_test.dart
@@ -19,6 +19,7 @@ main() {
defineReflectiveSuite(() {
defineReflectiveTests(PhysicalFileSystemTest);
defineReflectiveTests(FileTest);
+ defineReflectiveTests(DirectoryTest);
});
}
@@ -86,6 +87,71 @@ class FileTest extends _BaseTest {
test_uri() {
expect(file.uri, p.toUri(path));
}
+
+ test_exists_doesNotExist() async {
+ expect(await file.exists(), isFalse);
+ }
+
+ test_exists_fileExists() async {
+ new io.File(path).writeAsStringSync('contents');
+ expect(await file.exists(), isTrue);
+ }
+
+ test_lastModified_increasesOnEachChange() async {
+ new io.File(path).writeAsStringSync('contents1');
+ var mod1 = await file.lastModified();
+
+ // Pause to ensure the file-system time-stamps are different.
+ await new Future.delayed(new Duration(seconds: 1));
+ new io.File(path).writeAsStringSync('contents2');
+ var mod2 = await file.lastModified();
+ expect(mod2.isAfter(mod1), isTrue);
+
+ await new Future.delayed(new Duration(seconds: 1));
+ var path2 = p.join(tempPath, 'file2.txt');
+ new io.File(path2).writeAsStringSync('contents2');
+ var file2 = entityForPath(path2);
+ var mod3 = await file2.lastModified();
+ expect(mod3.isAfter(mod2), isTrue);
+ }
+}
+
+@reflectiveTest
+class DirectoryTest extends _BaseTest {
+ String path;
+ FileSystemEntity dir;
+
+ setUp() {
+ super.setUp();
+ path = p.join(tempPath, 'dir');
+ dir = PhysicalFileSystem.instance.entityForUri(p.toUri(path));
+ }
+
+ test_equals_differentPaths() {
+ expect(dir == entityForPath(p.join(tempPath, 'dir2')), isFalse);
+ }
+
+ test_equals_samePath() {
+ expect(dir == entityForPath(p.join(tempPath, 'dir')), isTrue);
+ }
+
+ test_readAsBytes() async {
+ await new io.Directory(path).create();
+ expect(dir.readAsBytes(), throwsException);
+ }
+
+ test_uri() {
+ expect(dir.uri, p.toUri(path));
+ }
+
+ test_exists_doesNotExist() async {
+ expect(await dir.exists(), isFalse);
+ }
+
+ test_exists_directoryExists() async {
+ await new io.Directory(path).create();
+ expect(await dir.exists(), isTrue);
+ }
}
@reflectiveTest
« no previous file with comments | « pkg/front_end/test/memory_file_system_test.dart ('k') | pkg/front_end/test/src/base/processed_options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698