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

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

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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 24 matching lines...) Expand all
35 } 35 }
36 36
37 void testInvalidBind() { 37 void testInvalidBind() {
38 int count = 0; 38 int count = 0;
39 ReceivePort port = new ReceivePort(); 39 ReceivePort port = new ReceivePort();
40 port.receive((_, __) { count++; if (count == 3) port.close(); }); 40 port.receive((_, __) { count++; if (count == 3) port.close(); });
41 41
42 // Bind to a unknown DNS name. 42 // Bind to a unknown DNS name.
43 RawSecureServerSocket.bind("ko.faar.__hest__", 0, 5, CERTIFICATE).then((_) { 43 RawSecureServerSocket.bind("ko.faar.__hest__", 0, 5, CERTIFICATE).then((_) {
44 Expect.fail("Failure expected"); 44 Expect.fail("Failure expected");
45 }).catchError((e) { 45 }).catchError((error) {
46 Expect.isTrue(e.error is SocketIOException); 46 Expect.isTrue(error is SocketIOException);
47 port.toSendPort().send(1); 47 port.toSendPort().send(1);
48 }); 48 });
49 49
50 // Bind to an unavaliable IP-address. 50 // Bind to an unavaliable IP-address.
51 RawSecureServerSocket.bind("8.8.8.8", 0, 5, CERTIFICATE).then((_) { 51 RawSecureServerSocket.bind("8.8.8.8", 0, 5, CERTIFICATE).then((_) {
52 Expect.fail("Failure expected"); 52 Expect.fail("Failure expected");
53 }).catchError((e) { 53 }).catchError((error) {
54 Expect.isTrue(e.error is SocketIOException); 54 Expect.isTrue(error is SocketIOException);
55 port.toSendPort().send(1); 55 port.toSendPort().send(1);
56 }); 56 });
57 57
58 // Bind to a port already in use. 58 // Bind to a port already in use.
59 // Either an error or a successful bind is allowed. 59 // Either an error or a successful bind is allowed.
60 // Windows platforms allow multiple binding to the same socket, with 60 // Windows platforms allow multiple binding to the same socket, with
61 // unpredictable results. 61 // unpredictable results.
62 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((s) { 62 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((s) {
63 RawSecureServerSocket.bind(SERVER_ADDRESS, 63 RawSecureServerSocket.bind(SERVER_ADDRESS,
64 s.port, 64 s.port,
65 5, 65 5,
66 CERTIFICATE).then((t) { 66 CERTIFICATE).then((t) {
67 Expect.equals('windows', Platform.operatingSystem); 67 Expect.equals('windows', Platform.operatingSystem);
68 Expect.equals(s.port, t.port); 68 Expect.equals(s.port, t.port);
69 s.close(); 69 s.close();
70 t.close(); 70 t.close();
71 port.toSendPort().send(1); 71 port.toSendPort().send(1);
72 }) 72 })
73 .catchError((e) { 73 .catchError((error) {
74 Expect.notEquals('windows', Platform.operatingSystem); 74 Expect.notEquals('windows', Platform.operatingSystem);
75 Expect.isTrue(e.error is SocketIOException); 75 Expect.isTrue(error is SocketIOException);
76 s.close(); 76 s.close();
77 port.toSendPort().send(1); 77 port.toSendPort().send(1);
78 }); 78 });
79 }); 79 });
80 } 80 }
81 81
82 void testSimpleConnect(String certificate) { 82 void testSimpleConnect(String certificate) {
83 ReceivePort port = new ReceivePort(); 83 ReceivePort port = new ReceivePort();
84 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, certificate).then((server) { 84 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, certificate).then((server) {
85 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port); 85 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port);
86 server.listen((serverEnd) { 86 server.listen((serverEnd) {
87 clientEndFuture.then((clientEnd) { 87 clientEndFuture.then((clientEnd) {
88 clientEnd.shutdown(SocketDirection.SEND); 88 clientEnd.shutdown(SocketDirection.SEND);
89 serverEnd.shutdown(SocketDirection.SEND); 89 serverEnd.shutdown(SocketDirection.SEND);
90 server.close(); 90 server.close();
91 port.close(); 91 port.close();
92 }); 92 });
93 }); 93 });
94 }); 94 });
95 } 95 }
96 96
97 void testSimpleConnectFail(String certificate) { 97 void testSimpleConnectFail(String certificate) {
98 ReceivePort port = new ReceivePort(); 98 ReceivePort port = new ReceivePort();
99 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, certificate).then((server) { 99 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, certificate).then((server) {
100 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port) 100 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port)
101 .then((clientEnd) { 101 .then((clientEnd) {
102 Expect.fail("No client connection expected."); 102 Expect.fail("No client connection expected.");
103 }) 103 })
104 .catchError((e) { 104 .catchError((error) {
105 Expect.isTrue(e is AsyncError); 105 Expect.isTrue(error is SocketIOException);
106 Expect.isTrue(e.error is SocketIOException);
107 }); 106 });
108 server.listen((serverEnd) { 107 server.listen((serverEnd) {
109 Expect.fail("No server connection expected."); 108 Expect.fail("No server connection expected.");
110 }, 109 },
111 onError: (e) { 110 onError: (error) {
112 Expect.isTrue(e is AsyncError); 111 Expect.isTrue(error is SocketIOException);
113 Expect.isTrue(e.error is SocketIOException);
114 clientEndFuture.then((_) => port.close()); 112 clientEndFuture.then((_) => port.close());
115 }); 113 });
116 }); 114 });
117 } 115 }
118 116
119 void testServerListenAfterConnect() { 117 void testServerListenAfterConnect() {
120 ReceivePort port = new ReceivePort(); 118 ReceivePort port = new ReceivePort();
121 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) { 119 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) {
122 Expect.isTrue(server.port > 0); 120 Expect.isTrue(server.port > 0);
123 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port); 121 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 testArguments(); 253 testArguments();
256 testSimpleBind(); 254 testSimpleBind();
257 testInvalidBind(); 255 testInvalidBind();
258 testSimpleConnect(CERTIFICATE); 256 testSimpleConnect(CERTIFICATE);
259 testSimpleConnect("CN=localhost"); 257 testSimpleConnect("CN=localhost");
260 testSimpleConnectFail("not_a_nickname"); 258 testSimpleConnectFail("not_a_nickname");
261 testSimpleConnectFail("CN=notARealDistinguishedName"); 259 testSimpleConnectFail("CN=notARealDistinguishedName");
262 testServerListenAfterConnect(); 260 testServerListenAfterConnect();
263 testSimpleReadWrite(); 261 testSimpleReadWrite();
264 } 262 }
OLDNEW
« no previous file with comments | « tests/standalone/io/process_start_exception_test.dart ('k') | tests/standalone/io/raw_secure_socket_pause_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698