| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Directory listing test. | 5 // Directory listing test. |
| 6 | 6 |
| 7 class DirectoryTest { | 7 class DirectoryTest { |
| 8 static void testListing() { | 8 static void testListing() { |
| 9 bool listedDir = false; | 9 bool listedDir = false; |
| 10 bool listedFile = false; | 10 bool listedFile = false; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (os == "windows") { | 257 if (os == "windows") { |
| 258 return "*"; | 258 return "*"; |
| 259 } | 259 } |
| 260 return null; | 260 return null; |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 testCreateTempErrorSync() { | 264 testCreateTempErrorSync() { |
| 265 var location = illegalTempDirectoryLocation(); | 265 var location = illegalTempDirectoryLocation(); |
| 266 if (location != null) { | 266 if (location != null) { |
| 267 bool exception = false; | 267 Expect.throws(new Directory(location).createTempSync, |
| 268 try { | 268 (e) => e is DirectoryException); |
| 269 new Directory(location).createTempSync(); | |
| 270 } catch(DirectoryException e) { | |
| 271 exception = true; | |
| 272 } | |
| 273 Expect.isTrue(exception); | |
| 274 } | 269 } |
| 275 } | 270 } |
| 276 | 271 |
| 277 | 272 |
| 278 testCreateTempError() { | 273 testCreateTempError() { |
| 279 var location = illegalTempDirectoryLocation(); | 274 var location = illegalTempDirectoryLocation(); |
| 280 if (location == null) return; | 275 if (location == null) return; |
| 281 | 276 |
| 282 var resultPort = new ReceivePort.singleShot(); | 277 var resultPort = new ReceivePort.singleShot(); |
| 283 resultPort.receive((String message, ignored) { | 278 resultPort.receive((String message, ignored) { |
| 284 Expect.equals("error", message); | 279 Expect.equals("error", message); |
| 285 }); | 280 }); |
| 286 | 281 |
| 287 Directory dir = new Directory(location); | 282 Directory dir = new Directory(location); |
| 288 dir.errorHandler = (error) { resultPort.toSendPort().send("error"); }; | 283 dir.errorHandler = (error) { resultPort.toSendPort().send("error"); }; |
| 289 dir.createTempHandler = () { resultPort.toSendPort().send("success"); }; | 284 dir.createTempHandler = () { resultPort.toSendPort().send("success"); }; |
| 290 dir.createTemp(); | 285 dir.createTemp(); |
| 291 } | 286 } |
| 292 | 287 |
| 293 | 288 |
| 294 main() { | 289 main() { |
| 295 DirectoryTest.testMain(); | 290 DirectoryTest.testMain(); |
| 296 NestedTempDirectoryTest.testMain(); | 291 NestedTempDirectoryTest.testMain(); |
| 297 testCreateTempErrorSync(); | 292 testCreateTempErrorSync(); |
| 298 testCreateTempError(); | 293 testCreateTempError(); |
| 299 } | 294 } |
| OLD | NEW |