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

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

Issue 10351011: Change Platform members to getters instead of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new test binaries Created 8 years, 7 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
« no previous file with comments | « tests/standalone/io/file_error_test.dart ('k') | tests/standalone/io/platform_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import('dart:io'); 5 #import('dart:io');
6 6
7 7
8 createLink(String dst, String link, bool symbolic, void callback()) { 8 createLink(String dst, String link, bool symbolic, void callback()) {
9 var args = [ symbolic ? '-s' : '', dst, link ]; 9 var args = [ symbolic ? '-s' : '', dst, link ];
10 var script = 'tests/standalone/io/ln.sh'; 10 var script = 'tests/standalone/io/ln.sh';
11 if (!new File(script).existsSync()) { 11 if (!new File(script).existsSync()) {
12 script = '../$script'; 12 script = '../$script';
13 } 13 }
14 new Process.run(script, args, null, (exit, out, err) { 14 new Process.run(script, args, null, (exit, out, err) {
15 if (exit == 0) { 15 if (exit == 0) {
16 callback(); 16 callback();
17 } else { 17 } else {
18 throw new Exception('link creation failed'); 18 throw new Exception('link creation failed');
19 } 19 }
20 }); 20 });
21 } 21 }
22 22
23 23
24 testFileExistsCreate() { 24 testFileExistsCreate() {
25 var temp = new Directory(''); 25 var temp = new Directory('');
26 temp.createTempSync(); 26 temp.createTempSync();
27 var x = '${temp.path}${Platform.pathSeparator()}x'; 27 var x = '${temp.path}${Platform.pathSeparator}x';
28 var y = '${temp.path}${Platform.pathSeparator()}y'; 28 var y = '${temp.path}${Platform.pathSeparator}y';
29 createLink(x, y, true, () { 29 createLink(x, y, true, () {
30 Expect.isFalse(new File(x).existsSync()); 30 Expect.isFalse(new File(x).existsSync());
31 Expect.isFalse(new File(y).existsSync()); 31 Expect.isFalse(new File(y).existsSync());
32 new File(y).createSync(); 32 new File(y).createSync();
33 Expect.isTrue(new File(x).existsSync()); 33 Expect.isTrue(new File(x).existsSync());
34 Expect.isTrue(new File(y).existsSync()); 34 Expect.isTrue(new File(y).existsSync());
35 temp.deleteRecursivelySync(); 35 temp.deleteRecursivelySync();
36 }); 36 });
37 } 37 }
38 38
39 39
40 testFileDelete() { 40 testFileDelete() {
41 var temp = new Directory(''); 41 var temp = new Directory('');
42 temp.createTempSync(); 42 temp.createTempSync();
43 var x = '${temp.path}${Platform.pathSeparator()}x'; 43 var x = '${temp.path}${Platform.pathSeparator}x';
44 var y = '${temp.path}${Platform.pathSeparator()}y'; 44 var y = '${temp.path}${Platform.pathSeparator}y';
45 new File(x).createSync(); 45 new File(x).createSync();
46 createLink(x, y, true, () { 46 createLink(x, y, true, () {
47 Expect.isTrue(new File(x).existsSync()); 47 Expect.isTrue(new File(x).existsSync());
48 Expect.isTrue(new File(y).existsSync()); 48 Expect.isTrue(new File(y).existsSync());
49 new File(y).deleteSync(); 49 new File(y).deleteSync();
50 Expect.isTrue(new File(x).existsSync()); 50 Expect.isTrue(new File(x).existsSync());
51 Expect.isFalse(new File(y).existsSync()); 51 Expect.isFalse(new File(y).existsSync());
52 createLink(x, y, false, () { 52 createLink(x, y, false, () {
53 Expect.isTrue(new File(x).existsSync()); 53 Expect.isTrue(new File(x).existsSync());
54 Expect.isTrue(new File(y).existsSync()); 54 Expect.isTrue(new File(y).existsSync());
55 new File(y).deleteSync(); 55 new File(y).deleteSync();
56 Expect.isTrue(new File(x).existsSync()); 56 Expect.isTrue(new File(x).existsSync());
57 Expect.isFalse(new File(y).existsSync()); 57 Expect.isFalse(new File(y).existsSync());
58 temp.deleteRecursivelySync(); 58 temp.deleteRecursivelySync();
59 }); 59 });
60 }); 60 });
61 } 61 }
62 62
63 63
64 testFileWriteRead() { 64 testFileWriteRead() {
65 var temp = new Directory(''); 65 var temp = new Directory('');
66 temp.createTempSync(); 66 temp.createTempSync();
67 var x = '${temp.path}${Platform.pathSeparator()}x'; 67 var x = '${temp.path}${Platform.pathSeparator}x';
68 var y = '${temp.path}${Platform.pathSeparator()}y'; 68 var y = '${temp.path}${Platform.pathSeparator}y';
69 new File(x).createSync(); 69 new File(x).createSync();
70 createLink(x, y, true, () { 70 createLink(x, y, true, () {
71 var data = "asdf".charCodes(); 71 var data = "asdf".charCodes();
72 var output = new File(y).openOutputStream(FileMode.WRITE); 72 var output = new File(y).openOutputStream(FileMode.WRITE);
73 output.write(data); 73 output.write(data);
74 output.onNoPendingWrites = () { 74 output.onNoPendingWrites = () {
75 output.close(); 75 output.close();
76 var read = new File(y).readAsBytesSync(); 76 var read = new File(y).readAsBytesSync();
77 Expect.listEquals(data, read); 77 Expect.listEquals(data, read);
78 var read2 = new File(x).readAsBytesSync(); 78 var read2 = new File(x).readAsBytesSync();
79 Expect.listEquals(data, read2); 79 Expect.listEquals(data, read2);
80 temp.deleteRecursivelySync(); 80 temp.deleteRecursivelySync();
81 }; 81 };
82 }); 82 });
83 } 83 }
84 84
85 85
86 testDirectoryExistsCreate() { 86 testDirectoryExistsCreate() {
87 var temp = new Directory(''); 87 var temp = new Directory('');
88 temp.createTempSync(); 88 temp.createTempSync();
89 var x = '${temp.path}${Platform.pathSeparator()}x'; 89 var x = '${temp.path}${Platform.pathSeparator}x';
90 var y = '${temp.path}${Platform.pathSeparator()}y'; 90 var y = '${temp.path}${Platform.pathSeparator}y';
91 createLink(x, y, true, () { 91 createLink(x, y, true, () {
92 Expect.isFalse(new Directory(x).existsSync()); 92 Expect.isFalse(new Directory(x).existsSync());
93 Expect.isFalse(new Directory(y).existsSync()); 93 Expect.isFalse(new Directory(y).existsSync());
94 Expect.throws(new Directory(y).createSync); 94 Expect.throws(new Directory(y).createSync);
95 temp.deleteRecursivelySync(); 95 temp.deleteRecursivelySync();
96 }); 96 });
97 } 97 }
98 98
99 99
100 testDirectoryDelete() { 100 testDirectoryDelete() {
101 var temp = new Directory(''); 101 var temp = new Directory('');
102 temp.createTempSync(); 102 temp.createTempSync();
103 var temp2 = new Directory(''); 103 var temp2 = new Directory('');
104 temp2.createTempSync(); 104 temp2.createTempSync();
105 var y = '${temp.path}${Platform.pathSeparator()}y'; 105 var y = '${temp.path}${Platform.pathSeparator}y';
106 var x = '${temp2.path}${Platform.pathSeparator()}x'; 106 var x = '${temp2.path}${Platform.pathSeparator}x';
107 new File(x).createSync(); 107 new File(x).createSync();
108 createLink(temp2.path, y, true, () { 108 createLink(temp2.path, y, true, () {
109 var link = new Directory(y); 109 var link = new Directory(y);
110 Expect.isTrue(link.existsSync()); 110 Expect.isTrue(link.existsSync());
111 Expect.isTrue(temp2.existsSync()); 111 Expect.isTrue(temp2.existsSync());
112 link.deleteSync(); 112 link.deleteSync();
113 Expect.isFalse(link.existsSync()); 113 Expect.isFalse(link.existsSync());
114 Expect.isTrue(temp2.existsSync()); 114 Expect.isTrue(temp2.existsSync());
115 createLink(temp2.path, y, true, () { 115 createLink(temp2.path, y, true, () {
116 Expect.isTrue(link.existsSync()); 116 Expect.isTrue(link.existsSync());
117 temp.deleteRecursivelySync(); 117 temp.deleteRecursivelySync();
118 Expect.isFalse(link.existsSync()); 118 Expect.isFalse(link.existsSync());
119 Expect.isTrue(temp2.existsSync()); 119 Expect.isTrue(temp2.existsSync());
120 Expect.isTrue(new File(x).existsSync()); 120 Expect.isTrue(new File(x).existsSync());
121 temp2.deleteRecursivelySync(); 121 temp2.deleteRecursivelySync();
122 }); 122 });
123 }); 123 });
124 } 124 }
125 125
126 126
127 testDirectoryListing() { 127 testDirectoryListing() {
128 var temp = new Directory(''); 128 var temp = new Directory('');
129 temp.createTempSync(); 129 temp.createTempSync();
130 var temp2 = new Directory(''); 130 var temp2 = new Directory('');
131 temp2.createTempSync(); 131 temp2.createTempSync();
132 var y = '${temp.path}${Platform.pathSeparator()}y'; 132 var y = '${temp.path}${Platform.pathSeparator}y';
133 var x = '${temp2.path}${Platform.pathSeparator()}x'; 133 var x = '${temp2.path}${Platform.pathSeparator}x';
134 new File(x).createSync(); 134 new File(x).createSync();
135 createLink(temp2.path, y, true, () { 135 createLink(temp2.path, y, true, () {
136 var files = []; 136 var files = [];
137 var dirs = []; 137 var dirs = [];
138 temp.list(recursive: true); 138 temp.list(recursive: true);
139 temp.onFile = (f) => files.add(f); 139 temp.onFile = (f) => files.add(f);
140 temp.onDir = (d) => dirs.add(d); 140 temp.onDir = (d) => dirs.add(d);
141 temp.onDone = (success) { 141 temp.onDone = (success) {
142 Expect.isTrue(success); 142 Expect.isTrue(success);
143 Expect.equals(1, files.length); 143 Expect.equals(1, files.length);
144 Expect.isTrue(files[0].endsWith(x)); 144 Expect.isTrue(files[0].endsWith(x));
145 Expect.equals(1, dirs.length); 145 Expect.equals(1, dirs.length);
146 Expect.isTrue(dirs[0].endsWith(y)); 146 Expect.isTrue(dirs[0].endsWith(y));
147 temp.deleteRecursivelySync(); 147 temp.deleteRecursivelySync();
148 temp2.deleteRecursivelySync(); 148 temp2.deleteRecursivelySync();
149 }; 149 };
150 }); 150 });
151 } 151 }
152 152
153 153
154 main() { 154 main() {
155 testFileExistsCreate(); 155 testFileExistsCreate();
156 testFileDelete(); 156 testFileDelete();
157 testFileWriteRead(); 157 testFileWriteRead();
158 testDirectoryExistsCreate(); 158 testDirectoryExistsCreate();
159 testDirectoryDelete(); 159 testDirectoryDelete();
160 testDirectoryListing(); 160 testDirectoryListing();
161 } 161 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_error_test.dart ('k') | tests/standalone/io/platform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698