| 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 // Dart test program for testing file I/O. | 5 // Dart test program for testing file I/O. |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 | 9 |
| 10 class MyListOfOneElement implements List { | 10 class MyListOfOneElement implements List { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 static void testOutputStreamWriteAppend() { | 303 static void testOutputStreamWriteAppend() { |
| 304 String content = "foobar"; | 304 String content = "foobar"; |
| 305 String filename = tempDirectory.path + "/outstream_write_append"; | 305 String filename = tempDirectory.path + "/outstream_write_append"; |
| 306 File file = new File(filename); | 306 File file = new File(filename); |
| 307 file.createSync(); | 307 file.createSync(); |
| 308 List<int> buffer = content.charCodes(); | 308 List<int> buffer = content.charCodes(); |
| 309 OutputStream outStream = file.openOutputStream(); | 309 OutputStream outStream = file.openOutputStream(); |
| 310 outStream.write(buffer); | 310 outStream.write(buffer); |
| 311 outStream.onNoPendingWrites = () { | 311 outStream.onNoPendingWrites = () { |
| 312 outStream.close(); | 312 outStream.close(); |
| 313 File file2 = new File(filename); | 313 outStream.onClosed = () { |
| 314 OutputStream appendingOutput = | 314 File file2 = new File(filename); |
| 315 file2.openOutputStream(FileMode.APPEND); | 315 OutputStream appendingOutput = |
| 316 appendingOutput.write(buffer); | 316 file2.openOutputStream(FileMode.APPEND); |
| 317 appendingOutput.onNoPendingWrites = () { | 317 appendingOutput.write(buffer); |
| 318 appendingOutput.close(); | 318 appendingOutput.onNoPendingWrites = () { |
| 319 File file3 = new File(filename); | 319 appendingOutput.close(); |
| 320 file3.open(FileMode.READ, (RandomAccessFile openedFile) { | 320 appendingOutput.onClosed = () { |
| 321 openedFile.length((int length) { | 321 File file3 = new File(filename); |
| 322 Expect.equals(content.length * 2, length); | 322 file3.open(FileMode.READ, (RandomAccessFile openedFile) { |
| 323 openedFile.close(() { | 323 openedFile.length((int length) { |
| 324 file3.delete(() { | 324 Expect.equals(content.length * 2, length); |
| 325 asyncTestDone("testOutputStreamWriteAppend"); | 325 openedFile.close(() { |
| 326 file3.delete(() { |
| 327 asyncTestDone("testOutputStreamWriteAppend"); |
| 328 }); |
| 329 }); |
| 326 }); | 330 }); |
| 327 }); | 331 }); |
| 328 }); | 332 }; |
| 329 }); | 333 }; |
| 330 }; | 334 }; |
| 331 }; | 335 }; |
| 332 asyncTestStarted(); | 336 asyncTestStarted(); |
| 333 } | 337 } |
| 334 | 338 |
| 335 // Test for file read and write functionality. | 339 // Test for file read and write functionality. |
| 336 static void testOutputStreamWriteString() { | 340 static void testOutputStreamWriteString() { |
| 337 String content = "foobar"; | 341 String content = "foobar"; |
| 338 String filename = tempDirectory.path + "/outstream_write_string"; | 342 String filename = tempDirectory.path + "/outstream_write_string"; |
| 339 File file = new File(filename); | 343 File file = new File(filename); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 testWriteVariousLists(); | 1083 testWriteVariousLists(); |
| 1080 testDirectory(); | 1084 testDirectory(); |
| 1081 testDirectorySync(); | 1085 testDirectorySync(); |
| 1082 }); | 1086 }); |
| 1083 } | 1087 } |
| 1084 } | 1088 } |
| 1085 | 1089 |
| 1086 main() { | 1090 main() { |
| 1087 FileTest.testMain(); | 1091 FileTest.testMain(); |
| 1088 } | 1092 } |
| OLD | NEW |