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

Unified Diff: tests/standalone/io/web_socket_secure_test.dart

Issue 11886038: Change the WebSocket implementation to use Socket.read instead of Socket.readList (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/web_socket_protocol_processor_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_secure_test.dart
diff --git a/tests/standalone/io/web_socket_secure_test.dart b/tests/standalone/io/web_socket_secure_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6a749ce6eccd85fad219128b3d5e671eda964f1b
--- /dev/null
+++ b/tests/standalone/io/web_socket_secure_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:io";
+import "dart:uri";
+import "dart:isolate";
+
+const SERVER_ADDRESS = "127.0.0.1";
+const HOST_NAME = "localhost";
+
+void test() {
+ HttpsServer server = new HttpsServer();
+ var client = new HttpClient();
+
+ // Create a web socket handler and set is as the HTTP server default
Mads Ager (google) 2013/01/15 08:40:20 is as -> it as
+ // handler.
+ WebSocketHandler wsHandler = new WebSocketHandler();
+ wsHandler.onOpen = (WebSocketConnection conn) {
+ conn.onMessage = (Object message) => conn.send(message);
+ conn.onClosed = (status, reason) {
+ conn.close();
+ server.close();
+ client.shutdown();
+ };
+ };
+ server.defaultRequestHandler = wsHandler.onRequest;
+
+ server.onError = (Exception e) {
+ Expect.fail("Unexpected error in Https Server: $e");
+ };
+
+ server.listen(SERVER_ADDRESS,
+ 0,
+ backlog: 5,
+ certificate_name: "CN=$HOST_NAME");
+
+ // Connect web socket over HTTPS.
+ var conn = new WebSocketClientConnection(
+ client.getUrl(
+ new Uri.fromString("https://$HOST_NAME:${server.port}/")));
+ conn.onOpen = () {
+ conn.send("hello");
+ };
+ conn.onMessage = (msg) {
+ Expect.equals("hello", msg);
+ print(msg);
+ conn.close();
+ };
+
+}
+
+void InitializeSSL() {
+ var testPkcertDatabase =
+ new Path(new Options().script).directoryPath.append("pkcert/");
+ SecureSocket.initialize(database: testPkcertDatabase.toNativePath(),
+ password: "dartdart");
+}
+
+void main() {
+ InitializeSSL();
+ test();
+}
« no previous file with comments | « tests/standalone/io/web_socket_protocol_processor_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698