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

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

Issue 10832145: Add a ListOutputStream.onData callback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months 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
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | tests/standalone/io/list_output_stream_test.dart » ('j') | 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 #import("dart:io"); 5 #import("dart:io");
6 #import("dart:isolate"); 6 #import("dart:isolate");
7 7
8 void testEmptyListInputStream() { 8 void testEmptyListInputStream() {
9 ListInputStream stream = new ListInputStream(); 9 ListInputStream stream = new ListInputStream();
10 stream.write([]); 10 stream.write([]);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 void testListInputStreamPipe1() { 99 void testListInputStreamPipe1() {
100 List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff]; 100 List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
101 ListInputStream input = new ListInputStream(); 101 ListInputStream input = new ListInputStream();
102 input.write(data); 102 input.write(data);
103 input.markEndOfStream(); 103 input.markEndOfStream();
104 ListOutputStream output = new ListOutputStream(); 104 ListOutputStream output = new ListOutputStream();
105 ReceivePort donePort = new ReceivePort(); 105 ReceivePort donePort = new ReceivePort();
106 106
107 void onClosed() { 107 void onClosed() {
108 var contents = output.contents(); 108 var contents = output.read();
109 Expect.equals(data.length, contents.length); 109 Expect.equals(data.length, contents.length);
110 donePort.toSendPort().send(null); 110 donePort.toSendPort().send(null);
111 } 111 }
112 112
113 input.onClosed = onClosed; 113 input.onClosed = onClosed;
114 input.pipe(output); 114 input.pipe(output);
115 115
116 donePort.receive((x,y) => donePort.close()); 116 donePort.receive((x,y) => donePort.close());
117 } 117 }
118 118
119 void testListInputStreamPipe2() { 119 void testListInputStreamPipe2() {
120 List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff]; 120 List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
121 ListOutputStream output = new ListOutputStream(); 121 ListOutputStream output = new ListOutputStream();
122 ReceivePort donePort = new ReceivePort(); 122 ReceivePort donePort = new ReceivePort();
123 int count = 0; 123 int count = 0;
124 124
125 void onClosed() { 125 void onClosed() {
126 if (count < 10) { 126 if (count < 10) {
127 ListInputStream input = new ListInputStream(); 127 ListInputStream input = new ListInputStream();
128 input.write(data); 128 input.write(data);
129 input.markEndOfStream(); 129 input.markEndOfStream();
130 input.onClosed = onClosed; 130 input.onClosed = onClosed;
131 if (count < 9) { 131 if (count < 9) {
132 input.pipe(output, close: false); 132 input.pipe(output, close: false);
133 } else { 133 } else {
134 input.pipe(output); 134 input.pipe(output);
135 } 135 }
136 count++; 136 count++;
137 } else { 137 } else {
138 var contents = output.contents(); 138 var contents = output.read();
139 Expect.equals(data.length * 10, contents.length); 139 Expect.equals(data.length * 10, contents.length);
140 donePort.toSendPort().send(null); 140 donePort.toSendPort().send(null);
141 } 141 }
142 } 142 }
143 143
144 ListInputStream input = new ListInputStream(); 144 ListInputStream input = new ListInputStream();
145 input.write(data); 145 input.write(data);
146 input.markEndOfStream(); 146 input.markEndOfStream();
147 input.onClosed = onClosed; 147 input.onClosed = onClosed;
148 input.pipe(output, close: false); 148 input.pipe(output, close: false);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 testListInputStream1(); 282 testListInputStream1();
283 testListInputStream2(); 283 testListInputStream2();
284 testListInputStreamPipe1(); 284 testListInputStreamPipe1();
285 testListInputStreamPipe2(); 285 testListInputStreamPipe2();
286 testListInputClose1(); 286 testListInputClose1();
287 testListInputClose2(); 287 testListInputClose2();
288 testDynamicListInputStream(); 288 testDynamicListInputStream();
289 testDynamicListInputClose1(); 289 testDynamicListInputClose1();
290 testDynamicListInputClose2(); 290 testDynamicListInputClose2();
291 } 291 }
OLDNEW
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | tests/standalone/io/list_output_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698