| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("StreamPipeTest"); | 10 #library("StreamPipeTest"); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 var dstFileName = tempDir.path + "/readline_test1.dat"; | 89 var dstFileName = tempDir.path + "/readline_test1.dat"; |
| 90 var dstFile = new File(dstFileName); | 90 var dstFile = new File(dstFileName); |
| 91 dstFile.createSync(); | 91 dstFile.createSync(); |
| 92 var fileOutput = dstFile.openOutputStream(); | 92 var fileOutput = dstFile.openOutputStream(); |
| 93 | 93 |
| 94 socketInput.closeHandler = () { | 94 socketInput.closeHandler = () { |
| 95 // Check that the resulting file is equal to the initial | 95 // Check that the resulting file is equal to the initial |
| 96 // file. | 96 // file. |
| 97 bool result = compareFileContent(srcFileName, dstFileName); | 97 bool result = compareFileContent(srcFileName, dstFileName); |
| 98 new File(dstFileName).deleteSync(); | 98 new File(dstFileName).deleteSync(); |
| 99 tempDir.deleteSync(); |
| 99 Expect.isTrue(result); | 100 Expect.isTrue(result); |
| 100 | 101 |
| 101 _socket.close(); | 102 _socket.close(); |
| 102 | 103 |
| 103 // Run this twice. | 104 // Run this twice. |
| 104 if (count++ < 2) { | 105 if (count++ < 2) { |
| 105 runTest(); | 106 runTest(); |
| 106 } else { | 107 } else { |
| 107 shutdown(); | 108 shutdown(); |
| 108 } | 109 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 164 |
| 164 var tempDir = new Directory(''); | 165 var tempDir = new Directory(''); |
| 165 tempDir.createTempSync(); | 166 tempDir.createTempSync(); |
| 166 String dstFileName = tempDir.path + "/readline_test1.dat"; | 167 String dstFileName = tempDir.path + "/readline_test1.dat"; |
| 167 new File(dstFileName).createSync(); | 168 new File(dstFileName).createSync(); |
| 168 var dstStream = new File(dstFileName).openOutputStream(); | 169 var dstStream = new File(dstFileName).openOutputStream(); |
| 169 | 170 |
| 170 srcStream.closeHandler = () { | 171 srcStream.closeHandler = () { |
| 171 bool result = compareFileContent(srcFileName, dstFileName); | 172 bool result = compareFileContent(srcFileName, dstFileName); |
| 172 new File(dstFileName).deleteSync(); | 173 new File(dstFileName).deleteSync(); |
| 174 tempDir.deleteSync(); |
| 173 Expect.isTrue(result); | 175 Expect.isTrue(result); |
| 174 }; | 176 }; |
| 175 | 177 |
| 176 srcStream.pipe(dstStream); | 178 srcStream.pipe(dstStream); |
| 177 } | 179 } |
| 178 | 180 |
| 179 | 181 |
| 180 // Test piping from one file to another and write additional data to | 182 // Test piping from one file to another and write additional data to |
| 181 // the output stream after piping finished. | 183 // the output stream after piping finished. |
| 182 testFileToFilePipe2() { | 184 testFileToFilePipe2() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 203 Expect.isTrue(compareFileContent(srcFileName, | 205 Expect.isTrue(compareFileContent(srcFileName, |
| 204 dstFileName, | 206 dstFileName, |
| 205 count: srcLength)); | 207 count: srcLength)); |
| 206 dst.setPositionSync(srcLength); | 208 dst.setPositionSync(srcLength); |
| 207 var data = new List<int>(1); | 209 var data = new List<int>(1); |
| 208 var read2 = dst.readListSync(data, 0, 1); | 210 var read2 = dst.readListSync(data, 0, 1); |
| 209 Expect.equals(32, data[0]); | 211 Expect.equals(32, data[0]); |
| 210 src.closeSync(); | 212 src.closeSync(); |
| 211 dst.closeSync(); | 213 dst.closeSync(); |
| 212 dstFile.deleteSync(); | 214 dstFile.deleteSync(); |
| 215 tempDir.deleteSync(); |
| 213 }; | 216 }; |
| 214 | 217 |
| 215 srcStream.pipe(dstStream, close: false); | 218 srcStream.pipe(dstStream, close: false); |
| 216 } | 219 } |
| 217 | 220 |
| 218 | 221 |
| 219 // Test piping two copies of one file to another. | 222 // Test piping two copies of one file to another. |
| 220 testFileToFilePipe3() { | 223 testFileToFilePipe3() { |
| 221 String srcFileName = | 224 String srcFileName = |
| 222 getDataFilename("tests/standalone/src/readline_test1.dat"); | 225 getDataFilename("tests/standalone/src/readline_test1.dat"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 242 Expect.isTrue(compareFileContent(srcFileName, | 245 Expect.isTrue(compareFileContent(srcFileName, |
| 243 dstFileName, | 246 dstFileName, |
| 244 count: srcLength)); | 247 count: srcLength)); |
| 245 Expect.isTrue(compareFileContent(srcFileName, | 248 Expect.isTrue(compareFileContent(srcFileName, |
| 246 dstFileName, | 249 dstFileName, |
| 247 file2Offset: srcLength, | 250 file2Offset: srcLength, |
| 248 count: srcLength)); | 251 count: srcLength)); |
| 249 src.closeSync(); | 252 src.closeSync(); |
| 250 dst.closeSync(); | 253 dst.closeSync(); |
| 251 dstFile.deleteSync(); | 254 dstFile.deleteSync(); |
| 255 tempDir.deleteSync(); |
| 252 }; | 256 }; |
| 253 | 257 |
| 254 // Pipe another copy of the source file. | 258 // Pipe another copy of the source file. |
| 255 srcStream2.pipe(dstStream); | 259 srcStream2.pipe(dstStream); |
| 256 }; | 260 }; |
| 257 | 261 |
| 258 srcStream.pipe(dstStream, close: false); | 262 srcStream.pipe(dstStream, close: false); |
| 259 } | 263 } |
| 260 | 264 |
| 261 | 265 |
| 262 main() { | 266 main() { |
| 263 testFileToFilePipe1(); | 267 testFileToFilePipe1(); |
| 264 testFileToFilePipe2(); | 268 testFileToFilePipe2(); |
| 265 testFileToFilePipe3(); | 269 testFileToFilePipe3(); |
| 266 PipeServerGame echoServerGame = new PipeServerGame.start(); | 270 PipeServerGame echoServerGame = new PipeServerGame.start(); |
| 267 } | 271 } |
| OLD | NEW |