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

Unified Diff: tests/standalone/src/DirectoryTest.dart

Issue 8965036: Add asynchronous versions of the methods on Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
« runtime/bin/directory.dart ('K') | « runtime/bin/directory_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/DirectoryTest.dart
diff --git a/tests/standalone/src/DirectoryTest.dart b/tests/standalone/src/DirectoryTest.dart
index 77d4bdb79aee9c416e3cd35bc805056484323a7d..bf43d5074e5741937cf532ddb2ee5c89fab6ed5d 100644
--- a/tests/standalone/src/DirectoryTest.dart
+++ b/tests/standalone/src/DirectoryTest.dart
@@ -55,6 +55,39 @@ class DirectoryTest {
static void testExistsCreateDelete() {
Søren Gjesse 2011/12/20 09:12:40 We should avoid using /tmp, or at least check for
Mads Ager (google) 2011/12/20 09:26:24 We have one test that does the check. Let's just u
Directory d = new Directory("/tmp/dart_temp_dir_");
+ d.createTempHandler = () {
+ d.existsHandler = (bool exists) {
+ Expect.isTrue(exists);
+ Directory created = new Directory("${d.path}/subdir");
+ created.createHandler = () {
+ created.existsHandler = (bool exists) {
+ Expect.isTrue(exists);
+ created.deleteHandler = () {
+ created.existsHandler = (bool exists) {
+ Expect.isFalse(exists);
+ d.deleteHandler = () {
+ d.existsHandler = (bool exists) {
+ Expect.isFalse(exists);
+ };
+ d.exists();
+ };
+ d.delete();
+ };
+ created.exists();
+ };
+ created.delete();
+ };
+ created.exists();
+ };
+ created.create();
+ };
+ d.exists();
+ };
+ d.createTemp();
+ }
+
+ static void testExistsCreateDeleteSync() {
+ Directory d = new Directory("/tmp/dart_temp_dir_");
Søren Gjesse 2011/12/20 09:12:40 Ditto.
Mads Ager (google) 2011/12/20 09:26:24 Done.
d.createTempSync();
Expect.isTrue(d.existsSync());
Directory created = new Directory("${d.path}/subdir");
@@ -64,7 +97,9 @@ class DirectoryTest {
Expect.isFalse(created.existsSync());
d.deleteSync();
Expect.isFalse(d.existsSync());
+ }
+ static void testCreateTemp() {
Directory tempDir1 = new Directory("/tmp/dart_temp_dir_");
Søren Gjesse 2011/12/20 09:12:40 Ditto.
Mads Ager (google) 2011/12/20 09:26:24 This one does the check further down.
Directory tempDir2 = new Directory("/tmp/dart_temp_dir_");
bool stage1aDone = false;
@@ -137,7 +172,7 @@ class DirectoryTest {
}
}
- static void testCreateTemp() {
+ static void testCreateDeleteTemp() {
Directory tempDirectory = new Directory("");
tempDirectory.createTempHandler = () {
String filename = tempDirectory.path +
@@ -148,56 +183,39 @@ class DirectoryTest {
Expect.fail("testCreateTemp file.errorHandler called: $error");
};
file.createHandler = () {
- file.openHandler = (RandomAccessFile openedFile) {
- openedFile.writeList([65, 66, 67, 13], 0, 4);
- openedFile.noPendingWriteHandler = () {
- openedFile.length();
- };
- openedFile.lengthHandler = (int length) {
- Expect.equals(4, length);
- openedFile.close();
- };
- openedFile.closeHandler = () {
- file.exists();
- };
- file.existsHandler = (bool exists) {
- Expect.isTrue(exists);
- // Try to delete the directory containing the file - should throw.
- bool threw_exception = false;
- try {
- tempDirectory.deleteSync();
- } catch (var e) {
- Expect.isTrue(tempDirectory.existsSync());
- threw_exception = true;
- }
- Expect.isTrue(threw_exception);
+ file.existsHandler = (bool exists) {
+ Expect.isTrue(exists);
+ // Try to delete the directory containing the file - should throw.
+ bool threw_exception = false;
+ try {
Søren Gjesse 2011/12/20 09:12:40 Can't we use Expect.throws here?
Mads Ager (google) 2011/12/20 09:26:24 Done.
+ tempDirectory.deleteSync();
+ } catch (var e) {
Expect.isTrue(tempDirectory.existsSync());
+ threw_exception = true;
+ }
+ Expect.isTrue(threw_exception);
+ Expect.isTrue(tempDirectory.existsSync());
- // Delete the file, and then delete the directory.
- file.delete();
- };
+ // Delete the file, and then delete the directory.
file.deleteHandler = () {
tempDirectory.deleteSync();
Expect.isFalse(tempDirectory.existsSync());
};
+ file.delete();
};
- file.open(writable: true);
+ file.exists();
};
file.create();
};
tempDirectory.createTemp();
}
- static void testNestedTempDirectory() {
- var test = new NestedTempDirectoryTest();
- }
-
-
static void testMain() {
testListing();
testExistsCreateDelete();
+ testExistsCreateDeleteSync();
testCreateTemp();
- testNestedTempDirectory();
+ testCreateDeleteTemp();
}
}
@@ -206,7 +224,13 @@ class NestedTempDirectoryTest {
List<Directory> createdDirectories;
Directory current;
- NestedTempDirectoryTest(): createdDirectories = new List<Directory>();
+ NestedTempDirectoryTest.run()
+ : createdDirectories = new List<Directory>(),
+ current = new Directory("") {
+ current.createTempHandler = createPhaseCallback;
+ current.errorHandler = errorCallback;
+ current.createTemp();
+ }
void errorCallback(error) {
Expect.fail("Error callback called in NestedTempDirectoryTest: $error");
@@ -236,16 +260,9 @@ class NestedTempDirectoryTest {
}
}
- void startTest() {
- current = new Directory("");
- current.createTempHandler = createPhaseCallback;
- current.errorHandler = errorCallback;
- current.createTemp();
- }
-
static void testMain() {
- new NestedTempDirectoryTest().startTest();
- new NestedTempDirectoryTest().startTest();
+ new NestedTempDirectoryTest.run();
+ new NestedTempDirectoryTest.run();
}
}
« runtime/bin/directory.dart ('K') | « runtime/bin/directory_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698