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

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

Issue 11554021: Update Windows file implementation to use the unicode APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« runtime/bin/file_win.cc ('K') | « runtime/bin/file_win.cc ('k') | no next file » | 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 // Dart test program for testing error handling in file I/O. 5 // Dart test program for testing error handling in file I/O.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 9
10 Directory tempDir() { 10 Directory tempDir() {
11 return new Directory('').createTempSync(); 11 return new Directory('').createTempSync();
12 } 12 }
13 13
14 14
15 bool checkNonExistentFileException(e, str) { 15 bool checkNonExistentFileException(e, str) {
16 Expect.isTrue(e is FileIOException); 16 Expect.isTrue(e is FileIOException);
17 Expect.isTrue(e.osError != null); 17 Expect.isTrue(e.osError != null);
18 Expect.isTrue(e.toString().indexOf(str) != -1); 18 Expect.isTrue(e.toString().indexOf(str) != -1);
19 if (Platform.operatingSystem == "linux") {
20 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
21 } else if (Platform.operatingSystem == "macos") {
22 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
23 } else if (Platform.operatingSystem == "windows") {
24 Expect.isTrue(
25 e.toString().indexOf(
26 "The system cannot find the file specified") != -1);
27 }
28 // File not not found has error code 2 on all supported platforms. 19 // File not not found has error code 2 on all supported platforms.
29 Expect.equals(2, e.osError.errorCode); 20 Expect.equals(2, e.osError.errorCode);
30
31 return true; 21 return true;
32 } 22 }
33 23
34 24
35 bool checkOpenNonExistentFileException(e) { 25 bool checkOpenNonExistentFileException(e) {
36 return checkNonExistentFileException(e, "Cannot open file"); 26 return checkNonExistentFileException(e, "Cannot open file");
37 } 27 }
38 28
39 29
40 bool checkDeleteNonExistentFileException(e) { 30 bool checkDeleteNonExistentFileException(e) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return true; 104 return true;
115 }); 105 });
116 } 106 }
117 107
118 108
119 bool checkCreateInNonExistentDirectoryException(e) { 109 bool checkCreateInNonExistentDirectoryException(e) {
120 Expect.isTrue(e is FileIOException); 110 Expect.isTrue(e is FileIOException);
121 Expect.isTrue(e.osError != null); 111 Expect.isTrue(e.osError != null);
122 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1); 112 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1);
123 if (Platform.operatingSystem == "linux") { 113 if (Platform.operatingSystem == "linux") {
124 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
125 Expect.equals(2, e.osError.errorCode); 114 Expect.equals(2, e.osError.errorCode);
126 } else if (Platform.operatingSystem == "macos") { 115 } else if (Platform.operatingSystem == "macos") {
127 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
128 Expect.equals(2, e.osError.errorCode); 116 Expect.equals(2, e.osError.errorCode);
129 } else if (Platform.operatingSystem == "windows") { 117 } else if (Platform.operatingSystem == "windows") {
130 Expect.isTrue(
131 e.toString().indexOf(
132 "The system cannot find the path specified") != -1);
133 Expect.equals(3, e.osError.errorCode); 118 Expect.equals(3, e.osError.errorCode);
134 } 119 }
135 120
136 return true; 121 return true;
137 } 122 }
138 123
139 void testCreateInNonExistentDirectory() { 124 void testCreateInNonExistentDirectory() {
140 Directory temp = tempDir(); 125 Directory temp = tempDir();
141 ReceivePort p = new ReceivePort(); 126 ReceivePort p = new ReceivePort();
142 p.receive((x, y) { 127 p.receive((x, y) {
(...skipping 12 matching lines...) Expand all
155 checkCreateInNonExistentDirectoryException(e); 140 checkCreateInNonExistentDirectoryException(e);
156 p.toSendPort().send(null); 141 p.toSendPort().send(null);
157 return true; 142 return true;
158 }); 143 });
159 } 144 }
160 145
161 bool checkFullPathOnNonExistentDirectoryException(e) { 146 bool checkFullPathOnNonExistentDirectoryException(e) {
162 Expect.isTrue(e is FileIOException); 147 Expect.isTrue(e is FileIOException);
163 Expect.isTrue(e.osError != null); 148 Expect.isTrue(e.osError != null);
164 Expect.isTrue(e.toString().indexOf("Cannot retrieve full path") != -1); 149 Expect.isTrue(e.toString().indexOf("Cannot retrieve full path") != -1);
165 if (Platform.operatingSystem == "linux") {
166 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
167 } else if (Platform.operatingSystem == "macos") {
168 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
169 } else if (Platform.operatingSystem == "windows") {
170 Expect.isTrue(
171 e.toString().indexOf(
172 "The system cannot find the file specified") != -1);
173 }
174 // File not not found has error code 2 on all supported platforms. 150 // File not not found has error code 2 on all supported platforms.
175 Expect.equals(2, e.osError.errorCode); 151 Expect.equals(2, e.osError.errorCode);
176 152
177 return true; 153 return true;
178 } 154 }
179 155
180 void testFullPathOnNonExistentDirectory() { 156 void testFullPathOnNonExistentDirectory() {
181 Directory temp = tempDir(); 157 Directory temp = tempDir();
182 ReceivePort p = new ReceivePort(); 158 ReceivePort p = new ReceivePort();
183 p.receive((x, y) { 159 p.receive((x, y) {
(...skipping 13 matching lines...) Expand all
197 p.toSendPort().send(null); 173 p.toSendPort().send(null);
198 return true; 174 return true;
199 }); 175 });
200 } 176 }
201 177
202 bool checkDirectoryInNonExistentDirectoryException(e) { 178 bool checkDirectoryInNonExistentDirectoryException(e) {
203 Expect.isTrue(e is FileIOException); 179 Expect.isTrue(e is FileIOException);
204 Expect.isTrue(e.osError != null); 180 Expect.isTrue(e.osError != null);
205 Expect.isTrue( 181 Expect.isTrue(
206 e.toString().indexOf("Cannot retrieve directory for file") != -1); 182 e.toString().indexOf("Cannot retrieve directory for file") != -1);
207 if (Platform.operatingSystem == "linux") {
208 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
209 } else if (Platform.operatingSystem == "macos") {
210 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
211 } else if (Platform.operatingSystem == "windows") {
212 Expect.isTrue(
213 e.toString().indexOf(
214 "The system cannot find the file specified") != -1);
215 }
216 // File not not found has error code 2 on all supported platforms. 183 // File not not found has error code 2 on all supported platforms.
217 Expect.equals(2, e.osError.errorCode); 184 Expect.equals(2, e.osError.errorCode);
218 185
219 return true; 186 return true;
220 } 187 }
221 188
222 void testDirectoryInNonExistentDirectory() { 189 void testDirectoryInNonExistentDirectory() {
223 Directory temp = tempDir(); 190 Directory temp = tempDir();
224 ReceivePort p = new ReceivePort(); 191 ReceivePort p = new ReceivePort();
225 p.receive((x, y) { 192 p.receive((x, y) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 testReadAsBytesNonExistent(); 477 testReadAsBytesNonExistent();
511 testReadAsTextNonExistent(); 478 testReadAsTextNonExistent();
512 testReadAsLinesNonExistent(); 479 testReadAsLinesNonExistent();
513 testWriteByteToReadOnlyFile(); 480 testWriteByteToReadOnlyFile();
514 testWriteListToReadOnlyFile(); 481 testWriteListToReadOnlyFile();
515 testTruncateReadOnlyFile(); 482 testTruncateReadOnlyFile();
516 testOperateOnClosedFile(); 483 testOperateOnClosedFile();
517 testRepeatedlyCloseFile(); 484 testRepeatedlyCloseFile();
518 testRepeatedlyCloseFileSync(); 485 testRepeatedlyCloseFileSync();
519 } 486 }
OLDNEW
« runtime/bin/file_win.cc ('K') | « runtime/bin/file_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698