Chromium Code Reviews| 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 72% |
| copy from tests/standalone/io/tls_server_test.dart |
| copy to tests/standalone/io/tls_server_stream_test.dart |
| index 372b114cb3f85c5e7826adcbd80b59ee172d21c2..1c904a4450e0f857480957abfd16bbb25211bd20 100644 |
| --- a/tests/standalone/io/tls_server_test.dart |
| +++ b/tests/standalone/io/tls_server_stream_test.dart |
| @@ -9,16 +9,13 @@ const HOST_NAME = "localhost"; |
| class TlsTestServer { |
| void onConnection(Socket connection) { |
| - connection.onConnect = () { |
| - numConnections++; |
| - }; |
| - connection.onData = () { |
| - var data = connection.read(); |
| - var received = new String.fromCharCodes(data); |
| + numConnections++; |
| + var input = connection.inputStream; |
| + input.onData = () { |
| + var received = new String.fromCharCodes(input.read()); |
|
Søren Gjesse
2012/11/20 21:13:07
The read is guaranteed to receive all the expected
Mads Ager (google)
2012/11/21 06:59:53
is *not* guaranteed. :-)
|
| 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); |
| + String name = received.substring(received.indexOf("client ") + 7); |
| + connection.outputStream.write("Welcome, client $name".charCodes); |
| }; |
| } |
| @@ -28,7 +25,7 @@ class TlsTestServer { |
| int start() { |
| server = new TlsServerSocket(SERVER_ADDRESS, 0, 10, "CN=$HOST_NAME"); |
| - Expect.isNotNull(server); |
| + Expect.equals(true, server != null); |
| server.onConnection = onConnection; |
| server.onError = errorHandlerServer; |
| return server.port; |
| @@ -45,22 +42,14 @@ class TlsTestServer { |
| class TlsTestClient { |
| TlsTestClient(int this.port, String this.name) { |
| socket = new TlsSocket(HOST_NAME, port); |
| - socket.onConnect = this.onConnect; |
| - socket.onData = this.onData; |
| - reply = ""; |
| - } |
| - |
| - void onConnect() { |
| numRequests++; |
| - var request_bytes = |
| - "Hello from client $name".charCodes; |
| - socket.writeList(request_bytes, 0, request_bytes.length); |
| + socket.outputStream.write("Hello from client $name".charCodes); |
| + socket.inputStream.onData = this.onData; |
| + reply = ""; |
| } |
| void onData() { |
| - var data = socket.read(); |
| - var received = new String.fromCharCodes(data); |
| - reply = reply.concat(received); |
| + reply = reply.concat(new String.fromCharCodes(socket.inputStream.read())); |
|
Søren Gjesse
2012/11/20 21:13:07
Ditto.
|
| if (reply.contains("Welcome") && reply.contains(name)) { |
| done(); |
| } |
| @@ -68,7 +57,7 @@ class TlsTestClient { |
| void done() { |
| Expect.equals("Welcome, client $name", reply); |
| - socket.close(true); |
| + socket.outputStream.close(); |
| numReplies++; |
| if (numReplies == CLIENT_NAMES.length) { |
| Expect.equals(numRequests, numReplies); |