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

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

Issue 11417116: Fix secure socket tests to close sockets after writing. Fix handling of close events in TlsSocket … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment Created 8 years, 1 month 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/tls_server_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/tls_socket_test.dart
diff --git a/tests/standalone/io/tls_socket_test.dart b/tests/standalone/io/tls_socket_test.dart
index 061d93f8f5af2564acdc436cdbb93723b8d2d62a..1a82d2d949b9d873fa939f8381163413b2c2d21e 100644
--- a/tests/standalone/io/tls_socket_test.dart
+++ b/tests/standalone/io/tls_socket_test.dart
@@ -11,6 +11,20 @@
#import("dart:isolate");
#import("dart:io");
+void WriteAndClose(Socket socket, String message) {
+ var data = message.charCodes;
+ int written = 0;
+ void write() {
+ written += socket.writeList(data, written, data.length - written);
+ if (written < data.length) {
+ socket.onWrite = write;
+ } else {
+ socket.close(true);
+ }
+ }
+ write();
+}
+
void main() {
var testPkcertDatabase =
new Path.fromNative(new Options().script).directoryPath.append('pkcert/');
@@ -22,10 +36,7 @@ void main() {
var tls = new TlsSocket("www.google.dk", 443);
List<String> chunks = <String>[];
tls.onConnect = () {
- var request_bytes =
- "GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n".charCodes;
- tls.writeList(request_bytes, 0, 20);
- tls.writeList(request_bytes, 20, request_bytes.length - 20);
+ WriteAndClose(tls, "GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n");
};
var useReadList; // Mutually recursive onData callbacks.
void useRead() {
@@ -45,6 +56,5 @@ void main() {
tls.onClosed = () {
String fullPage = Strings.concatAll(chunks);
Expect.isTrue(fullPage.contains('</body></html>'));
- tls.close();
};
}
« no previous file with comments | « tests/standalone/io/tls_server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698