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

Side by Side Diff: tests/standalone/src/io/StreamPipeTest.dart

Issue 9652001: SendPort + ReceivePort changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « tests/standalone/src/io/FileTest.dart ('k') | no next file » | 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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 #import("dart:io"); 10 #import("dart:io");
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 connection.inputStream.pipe(connection.outputStream); 156 connection.inputStream.pipe(connection.outputStream);
157 } 157 }
158 } 158 }
159 159
160 160
161 // Test piping from one file to another and closing both streams 161 // Test piping from one file to another and closing both streams
162 // after wards. 162 // after wards.
163 testFileToFilePipe1() { 163 testFileToFilePipe1() {
164 // Force test to timeout if one of the handlers is 164 // Force test to timeout if one of the handlers is
165 // not called. 165 // not called.
166 ReceivePort donePort = new ReceivePort.singleShot(); 166 ReceivePort donePort = new ReceivePort();
167 donePort.receive((message, ignore) {}); 167 donePort.receive((message, ignore) { donePort.close(); });
168 168
169 String srcFileName = 169 String srcFileName =
170 getDataFilename("tests/standalone/src/io/readline_test1.dat"); 170 getDataFilename("tests/standalone/src/io/readline_test1.dat");
171 var srcStream = new File(srcFileName).openInputStream(); 171 var srcStream = new File(srcFileName).openInputStream();
172 172
173 var tempDir = new Directory(''); 173 var tempDir = new Directory('');
174 tempDir.createTempSync(); 174 tempDir.createTempSync();
175 String dstFileName = tempDir.path + "/readline_test1.dat"; 175 String dstFileName = tempDir.path + "/readline_test1.dat";
176 new File(dstFileName).createSync(); 176 new File(dstFileName).createSync();
177 var dstStream = new File(dstFileName).openOutputStream(); 177 var dstStream = new File(dstFileName).openOutputStream();
178 178
179 dstStream.onClosed = () { 179 dstStream.onClosed = () {
180 bool result = compareFileContent(srcFileName, dstFileName); 180 bool result = compareFileContent(srcFileName, dstFileName);
181 new File(dstFileName).deleteSync(); 181 new File(dstFileName).deleteSync();
182 tempDir.deleteSync(); 182 tempDir.deleteSync();
183 Expect.isTrue(result); 183 Expect.isTrue(result);
184 donePort.toSendPort().send(null); 184 donePort.toSendPort().send(null);
185 }; 185 };
186 186
187 srcStream.pipe(dstStream); 187 srcStream.pipe(dstStream);
188 } 188 }
189 189
190 190
191 // Test piping from one file to another and write additional data to 191 // Test piping from one file to another and write additional data to
192 // the output stream after piping finished. 192 // the output stream after piping finished.
193 testFileToFilePipe2() { 193 testFileToFilePipe2() {
194 // Force test to timeout if one of the handlers is 194 // Force test to timeout if one of the handlers is
195 // not called. 195 // not called.
196 ReceivePort donePort = new ReceivePort.singleShot(); 196 ReceivePort donePort = new ReceivePort();
197 donePort.receive((message, ignore) {}); 197 donePort.receive((message, ignore) { donePort.close(); });
198 198
199 String srcFileName = 199 String srcFileName =
200 getDataFilename("tests/standalone/src/io/readline_test1.dat"); 200 getDataFilename("tests/standalone/src/io/readline_test1.dat");
201 var srcFile = new File(srcFileName); 201 var srcFile = new File(srcFileName);
202 var srcStream = srcFile.openInputStream(); 202 var srcStream = srcFile.openInputStream();
203 203
204 var tempDir = new Directory(''); 204 var tempDir = new Directory('');
205 tempDir.createTempSync(); 205 tempDir.createTempSync();
206 var dstFileName = tempDir.path + "/readline_test1.dat"; 206 var dstFileName = tempDir.path + "/readline_test1.dat";
207 var dstFile = new File(dstFileName); 207 var dstFile = new File(dstFileName);
(...skipping 25 matching lines...) Expand all
233 }; 233 };
234 234
235 srcStream.pipe(dstStream, close: false); 235 srcStream.pipe(dstStream, close: false);
236 } 236 }
237 237
238 238
239 // Test piping two copies of one file to another. 239 // Test piping two copies of one file to another.
240 testFileToFilePipe3() { 240 testFileToFilePipe3() {
241 // Force test to timeout if one of the handlers is 241 // Force test to timeout if one of the handlers is
242 // not called. 242 // not called.
243 ReceivePort donePort = new ReceivePort.singleShot(); 243 ReceivePort donePort = new ReceivePort();
244 donePort.receive((message, ignore) {}); 244 donePort.receive((message, ignore) { donePort.close(); });
245 245
246 String srcFileName = 246 String srcFileName =
247 getDataFilename("tests/standalone/src/io/readline_test1.dat"); 247 getDataFilename("tests/standalone/src/io/readline_test1.dat");
248 var srcFile = new File(srcFileName); 248 var srcFile = new File(srcFileName);
249 var srcStream = srcFile.openInputStream(); 249 var srcStream = srcFile.openInputStream();
250 250
251 var tempDir = new Directory(''); 251 var tempDir = new Directory('');
252 tempDir.createTempSync(); 252 tempDir.createTempSync();
253 var dstFileName = tempDir.path + "/readline_test1.dat"; 253 var dstFileName = tempDir.path + "/readline_test1.dat";
254 var dstFile = new File(dstFileName); 254 var dstFile = new File(dstFileName);
(...skipping 30 matching lines...) Expand all
285 srcStream.pipe(dstStream, close: false); 285 srcStream.pipe(dstStream, close: false);
286 } 286 }
287 287
288 288
289 main() { 289 main() {
290 testFileToFilePipe1(); 290 testFileToFilePipe1();
291 testFileToFilePipe2(); 291 testFileToFilePipe2();
292 testFileToFilePipe3(); 292 testFileToFilePipe3();
293 PipeServerGame echoServerGame = new PipeServerGame.start(); 293 PipeServerGame echoServerGame = new PipeServerGame.start();
294 } 294 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/FileTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698