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

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

Issue 10252020: test rename overhaul: step 12 - standalone (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
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");
11 #import("dart:isolate"); 11 #import("dart:isolate");
12 #source("TestingServer.dart"); 12 #source("testing_server.dart");
13 13
14 // Helper method to be able to run the test from the runtime 14 // Helper method to be able to run the test from the runtime
15 // directory, or the top directory. 15 // directory, or the top directory.
16 String getDataFilename(String path) => 16 String getDataFilename(String path) =>
17 new File(path).existsSync() ? path : '../' + path; 17 new File(path).existsSync() ? path : '../' + path;
18 18
19 19
20 bool compareFileContent(String fileName1, 20 bool compareFileContent(String fileName1,
21 String fileName2, 21 String fileName2,
22 [int file1Offset = 0, 22 [int file1Offset = 0,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 new PipeServer().spawn().then((SendPort port) { 71 new PipeServer().spawn().then((SendPort port) {
72 _sendPort = port; 72 _sendPort = port;
73 start(); 73 start();
74 }); 74 });
75 } 75 }
76 76
77 void runTest() { 77 void runTest() {
78 78
79 void connectHandler() { 79 void connectHandler() {
80 String srcFileName = 80 String srcFileName =
81 getDataFilename("tests/standalone/src/io/readline_test1.dat"); 81 getDataFilename("tests/standalone/io/readline_test1.dat");
82 82
83 SocketOutputStream socketOutput = _socket.outputStream; 83 SocketOutputStream socketOutput = _socket.outputStream;
84 InputStream fileInput = new File(srcFileName).openInputStream(); 84 InputStream fileInput = new File(srcFileName).openInputStream();
85 85
86 fileInput.onClosed = () { 86 fileInput.onClosed = () {
87 SocketInputStream socketInput = _socket.inputStream; 87 SocketInputStream socketInput = _socket.inputStream;
88 var tempDir = new Directory(''); 88 var tempDir = new Directory('');
89 tempDir.createTempSync(); 89 tempDir.createTempSync();
90 var dstFileName = tempDir.path + "/readline_test1.dat"; 90 var dstFileName = tempDir.path + "/readline_test1.dat";
91 var dstFile = new File(dstFileName); 91 var dstFile = new File(dstFileName);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 166 ReceivePort donePort = new ReceivePort();
167 donePort.receive((message, ignore) { donePort.close(); }); 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/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(); 196 ReceivePort donePort = new ReceivePort();
197 donePort.receive((message, ignore) { donePort.close(); }); 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/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);
208 dstFile.createSync(); 208 dstFile.createSync();
209 var dstStream = dstFile.openOutputStream(); 209 var dstStream = dstFile.openOutputStream();
210 210
(...skipping 26 matching lines...) Expand all
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(); 243 ReceivePort donePort = new ReceivePort();
244 donePort.receive((message, ignore) { donePort.close(); }); 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/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);
255 dstFile.createSync(); 255 dstFile.createSync();
256 var dstStream = dstFile.openOutputStream(); 256 var dstStream = dstFile.openOutputStream();
257 257
(...skipping 27 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/io/status_file_parser_test.dart ('k') | tests/standalone/io/string_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698