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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 void testInvalidBind() { | 29 void testInvalidBind() { |
30 int count = 0; | 30 int count = 0; |
31 ReceivePort port = new ReceivePort(); | 31 ReceivePort port = new ReceivePort(); |
32 port.receive((_, __) { count++; if (count == 3) port.close(); }); | 32 port.receive((_, __) { count++; if (count == 3) port.close(); }); |
33 | 33 |
34 // Bind to a unknown DNS name. | 34 // Bind to a unknown DNS name. |
35 ServerSocket.bind("ko.faar.__hest__") | 35 ServerSocket.bind("ko.faar.__hest__") |
36 .then((_) { Expect.fail("Failure expected"); } ) | 36 .then((_) { Expect.fail("Failure expected"); } ) |
37 .catchError((e) { | 37 .catchError((error) { |
38 Expect.isTrue(e.error is SocketIOException); | 38 Expect.isTrue(error is SocketIOException); |
39 port.toSendPort().send(1); | 39 port.toSendPort().send(1); |
40 }); | 40 }); |
41 | 41 |
42 // Bind to an unavaliable IP-address. | 42 // Bind to an unavaliable IP-address. |
43 ServerSocket.bind("8.8.8.8") | 43 ServerSocket.bind("8.8.8.8") |
44 .then((_) { Expect.fail("Failure expected"); } ) | 44 .then((_) { Expect.fail("Failure expected"); } ) |
45 .catchError((e) { | 45 .catchError((error) { |
46 Expect.isTrue(e.error is SocketIOException); | 46 Expect.isTrue(error is SocketIOException); |
47 port.toSendPort().send(1); | 47 port.toSendPort().send(1); |
48 }); | 48 }); |
49 | 49 |
50 // Bind to a port already in use. | 50 // Bind to a port already in use. |
51 // Either an error or a successful bind is allowed. | 51 // Either an error or a successful bind is allowed. |
52 // Windows platforms allow multiple binding to the same socket, with | 52 // Windows platforms allow multiple binding to the same socket, with |
53 // unpredictable results. | 53 // unpredictable results. |
54 ServerSocket.bind("127.0.0.1") | 54 ServerSocket.bind("127.0.0.1") |
55 .then((s) { | 55 .then((s) { |
56 ServerSocket.bind("127.0.0.1", s.port) | 56 ServerSocket.bind("127.0.0.1", s.port) |
57 .then((t) { | 57 .then((t) { |
58 Expect.equals('windows', Platform.operatingSystem); | 58 Expect.equals('windows', Platform.operatingSystem); |
59 Expect.equals(s.port, t.port); | 59 Expect.equals(s.port, t.port); |
60 port.toSendPort().send(1); | 60 port.toSendPort().send(1); |
61 }) | 61 }) |
62 .catchError((e) { | 62 .catchError((error) { |
63 Expect.notEquals('windows', Platform.operatingSystem); | 63 Expect.notEquals('windows', Platform.operatingSystem); |
64 Expect.isTrue(e.error is SocketIOException); | 64 Expect.isTrue(error is SocketIOException); |
65 port.toSendPort().send(1); | 65 port.toSendPort().send(1); |
66 }); | 66 }); |
67 }); | 67 }); |
68 } | 68 } |
69 | 69 |
70 void testConnectNoDestroy() { | 70 void testConnectNoDestroy() { |
71 ReceivePort port = new ReceivePort(); | 71 ReceivePort port = new ReceivePort(); |
72 ServerSocket.bind().then((server) { | 72 ServerSocket.bind().then((server) { |
73 server.listen((_) { }); | 73 server.listen((_) { }); |
74 Socket.connect("127.0.0.1", server.port).then((_) { | 74 Socket.connect("127.0.0.1", server.port).then((_) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 testConnectNoDestroy(); | 222 testConnectNoDestroy(); |
223 testConnectImmediateDestroy(); | 223 testConnectImmediateDestroy(); |
224 testConnectConsumerClose(); | 224 testConnectConsumerClose(); |
225 testConnectConsumerWriteClose(); | 225 testConnectConsumerWriteClose(); |
226 testConnectStreamClose(); | 226 testConnectStreamClose(); |
227 testConnectStreamDataClose(true); | 227 testConnectStreamDataClose(true); |
228 testConnectStreamDataClose(false); | 228 testConnectStreamDataClose(false); |
229 testConnectStreamDataCloseCancel(true); | 229 testConnectStreamDataCloseCancel(true); |
230 testConnectStreamDataCloseCancel(false); | 230 testConnectStreamDataCloseCancel(false); |
231 } | 231 } |
OLD | NEW |