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

Unified Diff: tests/standalone/io/tls_server_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: Improve comments and code. 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
Index: tests/standalone/io/tls_server_test.dart
diff --git a/tests/standalone/io/tls_server_test.dart b/tests/standalone/io/tls_server_test.dart
index 165c1ef85e632d1996b0d139800cb306a2bc244b..9d3c7cf6e4a0649816d755da28a75cc7029e4280 100644
--- a/tests/standalone/io/tls_server_test.dart
+++ b/tests/standalone/io/tls_server_test.dart
@@ -12,13 +12,16 @@ class TlsTestServer {
connection.onConnect = () {
numConnections++;
};
+ String received = "";
connection.onData = () {
- var data = connection.read();
- var received = new String.fromCharCodes(data);
+ received = received.concat(new String.fromCharCodes(connection.read()));
+ };
+ connection.onClosed = () {
Expect.isTrue(received.contains("Hello from client "));
String name = received.substring(received.indexOf("client ") + 7);
var reply_bytes = "Welcome, client $name".charCodes;
connection.writeList(reply_bytes, 0, reply_bytes.length);
+ connection.close(true);
};
}
@@ -46,7 +49,10 @@ class TlsTestClient {
TlsTestClient(int this.port, String this.name) {
socket = new TlsSocket(HOST_NAME, port);
socket.onConnect = this.onConnect;
- socket.onData = this.onData;
+ socket.onData = () {
+ reply = reply.concat(new String.fromCharCodes(socket.read()));
+ };
+ socket.onClosed = done;
reply = "";
}
@@ -55,20 +61,11 @@ class TlsTestClient {
var request_bytes =
"Hello from client $name".charCodes;
socket.writeList(request_bytes, 0, request_bytes.length);
- }
-
- void onData() {
- var data = socket.read();
- var received = new String.fromCharCodes(data);
- reply = reply.concat(received);
- if (reply.contains("Welcome") && reply.contains(name)) {
- done();
- }
+ socket.close(true);
}
void done() {
Expect.equals("Welcome, client $name", reply);
- socket.close(true);
numReplies++;
if (numReplies == CLIENT_NAMES.length) {
Expect.equals(numRequests, numReplies);

Powered by Google App Engine
This is Rietveld 408576698