OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "net/base/address_list.h" | 7 #include "net/base/address_list.h" |
8 #include "net/base/host_resolver.h" | 8 #include "net/base/host_resolver.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // - Server sends data unexpectedly. | 250 // - Server sends data unexpectedly. |
251 | 251 |
252 TEST_F(SSLClientSocketTest, Read) { | 252 TEST_F(SSLClientSocketTest, Read) { |
253 StartOKServer(); | 253 StartOKServer(); |
254 | 254 |
255 net::AddressList addr; | 255 net::AddressList addr; |
256 TestCompletionCallback callback; | 256 TestCompletionCallback callback; |
257 | 257 |
258 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); | 258 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); |
259 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog()); | 259 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog()); |
| 260 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 261 |
| 262 rv = callback.WaitForResult(); |
260 EXPECT_EQ(net::OK, rv); | 263 EXPECT_EQ(net::OK, rv); |
261 | 264 |
262 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); | 265 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); |
263 rv = transport->Connect(&callback); | 266 rv = transport->Connect(&callback); |
264 if (rv == net::ERR_IO_PENDING) | 267 if (rv == net::ERR_IO_PENDING) |
265 rv = callback.WaitForResult(); | 268 rv = callback.WaitForResult(); |
266 EXPECT_EQ(net::OK, rv); | 269 EXPECT_EQ(net::OK, rv); |
267 | 270 |
268 scoped_ptr<net::SSLClientSocket> sock( | 271 scoped_ptr<net::SSLClientSocket> sock( |
269 socket_factory_->CreateSSLClientSocket(transport, | 272 socket_factory_->CreateSSLClientSocket(transport, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // This test also serves as a regression test for http://crbug.com/29815. | 312 // This test also serves as a regression test for http://crbug.com/29815. |
310 TEST_F(SSLClientSocketTest, Read_FullDuplex) { | 313 TEST_F(SSLClientSocketTest, Read_FullDuplex) { |
311 StartOKServer(); | 314 StartOKServer(); |
312 | 315 |
313 net::AddressList addr; | 316 net::AddressList addr; |
314 TestCompletionCallback callback; // Used for everything except Write. | 317 TestCompletionCallback callback; // Used for everything except Write. |
315 TestCompletionCallback callback2; // Used for Write only. | 318 TestCompletionCallback callback2; // Used for Write only. |
316 | 319 |
317 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); | 320 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); |
318 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog()); | 321 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog()); |
| 322 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 323 |
| 324 rv = callback.WaitForResult(); |
319 EXPECT_EQ(net::OK, rv); | 325 EXPECT_EQ(net::OK, rv); |
320 | 326 |
321 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); | 327 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); |
322 rv = transport->Connect(&callback); | 328 rv = transport->Connect(&callback); |
323 if (rv == net::ERR_IO_PENDING) | 329 if (rv == net::ERR_IO_PENDING) |
324 rv = callback.WaitForResult(); | 330 rv = callback.WaitForResult(); |
325 EXPECT_EQ(net::OK, rv); | 331 EXPECT_EQ(net::OK, rv); |
326 | 332 |
327 scoped_ptr<net::SSLClientSocket> sock( | 333 scoped_ptr<net::SSLClientSocket> sock( |
328 socket_factory_->CreateSSLClientSocket(transport, | 334 socket_factory_->CreateSSLClientSocket(transport, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 rv = callback.WaitForResult(); | 513 rv = callback.WaitForResult(); |
508 EXPECT_EQ(net::OK, rv); | 514 EXPECT_EQ(net::OK, rv); |
509 | 515 |
510 scoped_ptr<net::SSLClientSocket> sock( | 516 scoped_ptr<net::SSLClientSocket> sock( |
511 socket_factory_->CreateSSLClientSocket( | 517 socket_factory_->CreateSSLClientSocket( |
512 transport, server_.kHostName, kDefaultSSLConfig)); | 518 transport, server_.kHostName, kDefaultSSLConfig)); |
513 | 519 |
514 rv = sock->Connect(&callback); | 520 rv = sock->Connect(&callback); |
515 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); | 521 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); |
516 } | 522 } |
OLD | NEW |