Chromium Code Reviews| Index: tests/standalone/io/raw_secure_server_socket_test.dart |
| diff --git a/tests/standalone/io/raw_secure_server_socket_test.dart b/tests/standalone/io/raw_secure_server_socket_test.dart |
| index 44cb7fc19e581abb14cf29b8344ee9fbdbf77361..d7ed598dd01c94b36cc6057058df52e97231f5ad 100644 |
| --- a/tests/standalone/io/raw_secure_server_socket_test.dart |
| +++ b/tests/standalone/io/raw_secure_server_socket_test.dart |
| @@ -472,6 +472,65 @@ void testSimpleReadWrite({bool listenSecure, |
| } |
| } |
| +testPausedSecuringSubscription(bool pausedServer, bool pausedClient) { |
| + asyncStart(); |
|
Bill Hesse
2014/02/10 12:50:14
Maybe bool expectFail = pausedServer || pausedClie
|
| + var clientComplete = new Completer(); |
| + RawServerSocket.bind(HOST_NAME, 0).then((server) { |
| + server.listen((client) { |
| + var subscription; |
| + subscription = client.listen((_) { |
| + if (pausedServer) { |
| + subscription.pause(); |
| + } |
| + RawSecureSocket.secureServer( |
| + client, CERTIFICATE, subscription: subscription).then((client) { |
| + if (pausedServer || pausedClient) { |
| + Expect.fail("secureServer succeeded with paused subscription"); |
| + } |
| + }).catchError((e) { |
| + if (!pausedServer && !pausedClient) { |
| + Expect.fail("secureServer failed with non-paused subscriptions"); |
| + } |
| + if (pausedServer) { |
| + Expect.isTrue(e is StateError); |
| + } |
| + }).whenComplete(() { |
| + server.close(); |
| + clientComplete.future.then((_) { |
| + client.close(); |
| + asyncEnd(); |
| + }); |
| + }); |
| + }); |
| + }); |
| + |
| + RawSocket.connect(HOST_NAME, server.port).then((socket) { |
| + var subscription; |
| + subscription = socket.listen((_) { |
| + if (pausedClient) { |
| + subscription.pause(); |
| + } |
| + RawSecureSocket.secure( |
| + socket, subscription: subscription).then((socket) { |
| + if (pausedServer || pausedClient) { |
| + Expect.fail("secure succeeded with paused subscription"); |
| + } |
| + socket.close(); |
| + }).catchError((e) { |
| + if (!pausedServer && !pausedClient) { |
| + Expect.fail("secure failed with non-paused subscriptions ($e)"); |
| + } |
| + if (pausedClient) { |
| + Expect.isTrue(e is StateError); |
| + } |
| + }).whenComplete(() { |
| + clientComplete.complete(null); |
| + }); |
| + }); |
| + }); |
| + }); |
| +} |
| + |
| main() { |
| var certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); |
| SecureSocket.initialize(database: certificateDatabase, |
| @@ -526,4 +585,8 @@ main() { |
| handshakeBeforeSecure: true, |
| postponeSecure: true, |
| dropReads: true); |
| + testPausedSecuringSubscription(false, false); |
| + testPausedSecuringSubscription(true, false); |
| + testPausedSecuringSubscription(false, true); |
| + testPausedSecuringSubscription(true, true); |
| } |