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

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

Issue 16123036: Clean up dart:io exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
OLDNEW
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 17 matching lines...) Expand all
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 RawServerSocket.bind("ko.faar.__hest__", 0) 35 RawServerSocket.bind("ko.faar.__hest__", 0)
36 .then((_) { Expect.fail("Failure expected"); } ) 36 .then((_) { Expect.fail("Failure expected"); } )
37 .catchError((error) { 37 .catchError((error) {
38 Expect.isTrue(error is SocketIOException); 38 Expect.isTrue(error is SocketException);
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 RawServerSocket.bind("8.8.8.8", 0) 43 RawServerSocket.bind("8.8.8.8", 0)
44 .then((_) { Expect.fail("Failure expected"); } ) 44 .then((_) { Expect.fail("Failure expected"); } )
45 .catchError((error) { 45 .catchError((error) {
46 Expect.isTrue(error is SocketIOException); 46 Expect.isTrue(error is SocketException);
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 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0) 54 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0)
55 .then((s) { 55 .then((s) {
56 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, s.port) 56 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 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((error) { 62 .catchError((error) {
63 Expect.notEquals('windows', Platform.operatingSystem); 63 Expect.notEquals('windows', Platform.operatingSystem);
64 Expect.isTrue(error is SocketIOException); 64 Expect.isTrue(error is SocketException);
65 port.toSendPort().send(1); 65 port.toSendPort().send(1);
66 }); 66 });
67 }); 67 });
68 } 68 }
69 69
70 void testSimpleConnect() { 70 void testSimpleConnect() {
71 ReceivePort port = new ReceivePort(); 71 ReceivePort port = new ReceivePort();
72 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { 72 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) {
73 server.listen((_) { }); 73 server.listen((_) { });
74 RawSocket.connect("127.0.0.1", server.port).then((_) { 74 RawSocket.connect("127.0.0.1", server.port).then((_) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 testSimpleBind(); 349 testSimpleBind();
350 testCloseOneEnd("client"); 350 testCloseOneEnd("client");
351 testCloseOneEnd("server"); 351 testCloseOneEnd("server");
352 testInvalidBind(); 352 testInvalidBind();
353 testSimpleConnect(); 353 testSimpleConnect();
354 testServerListenAfterConnect(); 354 testServerListenAfterConnect();
355 testSimpleReadWrite(); 355 testSimpleReadWrite();
356 testPauseServerSocket(); 356 testPauseServerSocket();
357 testPauseSocket(); 357 testPauseSocket();
358 } 358 }
OLDNEW
« no previous file with comments | « tests/standalone/io/raw_secure_server_socket_test.dart ('k') | tests/standalone/io/secure_no_builtin_roots_database_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698