OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 socket.close(); | 94 socket.close(); |
95 } | 95 } |
96 | 96 |
97 void connectHandler(socket) { | 97 void connectHandler(socket) { |
98 socket.listen( | 98 socket.listen( |
99 dataHandler, | 99 dataHandler, |
100 onDone: () => closeHandler(socket), | 100 onDone: () => closeHandler(socket), |
101 onError: (error) => errorHandler(socket)); | 101 onError: (error) => errorHandler(socket)); |
102 | 102 |
103 void writeHello() { | 103 void writeHello() { |
104 socket.add("Hello".charCodes); | 104 socket.add("Hello".codeUnits); |
105 } | 105 } |
106 | 106 |
107 _iterations++; | 107 _iterations++; |
108 switch (_mode) { | 108 switch (_mode) { |
109 case 0: | 109 case 0: |
110 socket.destroy(); | 110 socket.destroy(); |
111 proceed(); | 111 proceed(); |
112 break; | 112 break; |
113 case 1: | 113 case 1: |
114 writeHello(); | 114 writeHello(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 void readBytes(bytes, whenFiveBytes) { | 218 void readBytes(bytes, whenFiveBytes) { |
219 data.readBytes += bytes.length; | 219 data.readBytes += bytes.length; |
220 Expect.isTrue(data.readBytes <= 5); | 220 Expect.isTrue(data.readBytes <= 5); |
221 if (data.readBytes == 5) { | 221 if (data.readBytes == 5) { |
222 whenFiveBytes(); | 222 whenFiveBytes(); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 void writeHello() { | 226 void writeHello() { |
227 connection.add("Hello".charCodes); | 227 connection.add("Hello".codeUnits); |
228 } | 228 } |
229 | 229 |
230 void dataHandler(bytes) { | 230 void dataHandler(bytes) { |
231 switch (_mode) { | 231 switch (_mode) { |
232 case 0: | 232 case 0: |
233 Expect.fail("No data expected"); | 233 Expect.fail("No data expected"); |
234 break; | 234 break; |
235 case 1: | 235 case 1: |
236 readBytes(bytes, () { _dataEvents++; }); | 236 readBytes(bytes, () { _dataEvents++; }); |
237 break; | 237 break; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 var tests = 7; | 377 var tests = 7; |
378 var port = new ReceivePort(); | 378 var port = new ReceivePort(); |
379 var completed = 0; | 379 var completed = 0; |
380 port.receive((message, ignore) { | 380 port.receive((message, ignore) { |
381 if (++completed == tests) port.close(); | 381 if (++completed == tests) port.close(); |
382 }); | 382 }); |
383 for (var i = 0; i < tests; i++) { | 383 for (var i = 0; i < tests; i++) { |
384 new SocketClose.start(i, port.toSendPort()); | 384 new SocketClose.start(i, port.toSendPort()); |
385 } | 385 } |
386 } | 386 } |
OLD | NEW |