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

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

Issue 12328037: Add missing files from previous commit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/raw_secure_socket_pause_test.dart ('k') | tests/standalone/io/raw_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/raw_secure_socket_test.dart
diff --git a/tests/standalone/io/raw_secure_socket_test.dart b/tests/standalone/io/raw_secure_socket_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b7f70689af0f5b208d2e784a0386d053603b706c
--- /dev/null
+++ b/tests/standalone/io/raw_secure_socket_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2012, 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.
+//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+
+import "dart:async";
+import "dart:io";
+import "dart:isolate";
+
+
+void main() {
+ List<int> message = "GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n".charCodes;
+ int written = 0;
+ List<String> chunks = <String>[];
+ SecureSocket.initialize();
+ // TODO(3593): Use a Dart HTTPS server for this test.
+ RawSecureSocket.connect("www.google.dk", 443).then((socket) {
+ socket.listen((RawSocketEvent event) {
+ switch (event) {
+ case RawSocketEvent.READ:
+ var data = socket.read();
+ var received = new String.fromCharCodes(data);
+ chunks.add(received);
+ break;
+ case RawSocketEvent.WRITE:
+ written +=
+ socket.write(message, written, message.length - written);
+ if (written < message.length) {
+ socket.writeEventsEnabled = true;
+ } else {
+ socket.shutdown(SocketDirection.SEND);
+ }
+ break;
+ case RawSocketEvent.READ_CLOSED:
+ String fullPage = chunks.join();
+ Expect.isTrue(fullPage.contains('</body></html>'));
+ break;
+ default: throw "Unexpected event $event";
+ }
+ }, onError: (AsyncError a) {
+ Expect.fail("onError handler of RawSecureSocket stream hit: $a");
+ });
+ });
+}
« no previous file with comments | « tests/standalone/io/raw_secure_socket_pause_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