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

Side by Side Diff: tests/standalone/io/raw_secure_server_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
« no previous file with comments | « tests/standalone/io/http_shutdown_test.dart ('k') | tests/standalone/io/raw_socket_test.dart » ('j') | 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) 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 15 matching lines...) Expand all
26 26
27 void testInvalidBind() { 27 void testInvalidBind() {
28 int count = 0; 28 int count = 0;
29 ReceivePort port = new ReceivePort(); 29 ReceivePort port = new ReceivePort();
30 port.receive((_, __) { count++; if (count == 3) port.close(); }); 30 port.receive((_, __) { count++; if (count == 3) port.close(); });
31 31
32 // Bind to a unknown DNS name. 32 // Bind to a unknown DNS name.
33 RawSecureServerSocket.bind("ko.faar.__hest__", 0, CERTIFICATE).then((_) { 33 RawSecureServerSocket.bind("ko.faar.__hest__", 0, CERTIFICATE).then((_) {
34 Expect.fail("Failure expected"); 34 Expect.fail("Failure expected");
35 }).catchError((error) { 35 }).catchError((error) {
36 Expect.isTrue(error is SocketIOException); 36 Expect.isTrue(error is SocketException);
37 port.toSendPort().send(1); 37 port.toSendPort().send(1);
38 }); 38 });
39 39
40 // Bind to an unavaliable IP-address. 40 // Bind to an unavaliable IP-address.
41 RawSecureServerSocket.bind("8.8.8.8", 0, CERTIFICATE).then((_) { 41 RawSecureServerSocket.bind("8.8.8.8", 0, CERTIFICATE).then((_) {
42 Expect.fail("Failure expected"); 42 Expect.fail("Failure expected");
43 }).catchError((error) { 43 }).catchError((error) {
44 Expect.isTrue(error is SocketIOException); 44 Expect.isTrue(error is SocketException);
45 port.toSendPort().send(1); 45 port.toSendPort().send(1);
46 }); 46 });
47 47
48 // Bind to a port already in use. 48 // Bind to a port already in use.
49 // Either an error or a successful bind is allowed. 49 // Either an error or a successful bind is allowed.
50 // Windows platforms allow multiple binding to the same socket, with 50 // Windows platforms allow multiple binding to the same socket, with
51 // unpredictable results. 51 // unpredictable results.
52 RawSecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((s) { 52 RawSecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((s) {
53 RawSecureServerSocket.bind(HOST_NAME, 53 RawSecureServerSocket.bind(HOST_NAME,
54 s.port, 54 s.port,
55 CERTIFICATE).then((t) { 55 CERTIFICATE).then((t) {
56 Expect.equals('windows', Platform.operatingSystem); 56 Expect.equals('windows', Platform.operatingSystem);
57 Expect.equals(s.port, t.port); 57 Expect.equals(s.port, t.port);
58 s.close(); 58 s.close();
59 t.close(); 59 t.close();
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 s.close(); 65 s.close();
66 port.toSendPort().send(1); 66 port.toSendPort().send(1);
67 }); 67 });
68 }); 68 });
69 } 69 }
70 70
71 void testSimpleConnect(String certificate) { 71 void testSimpleConnect(String certificate) {
72 ReceivePort port = new ReceivePort(); 72 ReceivePort port = new ReceivePort();
73 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { 73 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) {
74 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port); 74 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port);
75 server.listen((serverEnd) { 75 server.listen((serverEnd) {
76 clientEndFuture.then((clientEnd) { 76 clientEndFuture.then((clientEnd) {
77 clientEnd.shutdown(SocketDirection.SEND); 77 clientEnd.shutdown(SocketDirection.SEND);
78 serverEnd.shutdown(SocketDirection.SEND); 78 serverEnd.shutdown(SocketDirection.SEND);
79 server.close(); 79 server.close();
80 port.close(); 80 port.close();
81 }); 81 });
82 }); 82 });
83 }); 83 });
84 } 84 }
85 85
86 void testSimpleConnectFail(String certificate, bool cancelOnError) { 86 void testSimpleConnectFail(String certificate, bool cancelOnError) {
87 ReceivePort port = new ReceivePort(); 87 ReceivePort port = new ReceivePort();
88 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { 88 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) {
89 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port) 89 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port)
90 .then((clientEnd) { 90 .then((clientEnd) {
91 Expect.fail("No client connection expected."); 91 Expect.fail("No client connection expected.");
92 }) 92 })
93 .catchError((error) { 93 .catchError((error) {
94 Expect.isTrue(error is SocketIOException); 94 Expect.isTrue(error is SocketException);
95 }); 95 });
96 server.listen((serverEnd) { 96 server.listen((serverEnd) {
97 Expect.fail("No server connection expected."); 97 Expect.fail("No server connection expected.");
98 }, 98 },
99 onError: (error) { 99 onError: (error) {
100 Expect.isTrue(error is SocketIOException); 100 Expect.isTrue(error is SocketException);
101 clientEndFuture.then((_) { 101 clientEndFuture.then((_) {
102 if (!cancelOnError) server.close(); 102 if (!cancelOnError) server.close();
103 port.close(); 103 port.close();
104 }); 104 });
105 }, 105 },
106 cancelOnError: cancelOnError); 106 cancelOnError: cancelOnError);
107 }); 107 });
108 } 108 }
109 109
110 void testServerListenAfterConnect() { 110 void testServerListenAfterConnect() {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 testSimpleConnectFail("not_a_nickname", true); 454 testSimpleConnectFail("not_a_nickname", true);
455 testSimpleConnectFail("CN=notARealDistinguishedName", true); 455 testSimpleConnectFail("CN=notARealDistinguishedName", true);
456 testServerListenAfterConnect(); 456 testServerListenAfterConnect();
457 testSimpleReadWrite(true, true, false); 457 testSimpleReadWrite(true, true, false);
458 testSimpleReadWrite(true, false, false); 458 testSimpleReadWrite(true, false, false);
459 testSimpleReadWrite(false, true, false); 459 testSimpleReadWrite(false, true, false);
460 testSimpleReadWrite(false, false, false); 460 testSimpleReadWrite(false, false, false);
461 testSimpleReadWrite(false, false, true, true); 461 testSimpleReadWrite(false, false, true, true);
462 testSimpleReadWrite(false, false, true, false); 462 testSimpleReadWrite(false, false, true, false);
463 } 463 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_shutdown_test.dart ('k') | tests/standalone/io/raw_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698