| Index: net/base/ssl_client_socket_unittest.cc
|
| ===================================================================
|
| --- net/base/ssl_client_socket_unittest.cc (revision 12708)
|
| +++ net/base/ssl_client_socket_unittest.cc (working copy)
|
| @@ -79,8 +79,14 @@
|
| &addr, NULL);
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kHostName, kDefaultSSLConfig));
|
|
|
| EXPECT_FALSE(sock->IsConnected());
|
| @@ -111,8 +117,14 @@
|
| &addr, NULL);
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kHostName, kDefaultSSLConfig));
|
|
|
| EXPECT_FALSE(sock->IsConnected());
|
| @@ -126,7 +138,9 @@
|
| EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv);
|
| }
|
|
|
| - EXPECT_TRUE(sock->IsConnected());
|
| + // We cannot test sock->IsConnected(), as the NSS implementation disconnects
|
| + // the socket when it encounters an error, whereas other implementations
|
| + // leave it connected.
|
| }
|
|
|
| TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
|
| @@ -140,8 +154,14 @@
|
| &addr, NULL);
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kMismatchedHostName, kDefaultSSLConfig));
|
|
|
| EXPECT_FALSE(sock->IsConnected());
|
| @@ -155,13 +175,9 @@
|
| EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, rv);
|
| }
|
|
|
| - // The Windows code happens to keep the connection
|
| - // open now in spite of an error. The designers of
|
| - // this API intended to also allow the connection
|
| - // to be closed on error, in which case the caller
|
| - // should call ReconnectIgnoringLastError, but
|
| - // that's currently unimplemented.
|
| - EXPECT_TRUE(sock->IsConnected());
|
| + // We cannot test sock->IsConnected(), as the NSS implementation disconnects
|
| + // the socket when it encounters an error, whereas other implementations
|
| + // leave it connected.
|
| }
|
|
|
| // TODO(wtc): Add unit tests for IsConnectedAndIdle:
|
| @@ -183,8 +199,14 @@
|
| rv = callback.WaitForResult();
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kHostName,
|
| kDefaultSSLConfig));
|
|
|
| @@ -231,8 +253,14 @@
|
| &addr, NULL);
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kHostName, kDefaultSSLConfig));
|
|
|
| rv = sock->Connect(&callback);
|
| @@ -277,8 +305,14 @@
|
| &addr, NULL);
|
| EXPECT_EQ(net::OK, rv);
|
|
|
| + net::ClientSocket *transport = new net::TCPClientSocket(addr);
|
| + rv = transport->Connect(&callback);
|
| + if (rv == net::ERR_IO_PENDING)
|
| + rv = callback.WaitForResult();
|
| + EXPECT_EQ(net::OK, rv);
|
| +
|
| scoped_ptr<net::SSLClientSocket> sock(
|
| - socket_factory_->CreateSSLClientSocket(new net::TCPClientSocket(addr),
|
| + socket_factory_->CreateSSLClientSocket(transport,
|
| server_.kHostName, kDefaultSSLConfig));
|
|
|
| rv = sock->Connect(&callback);
|
|
|