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