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

Side by Side Diff: tests/standalone/io/directory_test.dart

Issue 12314153: dart:io | Rename File.name to File.path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove stray line break. Created 7 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import "dart:isolate"; 9 import "dart:isolate";
10 10
11 class DirectoryTest { 11 class DirectoryTest {
12 static void testListing() { 12 static void testListing() {
13 bool listedDir = false; 13 bool listedDir = false;
14 bool listedFile = false; 14 bool listedFile = false;
15 15
16 Directory directory = new Directory("").createTempSync(); 16 Directory directory = new Directory("").createTempSync();
17 Directory subDirectory = new Directory("${directory.path}/subdir"); 17 Directory subDirectory = new Directory("${directory.path}/subdir");
18 Expect.isTrue('$directory'.contains(directory.path)); 18 Expect.isTrue('$directory'.contains(directory.path));
19 Expect.isFalse(subDirectory.existsSync()); 19 Expect.isFalse(subDirectory.existsSync());
20 subDirectory.createSync(); 20 subDirectory.createSync();
21 Expect.isTrue(subDirectory.existsSync()); 21 Expect.isTrue(subDirectory.existsSync());
22 File f = new File('${subDirectory.path}/file.txt'); 22 File f = new File('${subDirectory.path}/file.txt');
23 File fLong = new File('${directory.path}/subdir/../subdir/file.txt'); 23 File fLong = new File('${directory.path}/subdir/../subdir/file.txt');
24 Expect.isFalse(f.existsSync()); 24 Expect.isFalse(f.existsSync());
25 f.createSync(); 25 f.createSync();
26 26
27 void testSyncListing(bool recursive) { 27 void testSyncListing(bool recursive) {
28 for (var entry in directory.listSync(recursive: recursive)) { 28 for (var entry in directory.listSync(recursive: recursive)) {
29 if (entry is File) { 29 if (entry is File) {
30 Expect.isTrue(entry.name.contains(directory.path)); 30 Expect.isTrue(entry.path.contains(directory.path));
31 Expect.isTrue(entry.name.contains('subdir')); 31 Expect.isTrue(entry.path.contains('subdir'));
32 Expect.isTrue(entry.name.contains('file.txt')); 32 Expect.isTrue(entry.path.contains('file.txt'));
33 Expect.isFalse(listedFile); 33 Expect.isFalse(listedFile);
34 listedFile = true; 34 listedFile = true;
35 } else { 35 } else {
36 Expect.isTrue(entry is Directory); 36 Expect.isTrue(entry is Directory);
37 Expect.isTrue(entry.path.contains(directory.path)); 37 Expect.isTrue(entry.path.contains(directory.path));
38 Expect.isTrue(entry.path.contains('subdir')); 38 Expect.isTrue(entry.path.contains('subdir'));
39 Expect.isFalse(listedDir); 39 Expect.isFalse(listedDir);
40 listedDir = true; 40 listedDir = true;
41 } 41 }
42 } 42 }
43 Expect.equals(listedFile, recursive); 43 Expect.equals(listedFile, recursive);
44 Expect.isTrue(listedDir); 44 Expect.isTrue(listedDir);
45 listedFile = false; 45 listedFile = false;
46 listedDir = false; 46 listedDir = false;
47 } 47 }
48 48
49 testSyncListing(true); 49 testSyncListing(true);
50 testSyncListing(false); 50 testSyncListing(false);
51 Expect.equals(f.fullPathSync(), fLong.fullPathSync()); 51 Expect.equals(f.fullPathSync(), fLong.fullPathSync());
52 52
53 var listingDonePort = new ReceivePort(); 53 var listingDonePort = new ReceivePort();
54 directory.list(recursive: true).listen( 54 directory.list(recursive: true).listen(
55 (FileSystemEntity entity) { 55 (FileSystemEntity entity) {
56 if (entity is File) { 56 if (entity is File) {
57 var path = entity.name; 57 var path = entity.path;
58 listedFile = true; 58 listedFile = true;
59 Expect.isTrue(path.contains(directory.path)); 59 Expect.isTrue(path.contains(directory.path));
60 Expect.isTrue(path.contains('subdir')); 60 Expect.isTrue(path.contains('subdir'));
61 Expect.isTrue(path.contains('file.txt')); 61 Expect.isTrue(path.contains('file.txt'));
62 } else { 62 } else {
63 var path = entity.path; 63 var path = entity.path;
64 Expect.isTrue(entity is Directory); 64 Expect.isTrue(entity is Directory);
65 listedDir = true; 65 listedDir = true;
66 Expect.isTrue(path.contains(directory.path)); 66 Expect.isTrue(path.contains(directory.path));
67 Expect.isTrue(path.contains('subdir')); 67 Expect.isTrue(path.contains('subdir'));
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 testCreateTempErrorSync(); 519 testCreateTempErrorSync();
520 testCreateTempError(); 520 testCreateTempError();
521 testCreateExistingSync(); 521 testCreateExistingSync();
522 testCreateExisting(); 522 testCreateExisting();
523 testCreateDirExistingFileSync(); 523 testCreateDirExistingFileSync();
524 testCreateDirExistingFile(); 524 testCreateDirExistingFile();
525 testCreateRecursive(); 525 testCreateRecursive();
526 testCreateRecursiveSync(); 526 testCreateRecursiveSync();
527 testRename(); 527 testRename();
528 } 528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698