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

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

Issue 11416108: Implement input and output streams for secure network sockets. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase to secure sockets with correct close(true) behavior. 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 | « sdk/lib/io/tls_socket.dart ('k') | tests/standalone/io/tls_stream_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/tls_server_stream_test.dart
diff --git a/tests/standalone/io/tls_server_test.dart b/tests/standalone/io/tls_server_stream_test.dart
similarity index 71%
copy from tests/standalone/io/tls_server_test.dart
copy to tests/standalone/io/tls_server_stream_test.dart
index 32792d77aec1487320f526cd98756fa13998aff0..1b4599124288638679bc3137b4b4e2efe94b86b9 100644
--- a/tests/standalone/io/tls_server_test.dart
+++ b/tests/standalone/io/tls_server_stream_test.dart
@@ -7,33 +7,19 @@ import "dart:io";
const SERVER_ADDRESS = "127.0.0.1";
const HOST_NAME = "localhost";
-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();
-}
-
class TlsTestServer {
void onConnection(Socket connection) {
- connection.onConnect = () {
- numConnections++;
- };
+ numConnections++;
+ var input = connection.inputStream;
String received = "";
- connection.onData = () {
- received = received.concat(new String.fromCharCodes(connection.read()));
+ input.onData = () {
+ received = received.concat(new String.fromCharCodes(input.read()));
};
- connection.onClosed = () {
+ input.onClosed = () {
Expect.isTrue(received.contains("Hello from client "));
String name = received.substring(received.indexOf("client ") + 7);
- WriteAndClose(connection, "Welcome, client $name");
+ connection.outputStream.write("Welcome, client $name".charCodes);
+ connection.outputStream.close();
};
}
@@ -60,19 +46,16 @@ class TlsTestServer {
class TlsTestClient {
TlsTestClient(int this.port, String this.name) {
socket = new TlsSocket(HOST_NAME, port);
- socket.onConnect = this.onConnect;
- socket.onData = () {
- reply = reply.concat(new String.fromCharCodes(socket.read()));
+ numRequests++;
+ socket.outputStream.write("Hello from client $name".charCodes);
+ socket.outputStream.close();
+ socket.inputStream.onData = () {
+ reply = reply.concat(new String.fromCharCodes(socket.inputStream.read()));
};
- socket.onClosed = done;
+ socket.inputStream.onClosed = this.done;
reply = "";
}
- void onConnect() {
- numRequests++;
- WriteAndClose(socket, "Hello from client $name");
- }
-
void done() {
Expect.equals("Welcome, client $name", reply);
numReplies++;
« no previous file with comments | « sdk/lib/io/tls_socket.dart ('k') | tests/standalone/io/tls_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698