| 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 // Tests socket exceptions. | 5 // Tests socket exceptions. |
| 6 | 6 |
| 7 #import("dart:isolate"); | 7 #import("dart:isolate"); |
| 8 #import("dart:io"); | 8 #import("dart:io"); |
| 9 | 9 |
| 10 class SocketExceptionTest { | 10 class SocketExceptionTest { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 static void unknownHostTest() { | 176 static void unknownHostTest() { |
| 177 // Port to verify that the test completes. | 177 // Port to verify that the test completes. |
| 178 var port = new ReceivePort(); | 178 var port = new ReceivePort(); |
| 179 port.receive((message, replyTo) => null); | 179 port.receive((message, replyTo) => null); |
| 180 | 180 |
| 181 Socket s = new Socket("hede.hule.hest", 1234); | 181 Socket s = new Socket("hede.hule.hest", 1234); |
| 182 s.onError = (e) => port.close(); | 182 s.onError = (e) => port.close(); |
| 183 s.onConnect = () => Expect.fail("Connection completed"); | 183 s.onConnect = () => Expect.fail("Connection completed"); |
| 184 } | 184 } |
| 185 | 185 |
| 186 static void unresponsiveHostTest() { | |
| 187 // Port to keep the VM alive until test completes. | |
| 188 var port = new ReceivePort(); | |
| 189 port.receive((message, replyTo) => null); | |
| 190 | |
| 191 Socket s = new Socket("127.0.0.1", 65535); | |
| 192 s.onError = (e) => port.close(); | |
| 193 s.onConnect = () => Expect.fail("Connection completed"); | |
| 194 } | |
| 195 | |
| 196 static void testMain() { | 186 static void testMain() { |
| 197 serverSocketExceptionTest(); | 187 serverSocketExceptionTest(); |
| 198 clientSocketExceptionTest(); | 188 clientSocketExceptionTest(); |
| 199 indexOutOfRangeExceptionTest(); | 189 indexOutOfRangeExceptionTest(); |
| 200 unknownHostTest(); | 190 unknownHostTest(); |
| 201 // TODO(sgjesse): This test seems to fail on the buildbot. | |
| 202 //unresponsiveHostTest(); | |
| 203 } | 191 } |
| 204 } | 192 } |
| 205 | 193 |
| 206 main() { | 194 main() { |
| 207 SocketExceptionTest.testMain(); | 195 SocketExceptionTest.testMain(); |
| 208 } | 196 } |
| 197 |
| OLD | NEW |