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

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

Issue 8934004: Add support for getting OS error information for creating temporary directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated test 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_posix.cc ('K') | « runtime/bin/directory_win.cc ('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 f4de9f09be1faa8e4e25ec4fb7a0324b465e4281..59d45e3e03eca8b15eaefb534952a9468073b01d 100644
--- a/tests/standalone/src/DirectoryTest.dart
+++ b/tests/standalone/src/DirectoryTest.dart
@@ -172,7 +172,7 @@ class DirectoryTest {
}
Expect.isTrue(threw_exception);
Expect.isTrue(tempDirectory.existsSync());
-
+
// Delete the file, and then delete the directory.
file.delete();
};
@@ -244,11 +244,56 @@ class NestedTempDirectoryTest {
static void testMain() {
new NestedTempDirectoryTest().startTest();
new NestedTempDirectoryTest().startTest();
- }
+ }
+}
+
+
+String illegalTempDirectoryLocation() {
+ // Determine a platform specific illegal location for a temporary directory.
+ var os = new Platform().operatingSystem();
+ if (os == "linux" || os == "macos") {
+ return "/dev/zero/";
+ }
+ if (os == "windows") {
+ return "*";
+ }
+ return null;
+}
+
+
+testCreateTempErrorSync() {
+ var location = illegalTempDirectoryLocation();
+ if (location != null) {
Bill Hesse 2011/12/13 13:51:03 Should we use expect.throws() here, instead of wri
Søren Gjesse 2011/12/13 14:07:40 Yes, done. I didn't know that existed.
+ bool exceptionCaught = false;
+ try {
+ new Directory(location).createTempSync();
+ } catch (DirectoryException e) {
+ exceptionCaught = true;
+ }
+ Expect.isTrue(exceptionCaught);
+ }
+}
+
+
+testCreateTempError() {
+ var location = illegalTempDirectoryLocation();
+ if (location == null) return;
+
+ var resultPort = new ReceivePort.singleShot();
+ resultPort.receive((String message, ignored) {
+ Expect.equals("error", message);
+ });
+
+ Directory dir = new Directory(location);
+ dir.errorHandler = (error) { resultPort.toSendPort().send("error"); };
+ dir.createTempHandler = () { resultPort.toSendPort().send("success"); };
+ dir.createTemp();
}
main() {
DirectoryTest.testMain();
NestedTempDirectoryTest.testMain();
+ testCreateTempErrorSync();
+ testCreateTempError();
}
« runtime/bin/directory_posix.cc ('K') | « runtime/bin/directory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698