| OLD | NEW |
| 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 library dart.io; | 10 library dart.io; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 closeCount++; | 87 closeCount++; |
| 88 if (closeCount == totalConnections) { | 88 if (closeCount == totalConnections) { |
| 89 server.close(); | 89 server.close(); |
| 90 } | 90 } |
| 91 }); | 91 }); |
| 92 }); | 92 }); |
| 93 } | 93 } |
| 94 }); | 94 }); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void testAddErrorServer() { | |
| 98 asyncStart(); | |
| 99 asyncStart(); | |
| 100 asyncStart(); | |
| 101 asyncStart(); | |
| 102 createServer().then((server) { | |
| 103 server.transform(new WebSocketTransformer()).listen((webSocket) { | |
| 104 webSocket.listen( | |
| 105 (message) { | |
| 106 webSocket.addError("ERROR"); | |
| 107 }, | |
| 108 onDone: () { | |
| 109 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE, | |
| 110 webSocket.closeCode); | |
| 111 server.close(); | |
| 112 }, | |
| 113 onError: (e) { | |
| 114 Expect.equals("ERROR", e); | |
| 115 asyncEnd(); | |
| 116 }); | |
| 117 | |
| 118 webSocket.done.then((_) { | |
| 119 Expect.fail("unexpected done completion"); | |
| 120 }).catchError((e) { | |
| 121 Expect.equals("ERROR", e); | |
| 122 asyncEnd(); | |
| 123 }); | |
| 124 }, onDone: () { | |
| 125 asyncEnd(); | |
| 126 }); | |
| 127 | |
| 128 createClient(server.port).then((webSocket) { | |
| 129 webSocket.add("message"); | |
| 130 webSocket.listen( | |
| 131 (message) { | |
| 132 Expect.fail("unexpected message"); | |
| 133 }, | |
| 134 onDone: () { | |
| 135 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE, | |
| 136 webSocket.closeCode); | |
| 137 server.close(); | |
| 138 asyncEnd(); | |
| 139 }, | |
| 140 onError: (e) { | |
| 141 Expect.fail("unexpected onError"); | |
| 142 }); | |
| 143 | |
| 144 }); | |
| 145 }); | |
| 146 } | |
| 147 | |
| 148 void testAddErrorClient() { | |
| 149 asyncStart(); | |
| 150 asyncStart(); | |
| 151 asyncStart(); | |
| 152 asyncStart(); | |
| 153 createServer().then((server) { | |
| 154 server.transform(new WebSocketTransformer()).listen((webSocket) { | |
| 155 webSocket.listen( | |
| 156 (message) { | |
| 157 Expect.fail("unexpected message"); | |
| 158 }, | |
| 159 onDone: () { | |
| 160 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE, | |
| 161 webSocket.closeCode); | |
| 162 asyncEnd(); | |
| 163 }); | |
| 164 }, onDone: () { | |
| 165 asyncEnd(); | |
| 166 }); | |
| 167 | |
| 168 createClient(server.port).then((webSocket) { | |
| 169 webSocket.addError("ERROR"); | |
| 170 webSocket.listen( | |
| 171 (message) { | |
| 172 Expect.fail("unexpected message"); | |
| 173 }, | |
| 174 onDone: () { | |
| 175 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE, | |
| 176 webSocket.closeCode); | |
| 177 server.close(); | |
| 178 }, | |
| 179 onError: (e) { | |
| 180 Expect.equals("ERROR", e); | |
| 181 asyncEnd(); | |
| 182 }); | |
| 183 | |
| 184 webSocket.done.then((_) { | |
| 185 Expect.fail("unexpected done completion"); | |
| 186 }).catchError((e) { | |
| 187 Expect.equals("ERROR", e); | |
| 188 asyncEnd(); | |
| 189 }); | |
| 190 }); | |
| 191 }); | |
| 192 } | |
| 193 | |
| 194 void runTests() { | 97 void runTests() { |
| 195 testForceCloseServerEnd(10); | 98 testForceCloseServerEnd(10); |
| 196 testAddErrorServer(); | |
| 197 testAddErrorClient(); | |
| 198 } | 99 } |
| 199 } | 100 } |
| 200 | 101 |
| 201 | 102 |
| 202 main() { | 103 main() { |
| 203 asyncStart(); | 104 asyncStart(); |
| 204 new SecurityConfiguration(secure: false).runTests(); | 105 new SecurityConfiguration(secure: false).runTests(); |
| 205 // TODO(whesse): WebSocket.connect needs an optional context: parameter | 106 // TODO(whesse): WebSocket.connect needs an optional context: parameter |
| 206 // new SecurityConfiguration(secure: true).runTests(); | 107 // new SecurityConfiguration(secure: true).runTests(); |
| 207 asyncEnd(); | 108 asyncEnd(); |
| 208 } | 109 } |
| 209 | 110 |
| OLD | NEW |