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 import "dart:async"; | 10 import "dart:async"; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 Expect.fail("Multiple listens on same port"); | 55 Expect.fail("Multiple listens on same port"); |
56 }) | 56 }) |
57 .catchError((error) { | 57 .catchError((error) { |
58 Expect.isTrue(error is SocketException); | 58 Expect.isTrue(error is SocketException); |
59 s.close(); | 59 s.close(); |
60 asyncEnd(); | 60 asyncEnd(); |
61 }); | 61 }); |
62 }); | 62 }); |
63 } | 63 } |
64 | 64 |
65 void testConnectNoDestroy() { | |
66 asyncStart(); | |
67 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { | |
68 server.listen((_) { }); | |
69 Socket.connect("127.0.0.1", server.port).then((_) { | |
70 server.close(); | |
71 asyncEnd(); | |
72 }); | |
73 }); | |
74 } | |
75 | |
76 void testConnectImmediateDestroy() { | 65 void testConnectImmediateDestroy() { |
77 asyncStart(); | 66 asyncStart(); |
78 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { | 67 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
79 server.listen((_) { }); | 68 server.listen((_) { }); |
80 Socket.connect("127.0.0.1", server.port).then((socket) { | 69 Socket.connect("127.0.0.1", server.port).then((socket) { |
81 socket.destroy(); | 70 socket.destroy(); |
82 server.close(); | 71 server.close(); |
83 asyncEnd(); | 72 asyncEnd(); |
84 }); | 73 }); |
85 }); | 74 }); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 subscription.cancel(); | 192 subscription.cancel(); |
204 socket.close(); | 193 socket.close(); |
205 server.close(); | 194 server.close(); |
206 asyncEnd(); | 195 asyncEnd(); |
207 }, | 196 }, |
208 onDone: () { Expect.fail("Unexpected pipe completion"); }); | 197 onDone: () { Expect.fail("Unexpected pipe completion"); }); |
209 }); | 198 }); |
210 }); | 199 }); |
211 } | 200 } |
212 | 201 |
213 void testCloseWriteNoListen() { | |
214 asyncStart(); | |
215 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { | |
216 server.listen( | |
217 (client) { | |
218 client.close(); | |
219 }); | |
220 Socket.connect("127.0.0.1", server.port).then((socket) { | |
221 socket.close(); | |
222 server.close(); | |
223 asyncEnd(); | |
224 }); | |
225 }); | |
226 } | |
227 | |
228 main() { | 202 main() { |
229 testArguments(); | 203 testArguments(); |
230 testSimpleBind(); | 204 testSimpleBind(); |
231 testInvalidBind(); | 205 testInvalidBind(); |
232 testConnectNoDestroy(); | |
233 testConnectImmediateDestroy(); | 206 testConnectImmediateDestroy(); |
234 testConnectConsumerClose(); | 207 testConnectConsumerClose(); |
235 testConnectConsumerWriteClose(); | 208 testConnectConsumerWriteClose(); |
236 testConnectStreamClose(); | 209 testConnectStreamClose(); |
237 testConnectStreamDataClose(true); | 210 testConnectStreamDataClose(true); |
238 testConnectStreamDataClose(false); | 211 testConnectStreamDataClose(false); |
239 testConnectStreamDataCloseCancel(true); | 212 testConnectStreamDataCloseCancel(true); |
240 testConnectStreamDataCloseCancel(false); | 213 testConnectStreamDataCloseCancel(false); |
241 testCloseWriteNoListen(); | |
242 } | 214 } |
OLD | NEW |