| 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 #library("StreamPipeTest"); | |
| 11 #import("dart:io"); | 10 #import("dart:io"); |
| 12 #import("dart:isolate"); | 11 #import("dart:isolate"); |
| 13 #source("TestingServer.dart"); | 12 #source("TestingServer.dart"); |
| 14 | 13 |
| 15 // 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 |
| 16 // directory, or the top directory. | 15 // directory, or the top directory. |
| 17 String getDataFilename(String path) => | 16 String getDataFilename(String path) => |
| 18 new File(path).existsSync() ? path : '../' + path; | 17 new File(path).existsSync() ? path : '../' + path; |
| 19 | 18 |
| 20 | 19 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ReceivePort _receivePort; | 144 ReceivePort _receivePort; |
| 146 SendPort _sendPort; | 145 SendPort _sendPort; |
| 147 Socket _socket; | 146 Socket _socket; |
| 148 int _messages; | 147 int _messages; |
| 149 } | 148 } |
| 150 | 149 |
| 151 | 150 |
| 152 // The testing server will simply pipe each connecting sockets input | 151 // The testing server will simply pipe each connecting sockets input |
| 153 // stream to its output stream. | 152 // stream to its output stream. |
| 154 class PipeServer extends TestingServer { | 153 class PipeServer extends TestingServer { |
| 155 void connectionHandler(Socket connection) { | 154 void onConnection(Socket connection) { |
| 156 connection.onError = () { Expect.fail("Socket error"); }; | 155 connection.onError = () { Expect.fail("Socket error"); }; |
| 157 connection.inputStream.pipe(connection.outputStream); | 156 connection.inputStream.pipe(connection.outputStream); |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 | 159 |
| 161 | 160 |
| 162 // Test piping from one file to another and closing both streams | 161 // Test piping from one file to another and closing both streams |
| 163 // after wards. | 162 // after wards. |
| 164 testFileToFilePipe1() { | 163 testFileToFilePipe1() { |
| 165 // Force test to timeout if one of the handlers is | 164 // Force test to timeout if one of the handlers is |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 srcStream.pipe(dstStream, close: false); | 285 srcStream.pipe(dstStream, close: false); |
| 287 } | 286 } |
| 288 | 287 |
| 289 | 288 |
| 290 main() { | 289 main() { |
| 291 testFileToFilePipe1(); | 290 testFileToFilePipe1(); |
| 292 testFileToFilePipe2(); | 291 testFileToFilePipe2(); |
| 293 testFileToFilePipe3(); | 292 testFileToFilePipe3(); |
| 294 PipeServerGame echoServerGame = new PipeServerGame.start(); | 293 PipeServerGame echoServerGame = new PipeServerGame.start(); |
| 295 } | 294 } |
| OLD | NEW |