| 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 // 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 void connectHandler() { | 79 void connectHandler() { |
| 80 String srcFileName = | 80 String srcFileName = |
| 81 getDataFilename("tests/standalone/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('').createTempSync(); |
| 89 tempDir.createTempSync(); | |
| 90 var dstFileName = tempDir.path + "/readline_test1.dat"; | 89 var dstFileName = tempDir.path + "/readline_test1.dat"; |
| 91 var dstFile = new File(dstFileName); | 90 var dstFile = new File(dstFileName); |
| 92 dstFile.createSync(); | 91 dstFile.createSync(); |
| 93 var fileOutput = dstFile.openOutputStream(); | 92 var fileOutput = dstFile.openOutputStream(); |
| 94 | 93 |
| 95 socketInput.onClosed = () { | 94 socketInput.onClosed = () { |
| 96 // Check that the resulting file is equal to the initial | 95 // Check that the resulting file is equal to the initial |
| 97 // file. | 96 // file. |
| 98 fileOutput.onClosed = () { | 97 fileOutput.onClosed = () { |
| 99 bool result = compareFileContent(srcFileName, dstFileName); | 98 bool result = compareFileContent(srcFileName, dstFileName); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 testFileToFilePipe1() { | 162 testFileToFilePipe1() { |
| 164 // Force test to timeout if one of the handlers is | 163 // Force test to timeout if one of the handlers is |
| 165 // not called. | 164 // not called. |
| 166 ReceivePort donePort = new ReceivePort(); | 165 ReceivePort donePort = new ReceivePort(); |
| 167 donePort.receive((message, ignore) { donePort.close(); }); | 166 donePort.receive((message, ignore) { donePort.close(); }); |
| 168 | 167 |
| 169 String srcFileName = | 168 String srcFileName = |
| 170 getDataFilename("tests/standalone/io/readline_test1.dat"); | 169 getDataFilename("tests/standalone/io/readline_test1.dat"); |
| 171 var srcStream = new File(srcFileName).openInputStream(); | 170 var srcStream = new File(srcFileName).openInputStream(); |
| 172 | 171 |
| 173 var tempDir = new Directory(''); | 172 var tempDir = new Directory('').createTempSync(); |
| 174 tempDir.createTempSync(); | |
| 175 String dstFileName = tempDir.path + "/readline_test1.dat"; | 173 String dstFileName = tempDir.path + "/readline_test1.dat"; |
| 176 new File(dstFileName).createSync(); | 174 new File(dstFileName).createSync(); |
| 177 var dstStream = new File(dstFileName).openOutputStream(); | 175 var dstStream = new File(dstFileName).openOutputStream(); |
| 178 | 176 |
| 179 dstStream.onClosed = () { | 177 dstStream.onClosed = () { |
| 180 bool result = compareFileContent(srcFileName, dstFileName); | 178 bool result = compareFileContent(srcFileName, dstFileName); |
| 181 new File(dstFileName).deleteSync(); | 179 new File(dstFileName).deleteSync(); |
| 182 tempDir.deleteSync(); | 180 tempDir.deleteSync(); |
| 183 Expect.isTrue(result); | 181 Expect.isTrue(result); |
| 184 donePort.toSendPort().send(null); | 182 donePort.toSendPort().send(null); |
| 185 }; | 183 }; |
| 186 | 184 |
| 187 srcStream.pipe(dstStream); | 185 srcStream.pipe(dstStream); |
| 188 } | 186 } |
| 189 | 187 |
| 190 | 188 |
| 191 // Test piping from one file to another and write additional data to | 189 // Test piping from one file to another and write additional data to |
| 192 // the output stream after piping finished. | 190 // the output stream after piping finished. |
| 193 testFileToFilePipe2() { | 191 testFileToFilePipe2() { |
| 194 // Force test to timeout if one of the handlers is | 192 // Force test to timeout if one of the handlers is |
| 195 // not called. | 193 // not called. |
| 196 ReceivePort donePort = new ReceivePort(); | 194 ReceivePort donePort = new ReceivePort(); |
| 197 donePort.receive((message, ignore) { donePort.close(); }); | 195 donePort.receive((message, ignore) { donePort.close(); }); |
| 198 | 196 |
| 199 String srcFileName = | 197 String srcFileName = |
| 200 getDataFilename("tests/standalone/io/readline_test1.dat"); | 198 getDataFilename("tests/standalone/io/readline_test1.dat"); |
| 201 var srcFile = new File(srcFileName); | 199 var srcFile = new File(srcFileName); |
| 202 var srcStream = srcFile.openInputStream(); | 200 var srcStream = srcFile.openInputStream(); |
| 203 | 201 |
| 204 var tempDir = new Directory(''); | 202 var tempDir = new Directory('').createTempSync(); |
| 205 tempDir.createTempSync(); | |
| 206 var dstFileName = tempDir.path + "/readline_test1.dat"; | 203 var dstFileName = tempDir.path + "/readline_test1.dat"; |
| 207 var dstFile = new File(dstFileName); | 204 var dstFile = new File(dstFileName); |
| 208 dstFile.createSync(); | 205 dstFile.createSync(); |
| 209 var dstStream = dstFile.openOutputStream(); | 206 var dstStream = dstFile.openOutputStream(); |
| 210 | 207 |
| 211 srcStream.onClosed = () { | 208 srcStream.onClosed = () { |
| 212 dstStream.write([32]); | 209 dstStream.write([32]); |
| 213 dstStream.close(); | 210 dstStream.close(); |
| 214 dstStream.onClosed = () { | 211 dstStream.onClosed = () { |
| 215 var src = srcFile.openSync(); | 212 var src = srcFile.openSync(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 241 // Force test to timeout if one of the handlers is | 238 // Force test to timeout if one of the handlers is |
| 242 // not called. | 239 // not called. |
| 243 ReceivePort donePort = new ReceivePort(); | 240 ReceivePort donePort = new ReceivePort(); |
| 244 donePort.receive((message, ignore) { donePort.close(); }); | 241 donePort.receive((message, ignore) { donePort.close(); }); |
| 245 | 242 |
| 246 String srcFileName = | 243 String srcFileName = |
| 247 getDataFilename("tests/standalone/io/readline_test1.dat"); | 244 getDataFilename("tests/standalone/io/readline_test1.dat"); |
| 248 var srcFile = new File(srcFileName); | 245 var srcFile = new File(srcFileName); |
| 249 var srcStream = srcFile.openInputStream(); | 246 var srcStream = srcFile.openInputStream(); |
| 250 | 247 |
| 251 var tempDir = new Directory(''); | 248 var tempDir = new Directory('').createTempSync(); |
| 252 tempDir.createTempSync(); | |
| 253 var dstFileName = tempDir.path + "/readline_test1.dat"; | 249 var dstFileName = tempDir.path + "/readline_test1.dat"; |
| 254 var dstFile = new File(dstFileName); | 250 var dstFile = new File(dstFileName); |
| 255 dstFile.createSync(); | 251 dstFile.createSync(); |
| 256 var dstStream = dstFile.openOutputStream(); | 252 var dstStream = dstFile.openOutputStream(); |
| 257 | 253 |
| 258 srcStream.onClosed = () { | 254 srcStream.onClosed = () { |
| 259 var srcStream2 = srcFile.openInputStream(); | 255 var srcStream2 = srcFile.openInputStream(); |
| 260 | 256 |
| 261 dstStream.onClosed = () { | 257 dstStream.onClosed = () { |
| 262 var src = srcFile.openSync(); | 258 var src = srcFile.openSync(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 285 srcStream.pipe(dstStream, close: false); | 281 srcStream.pipe(dstStream, close: false); |
| 286 } | 282 } |
| 287 | 283 |
| 288 | 284 |
| 289 main() { | 285 main() { |
| 290 testFileToFilePipe1(); | 286 testFileToFilePipe1(); |
| 291 testFileToFilePipe2(); | 287 testFileToFilePipe2(); |
| 292 testFileToFilePipe3(); | 288 testFileToFilePipe3(); |
| 293 PipeServerGame echoServerGame = new PipeServerGame.start(); | 289 PipeServerGame echoServerGame = new PipeServerGame.start(); |
| 294 } | 290 } |
| OLD | NEW |