Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #import("dart:io"); | 7 #import("dart:io"); |
| 8 | 8 |
| 9 class DirectoryTest { | 9 class DirectoryTest { |
| 10 static void testListing() { | 10 static void testListing() { |
| 11 bool listedDir = false; | 11 bool listedDir = false; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 28 directory.fileHandler = (f) { | 28 directory.fileHandler = (f) { |
| 29 listedFile = true; | 29 listedFile = true; |
| 30 Expect.isTrue(f.contains('subdir')); | 30 Expect.isTrue(f.contains('subdir')); |
| 31 Expect.isTrue(f.contains('file.txt')); | 31 Expect.isTrue(f.contains('file.txt')); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 directory.doneHandler = (completed) { | 34 directory.doneHandler = (completed) { |
| 35 Expect.isTrue(completed, "directory listing did not complete"); | 35 Expect.isTrue(completed, "directory listing did not complete"); |
| 36 Expect.isTrue(listedDir, "directory not found"); | 36 Expect.isTrue(listedDir, "directory not found"); |
| 37 Expect.isTrue(listedFile, "file not found"); | 37 Expect.isTrue(listedFile, "file not found"); |
| 38 f.deleteHandler = () { | 38 directory.delete(recursive: true); |
|
Bill Hesse
2012/02/02 17:24:39
I think we need some major tests for the new recur
Mads Ager (google)
2012/02/03 11:48:54
I have added some more tests. It is hard to do mor
| |
| 39 // TODO(ager): use async directory deletion API when available. | 39 directory.deleteHandler = () { |
| 40 subDirectory.deleteSync(); | 40 f.exists(); |
| 41 directory.deleteSync(); | 41 f.existsHandler = (exists) => Expect.isFalse(exists); |
| 42 directory.exists(); | |
| 43 directory.existsHandler = (exists) => Expect.isFalse(exists); | |
| 44 subDirectory.exists(); | |
| 45 subDirectory.existsHandler = (exists) => Expect.isFalse(exists); | |
| 42 }; | 46 }; |
| 43 f.delete(); | |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 directory.errorHandler = (error) { | 49 directory.errorHandler = (error) { |
| 47 Expect.fail("error listing directory: $error"); | 50 Expect.fail("error listing directory: $error"); |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 directory.list(recursive: true); | 53 directory.list(recursive: true); |
| 51 | 54 |
| 52 // Listing is asynchronous, so nothing should be listed at this | 55 // Listing is asynchronous, so nothing should be listed at this |
| 53 // point. | 56 // point. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 dir.createTemp(); | 302 dir.createTemp(); |
| 300 } | 303 } |
| 301 | 304 |
| 302 | 305 |
| 303 main() { | 306 main() { |
| 304 DirectoryTest.testMain(); | 307 DirectoryTest.testMain(); |
| 305 NestedTempDirectoryTest.testMain(); | 308 NestedTempDirectoryTest.testMain(); |
| 306 testCreateTempErrorSync(); | 309 testCreateTempErrorSync(); |
| 307 testCreateTempError(); | 310 testCreateTempError(); |
| 308 } | 311 } |
| OLD | NEW |