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('').createTempSync(); | 10 Directory tempDirectory = new Directory('').createTempSync(); |
(...skipping 20 matching lines...) Expand all Loading... |
31 }; | 31 }; |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 void testOutputStreamNoPendingWrite() { | 35 void testOutputStreamNoPendingWrite() { |
36 var tempDirectory; | 36 var tempDirectory; |
37 | 37 |
38 // Create a port for waiting on the final result of this test. | 38 // Create a port for waiting on the final result of this test. |
39 ReceivePort done = new ReceivePort(); | 39 ReceivePort done = new ReceivePort(); |
40 done.receive((message, replyTo) { | 40 done.receive((message, replyTo) { |
41 tempDirectory.deleteRecursively().then((ignore) => done.close()); | 41 tempDirectory.delete(recursive: true).then((ignore) => done.close()); |
42 }); | 42 }); |
43 | 43 |
44 new Directory('').createTemp().then((temp) { | 44 new Directory('').createTemp().then((temp) { |
45 tempDirectory = temp; | 45 tempDirectory = temp; |
46 String fileName = "${tempDirectory.path}/test"; | 46 String fileName = "${tempDirectory.path}/test"; |
47 File file = new File(fileName); | 47 File file = new File(fileName); |
48 file.create().then((ignore) { | 48 file.create().then((ignore) { |
49 OutputStream stream = file.openOutputStream(); | 49 OutputStream stream = file.openOutputStream(); |
50 final total = 100; | 50 final total = 100; |
51 var count = 0; | 51 var count = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 }; | 97 }; |
98 x.close(); | 98 x.close(); |
99 x.onError = (e) => Expect.fail("No error expected"); | 99 x.onError = (e) => Expect.fail("No error expected"); |
100 } | 100 } |
101 | 101 |
102 main() { | 102 main() { |
103 testOpenOutputStreamSync(); | 103 testOpenOutputStreamSync(); |
104 testOutputStreamNoPendingWrite(); | 104 testOutputStreamNoPendingWrite(); |
105 testOutputStreamFlush(); | 105 testOutputStreamFlush(); |
106 } | 106 } |
OLD | NEW |