| 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"; |
| 11 import "dart:io"; | 11 import "dart:io"; |
| 12 | 12 |
| 13 import "package:async_helper/async_helper.dart"; | 13 import "package:async_helper/async_helper.dart"; |
| 14 import "package:expect/expect.dart"; | 14 import "package:expect/expect.dart"; |
| 15 | 15 |
| 16 void testArguments() { | 16 void testArguments() { |
| 17 Expect.throws(() => ServerSocket.bind("127.0.0.1", 65536)); | 17 Expect.throws(() => ServerSocket.bind("127.0.0.1", 65536)); |
| 18 Expect.throws(() => ServerSocket.bind("127.0.0.1", -1)); | 18 Expect.throws(() => ServerSocket.bind("127.0.0.1", -1)); |
| 19 Expect.throws(() => ServerSocket.bind("127.0.0.1", 0, backlog: -1)); | 19 Expect.throws(() => ServerSocket.bind("127.0.0.1", 0, backlog: -1)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void testSimpleBind() { | 22 void testSimpleBind() { |
| 23 asyncStart(); | 23 asyncStart(); |
| 24 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((s) { | 24 ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((s) { |
| 25 Expect.isTrue(s.port > 0); | 25 Expect.isTrue(s.port > 0); |
| 26 s.close(); |
| 26 asyncEnd(); | 27 asyncEnd(); |
| 27 }); | 28 }); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void testInvalidBind() { | 31 void testInvalidBind() { |
| 31 // Bind to a unknown DNS name. | 32 // Bind to a unknown DNS name. |
| 32 asyncStart(); | 33 asyncStart(); |
| 33 ServerSocket.bind("ko.faar.__hest__", 0) | 34 ServerSocket.bind("ko.faar.__hest__", 0) |
| 34 .then((_) { Expect.fail("Failure expected"); } ) | 35 .then((_) { Expect.fail("Failure expected"); } ) |
| 35 .catchError((error) { | 36 .catchError((error) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 testInvalidBind(); | 206 testInvalidBind(); |
| 206 testConnectImmediateDestroy(); | 207 testConnectImmediateDestroy(); |
| 207 testConnectConsumerClose(); | 208 testConnectConsumerClose(); |
| 208 testConnectConsumerWriteClose(); | 209 testConnectConsumerWriteClose(); |
| 209 testConnectStreamClose(); | 210 testConnectStreamClose(); |
| 210 testConnectStreamDataClose(true); | 211 testConnectStreamDataClose(true); |
| 211 testConnectStreamDataClose(false); | 212 testConnectStreamDataClose(false); |
| 212 testConnectStreamDataCloseCancel(true); | 213 testConnectStreamDataCloseCancel(true); |
| 213 testConnectStreamDataCloseCancel(false); | 214 testConnectStreamDataCloseCancel(false); |
| 214 } | 215 } |
| OLD | NEW |