Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: tests/standalone/io/socket_exception_test.dart

Issue 10917064: Throw an error if the ServerSocket host argument is invalid. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check exception. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 server.close(); 21 server.close();
22 try { 22 try {
23 server.close(); 23 server.close();
24 } on SocketIOException catch(ex) { 24 } on SocketIOException catch(ex) {
25 exceptionCaught = true; 25 exceptionCaught = true;
26 } on Exception catch (ex) { 26 } on Exception catch (ex) {
27 wrongExceptionCaught = true; 27 wrongExceptionCaught = true;
28 } 28 }
29 Expect.equals(false, exceptionCaught); 29 Expect.equals(false, exceptionCaught);
30 Expect.equals(true, !wrongExceptionCaught); 30 Expect.equals(true, !wrongExceptionCaught);
31
32 // Test invalid host.
33 Expect.throws(() => new ServerSocket("__INVALID_HOST__", PORT, 10),
34 (e) => e is SocketIOException);
31 } 35 }
32 36
33 static void clientSocketExceptionTest() { 37 static void clientSocketExceptionTest() {
34 bool exceptionCaught = false; 38 bool exceptionCaught = false;
35 bool wrongExceptionCaught = false; 39 bool wrongExceptionCaught = false;
36 40
37 ServerSocket server = new ServerSocket(HOST, PORT, 10); 41 ServerSocket server = new ServerSocket(HOST, PORT, 10);
38 Expect.equals(true, server !== null); 42 Expect.equals(true, server !== null);
39 int port = server.port; 43 int port = server.port;
40 Socket client = new Socket(HOST, port); 44 Socket client = new Socket(HOST, port);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 Socket s = new Socket("127.0.0.1", 65535); 195 Socket s = new Socket("127.0.0.1", 65535);
192 s.onError = (e) => port.close(); 196 s.onError = (e) => port.close();
193 s.onConnect = () => Expect.fail("Connection completed"); 197 s.onConnect = () => Expect.fail("Connection completed");
194 } 198 }
195 199
196 static void testMain() { 200 static void testMain() {
197 serverSocketExceptionTest(); 201 serverSocketExceptionTest();
198 clientSocketExceptionTest(); 202 clientSocketExceptionTest();
199 indexOutOfRangeExceptionTest(); 203 indexOutOfRangeExceptionTest();
200 unknownHostTest(); 204 unknownHostTest();
205
201 // TODO(sgjesse): This test seems to fail on the buildbot. 206 // TODO(sgjesse): This test seems to fail on the buildbot.
202 //unresponsiveHostTest(); 207 //unresponsiveHostTest();
203 } 208 }
204 } 209 }
205 210
206 main() { 211 main() {
207 SocketExceptionTest.testMain(); 212 SocketExceptionTest.testMain();
208 } 213 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698