| 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 // Test socket close events. | 10 // Test socket close events. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 _socket.inputStream.onClosed = closeHandler; | 103 _socket.inputStream.onClosed = closeHandler; |
| 104 _socket.onError = errorHandler; | 104 _socket.onError = errorHandler; |
| 105 | 105 |
| 106 _iterations++; | 106 _iterations++; |
| 107 switch (_mode) { | 107 switch (_mode) { |
| 108 case 0: | 108 case 0: |
| 109 _socket.inputStream.close(); | 109 _socket.inputStream.close(); |
| 110 proceed(); | 110 proceed(); |
| 111 break; | 111 break; |
| 112 case 1: | 112 case 1: |
| 113 _socket.outputStream.write("Hello".charCodes); | 113 _socket.outputStream.write("Hello".codeUnits); |
| 114 _socket.outputStream.onNoPendingWrites = () { | 114 _socket.outputStream.onNoPendingWrites = () { |
| 115 _socket.inputStream.close(); | 115 _socket.inputStream.close(); |
| 116 proceed(); | 116 proceed(); |
| 117 }; | 117 }; |
| 118 break; | 118 break; |
| 119 case 2: | 119 case 2: |
| 120 case 3: | 120 case 3: |
| 121 case 4: | 121 case 4: |
| 122 _socket.outputStream.write("Hello".charCodes); | 122 _socket.outputStream.write("Hello".codeUnits); |
| 123 break; | 123 break; |
| 124 case 5: | 124 case 5: |
| 125 _socket.outputStream.write("Hello".charCodes); | 125 _socket.outputStream.write("Hello".codeUnits); |
| 126 _socket.outputStream.onNoPendingWrites = () { | 126 _socket.outputStream.onNoPendingWrites = () { |
| 127 _socket.outputStream.close(); | 127 _socket.outputStream.close(); |
| 128 }; | 128 }; |
| 129 break; | 129 break; |
| 130 case 6: | 130 case 6: |
| 131 _socket.outputStream.write("Hello".charCodes); | 131 _socket.outputStream.write("Hello".codeUnits); |
| 132 break; | 132 break; |
| 133 case 7: | 133 case 7: |
| 134 case 8: | 134 case 8: |
| 135 _socket.outputStream.write("Hello".charCodes); | 135 _socket.outputStream.write("Hello".codeUnits); |
| 136 _socket.outputStream.onNoPendingWrites = () { | 136 _socket.outputStream.onNoPendingWrites = () { |
| 137 _socket.outputStream.close(); | 137 _socket.outputStream.close(); |
| 138 }; | 138 }; |
| 139 break; | 139 break; |
| 140 default: | 140 default: |
| 141 Expect.fail("Unknown test mode"); | 141 Expect.fail("Unknown test mode"); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 _socket = new Socket(SocketCloseServer.HOST, _port); | 145 _socket = new Socket(SocketCloseServer.HOST, _port); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 break; | 249 break; |
| 250 case 2: | 250 case 2: |
| 251 readBytes(() { | 251 readBytes(() { |
| 252 _dataEvents++; | 252 _dataEvents++; |
| 253 connection.inputStream.close(); | 253 connection.inputStream.close(); |
| 254 }); | 254 }); |
| 255 break; | 255 break; |
| 256 case 3: | 256 case 3: |
| 257 readBytes(() { | 257 readBytes(() { |
| 258 _dataEvents++; | 258 _dataEvents++; |
| 259 connection.outputStream.write("Hello".charCodes); | 259 connection.outputStream.write("Hello".codeUnits); |
| 260 connection.outputStream.onNoPendingWrites = () { | 260 connection.outputStream.onNoPendingWrites = () { |
| 261 connection.inputStream.close(); | 261 connection.inputStream.close(); |
| 262 }; | 262 }; |
| 263 }); | 263 }); |
| 264 break; | 264 break; |
| 265 case 4: | 265 case 4: |
| 266 readBytes(() { | 266 readBytes(() { |
| 267 _dataEvents++; | 267 _dataEvents++; |
| 268 connection.outputStream.write("Hello".charCodes); | 268 connection.outputStream.write("Hello".codeUnits); |
| 269 connection.inputStream.close(); | 269 connection.inputStream.close(); |
| 270 }); | 270 }); |
| 271 break; | 271 break; |
| 272 case 5: | 272 case 5: |
| 273 readBytes(() { | 273 readBytes(() { |
| 274 _dataEvents++; | 274 _dataEvents++; |
| 275 connection.outputStream.write("Hello".charCodes); | 275 connection.outputStream.write("Hello".codeUnits); |
| 276 }); | 276 }); |
| 277 break; | 277 break; |
| 278 case 6: | 278 case 6: |
| 279 case 7: | 279 case 7: |
| 280 readBytes(() { | 280 readBytes(() { |
| 281 _dataEvents++; | 281 _dataEvents++; |
| 282 connection.outputStream.write("Hello".charCodes); | 282 connection.outputStream.write("Hello".codeUnits); |
| 283 connection.outputStream.onNoPendingWrites = () { | 283 connection.outputStream.onNoPendingWrites = () { |
| 284 connection.outputStream.close(); | 284 connection.outputStream.close(); |
| 285 }; | 285 }; |
| 286 }); | 286 }); |
| 287 break; | 287 break; |
| 288 case 8: | 288 case 8: |
| 289 readBytes(() { | 289 readBytes(() { |
| 290 _dataEvents++; | 290 _dataEvents++; |
| 291 connection.outputStream.write("Hello".charCodes); | 291 connection.outputStream.write("Hello".codeUnits); |
| 292 connection.outputStream.close(); | 292 connection.outputStream.close(); |
| 293 }); | 293 }); |
| 294 break; | 294 break; |
| 295 default: | 295 default: |
| 296 Expect.fail("Unknown test mode"); | 296 Expect.fail("Unknown test mode"); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void closeHandler() { | 300 void closeHandler() { |
| 301 _closeEvents++; | 301 _closeEvents++; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 var tests = 9; | 409 var tests = 9; |
| 410 var port = new ReceivePort(); | 410 var port = new ReceivePort(); |
| 411 var completed = 0; | 411 var completed = 0; |
| 412 port.receive((message, ignore) { | 412 port.receive((message, ignore) { |
| 413 if (++completed == tests) port.close(); | 413 if (++completed == tests) port.close(); |
| 414 }); | 414 }); |
| 415 for (var i = 0; i < tests; i++) { | 415 for (var i = 0; i < tests; i++) { |
| 416 new SocketClose.start(i, port.toSendPort()); | 416 new SocketClose.start(i, port.toSendPort()); |
| 417 } | 417 } |
| 418 } | 418 } |
| OLD | NEW |