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 // Testing file input stream, VM-only, standalone test. | 4 // Testing file input stream, VM-only, standalone test. |
5 | 5 |
6 #import("dart:io"); | 6 #import("dart:io"); |
7 #import("dart:isolate"); | 7 #import("dart:isolate"); |
8 | 8 |
9 void testOpenOutputStreamSync() { | 9 void testOpenOutputStreamSync() { |
10 Directory tempDirectory = new Directory(''); | 10 Directory tempDirectory = new Directory(''); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 openedFile.closeSync(); | 64 openedFile.closeSync(); |
65 fileSync.deleteSync(); | 65 fileSync.deleteSync(); |
66 done.toSendPort().send("done"); | 66 done.toSendPort().send("done"); |
67 }; | 67 }; |
68 }; | 68 }; |
69 }); | 69 }); |
70 }); | 70 }); |
71 } | 71 } |
72 | 72 |
73 | 73 |
| 74 void testOutputStreamFlush() { |
| 75 Directory tempDirectory = new Directory(''); |
| 76 |
| 77 // Create a port for waiting on the final result of this test. |
| 78 ReceivePort done = new ReceivePort(); |
| 79 done.receive((message, replyTo) { |
| 80 tempDirectory.deleteSync(); |
| 81 done.close(); |
| 82 }); |
| 83 |
| 84 tempDirectory.createTempSync(); |
| 85 String fileName = "${tempDirectory.path}/test"; |
| 86 File file = new File(fileName); |
| 87 file.createSync(); |
| 88 OutputStream x = file.openOutputStream(); |
| 89 x.write([65, 66, 67]); |
| 90 x.flush(); |
| 91 x.write([68, 69, 70]); |
| 92 x.flush(); |
| 93 x.write([71, 72, 73]); |
| 94 x.close(); |
| 95 x.onClosed = () { |
| 96 file.deleteSync(); |
| 97 done.toSendPort().send("done"); |
| 98 }; |
| 99 } |
| 100 |
| 101 |
74 main() { | 102 main() { |
75 testOpenOutputStreamSync(); | 103 testOpenOutputStreamSync(); |
76 testOutputStreamNoPendingWrite(); | 104 testOutputStreamNoPendingWrite(); |
| 105 testOutputStreamFlush(); |
77 } | 106 } |
OLD | NEW |