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 #import("dart:io"); | 5 #import("dart:io"); |
6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
7 | 7 |
8 void test1() { | 8 void test1() { |
9 void testWithChunkSize(var data, int chunkSize, Function testDone) { | 9 void testWithChunkSize(var data, int chunkSize, Function testDone) { |
10 InputStream list_input_stream = new ListInputStream(); | 10 InputStream list_input_stream = new ListInputStream(); |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 chunkCount++; | 32 chunkCount++; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 void closeHandler() { | 36 void closeHandler() { |
37 Expect.equals(data.length, byteCount); | 37 Expect.equals(data.length, byteCount); |
38 testDone(byteCount); | 38 testDone(byteCount); |
39 } | 39 } |
40 | 40 |
41 stream.dataHandler = chunkData; | 41 stream.onData = chunkData; |
42 stream.closeHandler = closeHandler; | 42 stream.onClosed = closeHandler; |
43 stream.chunkSize = chunkSize; | 43 stream.chunkSize = chunkSize; |
44 } | 44 } |
45 | 45 |
46 for (int i = 1; i <= 10; i++) { | 46 for (int i = 1; i <= 10; i++) { |
47 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 47 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
48 | 48 |
49 void testDone(int byteCount) { | 49 void testDone(int byteCount) { |
50 Expect.equals(data.length, byteCount); | 50 Expect.equals(data.length, byteCount); |
51 } | 51 } |
52 | 52 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 Expect.equals(null, chunk); | 117 Expect.equals(null, chunk); |
118 stage++; | 118 stage++; |
119 donePort.toSendPort().send(stage); | 119 donePort.toSendPort().send(stage); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 void streamClosed() { | 123 void streamClosed() { |
124 Expect.equals(5, stage); | 124 Expect.equals(5, stage); |
125 } | 125 } |
126 | 126 |
127 stream.dataHandler = chunkData; | 127 stream.onData = chunkData; |
128 stream.closeHandler = streamClosed; | 128 stream.onClosed = streamClosed; |
129 s.write([0, 1, 2, 3]); // 4 bytes written to stream. | 129 s.write([0, 1, 2, 3]); // 4 bytes written to stream. |
130 Expect.equals(0, stage); | 130 Expect.equals(0, stage); |
131 s.write([4, 5, 6]); // 7 bytes written to stream. | 131 s.write([4, 5, 6]); // 7 bytes written to stream. |
132 | 132 |
133 donePort.receive((x,y) => donePort.close()); | 133 donePort.receive((x,y) => donePort.close()); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 main() { | 137 main() { |
138 test1(); | 138 test1(); |
139 test2(); | 139 test2(); |
140 } | 140 } |
OLD | NEW |