OLD | NEW |
1 // Copyright (c) 2012, 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:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 Expect.isTrue(error is FileSystemException); | 588 Expect.isTrue(error is FileSystemException); |
589 temp.delete(recursive: true).then((_) { | 589 temp.delete(recursive: true).then((_) { |
590 asyncEnd(); | 590 asyncEnd(); |
591 }); | 591 }); |
592 }); | 592 }); |
593 }); | 593 }); |
594 }); | 594 }); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 testCreateRecursiveSync() { | |
599 var temp = Directory.systemTemp.createTempSync('directory_test'); | |
600 var d = new Directory('${temp.path}/a/b/c'); | |
601 d.createSync(recursive: true); | |
602 Expect.isTrue(new Directory('${temp.path}/a').existsSync()); | |
603 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync()); | |
604 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync()); | |
605 temp.deleteSync(recursive: true); | |
606 } | |
607 | |
608 | |
609 testCreateRecursive() { | |
610 asyncStart(); | |
611 Directory.systemTemp.createTemp('dart_directory').then((temp) { | |
612 var d = new Directory('${temp.path}/a/b/c'); | |
613 d.create(recursive: true).then((_) { | |
614 Expect.isTrue(new Directory('${temp.path}/a').existsSync()); | |
615 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync()); | |
616 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync()); | |
617 temp.deleteSync(recursive: true); | |
618 asyncEnd(); | |
619 }); | |
620 }); | |
621 } | |
622 | |
623 | |
624 testRename() { | 598 testRename() { |
625 var temp1 = Directory.systemTemp.createTempSync('directory_test'); | 599 var temp1 = Directory.systemTemp.createTempSync('directory_test'); |
626 var temp2 = Directory.systemTemp.createTempSync('directory_test'); | 600 var temp2 = Directory.systemTemp.createTempSync('directory_test'); |
627 var temp3 = temp1.renameSync(temp2.path); | 601 var temp3 = temp1.renameSync(temp2.path); |
628 Expect.isFalse(temp1.existsSync()); | 602 Expect.isFalse(temp1.existsSync()); |
629 Expect.isTrue(temp2.existsSync()); | 603 Expect.isTrue(temp2.existsSync()); |
630 Expect.equals(temp3.path, temp2.path); | 604 Expect.equals(temp3.path, temp2.path); |
631 | 605 |
632 temp2.rename(temp1.path).then((temp4) { | 606 temp2.rename(temp1.path).then((temp4) { |
633 Expect.isFalse(temp3.existsSync()); | 607 Expect.isFalse(temp3.existsSync()); |
634 Expect.isFalse(temp2.existsSync()); | 608 Expect.isFalse(temp2.existsSync()); |
635 Expect.isTrue(temp1.existsSync()); | 609 Expect.isTrue(temp1.existsSync()); |
636 Expect.isTrue(temp4.existsSync()); | 610 Expect.isTrue(temp4.existsSync()); |
637 Expect.equals(temp1.path, temp4.path); | 611 Expect.equals(temp1.path, temp4.path); |
638 temp1.deleteSync(recursive: true); | 612 temp1.deleteSync(recursive: true); |
639 }); | 613 }); |
640 } | 614 } |
641 | 615 |
642 main() { | 616 main() { |
643 DirectoryTest.testMain(); | 617 DirectoryTest.testMain(); |
644 NestedTempDirectoryTest.testMain(); | 618 NestedTempDirectoryTest.testMain(); |
645 testCreateTempErrorSync(); | 619 testCreateTempErrorSync(); |
646 testCreateTempError(); | 620 testCreateTempError(); |
647 testCreateExistingSync(); | 621 testCreateExistingSync(); |
648 testCreateExisting(); | 622 testCreateExisting(); |
649 testCreateDirExistingFileSync(); | 623 testCreateDirExistingFileSync(); |
650 testCreateDirExistingFile(); | 624 testCreateDirExistingFile(); |
651 testCreateRecursive(); | |
652 testCreateRecursiveSync(); | |
653 testRename(); | 625 testRename(); |
654 } | 626 } |
OLD | NEW |