Chromium Code Reviews| 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(); |
| } |