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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 1783008: Cleanup: Remove the implicit constructor for BoundNetLog that allowed passing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Sync Created 10 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/socks_client_socket_pool_unittest.cc ('k') | net/socket/ssl_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 //----------------------------------------------------------------------------- 59 //-----------------------------------------------------------------------------
60 60
61 TEST_F(SSLClientSocketTest, Connect) { 61 TEST_F(SSLClientSocketTest, Connect) {
62 StartOKServer(); 62 StartOKServer();
63 63
64 net::AddressList addr; 64 net::AddressList addr;
65 TestCompletionCallback callback; 65 TestCompletionCallback callback;
66 66
67 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); 67 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
68 int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL); 68 int rv = resolver_->Resolve(info, &addr, NULL, NULL, net::BoundNetLog());
69 EXPECT_EQ(net::OK, rv); 69 EXPECT_EQ(net::OK, rv);
70 70
71 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); 71 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
72 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log); 72 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
73 rv = transport->Connect(&callback); 73 rv = transport->Connect(&callback);
74 if (rv == net::ERR_IO_PENDING) 74 if (rv == net::ERR_IO_PENDING)
75 rv = callback.WaitForResult(); 75 rv = callback.WaitForResult();
76 EXPECT_EQ(net::OK, rv); 76 EXPECT_EQ(net::OK, rv);
77 77
78 scoped_ptr<net::SSLClientSocket> sock( 78 scoped_ptr<net::SSLClientSocket> sock(
(...skipping 23 matching lines...) Expand all
102 EXPECT_FALSE(sock->IsConnected()); 102 EXPECT_FALSE(sock->IsConnected());
103 } 103 }
104 104
105 TEST_F(SSLClientSocketTest, ConnectExpired) { 105 TEST_F(SSLClientSocketTest, ConnectExpired) {
106 StartExpiredServer(); 106 StartExpiredServer();
107 107
108 net::AddressList addr; 108 net::AddressList addr;
109 TestCompletionCallback callback; 109 TestCompletionCallback callback;
110 110
111 net::HostResolver::RequestInfo info(server_.kHostName, server_.kBadHTTPSPort); 111 net::HostResolver::RequestInfo info(server_.kHostName, server_.kBadHTTPSPort);
112 int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL); 112 int rv = resolver_->Resolve(info, &addr, NULL, NULL, net::BoundNetLog());
113 EXPECT_EQ(net::OK, rv); 113 EXPECT_EQ(net::OK, rv);
114 114
115 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); 115 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
116 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log); 116 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
117 rv = transport->Connect(&callback); 117 rv = transport->Connect(&callback);
118 if (rv == net::ERR_IO_PENDING) 118 if (rv == net::ERR_IO_PENDING)
119 rv = callback.WaitForResult(); 119 rv = callback.WaitForResult();
120 EXPECT_EQ(net::OK, rv); 120 EXPECT_EQ(net::OK, rv);
121 121
122 scoped_ptr<net::SSLClientSocket> sock( 122 scoped_ptr<net::SSLClientSocket> sock(
(...skipping 24 matching lines...) Expand all
147 } 147 }
148 148
149 TEST_F(SSLClientSocketTest, ConnectMismatched) { 149 TEST_F(SSLClientSocketTest, ConnectMismatched) {
150 StartMismatchedServer(); 150 StartMismatchedServer();
151 151
152 net::AddressList addr; 152 net::AddressList addr;
153 TestCompletionCallback callback; 153 TestCompletionCallback callback;
154 154
155 net::HostResolver::RequestInfo info(server_.kMismatchedHostName, 155 net::HostResolver::RequestInfo info(server_.kMismatchedHostName,
156 server_.kOKHTTPSPort); 156 server_.kOKHTTPSPort);
157 int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL); 157 int rv = resolver_->Resolve(info, &addr, NULL, NULL, net::BoundNetLog());
158 EXPECT_EQ(net::OK, rv); 158 EXPECT_EQ(net::OK, rv);
159 159
160 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); 160 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded);
161 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log); 161 net::ClientSocket* transport = new net::TCPClientSocket(addr, &log);
162 rv = transport->Connect(&callback); 162 rv = transport->Connect(&callback);
163 if (rv == net::ERR_IO_PENDING) 163 if (rv == net::ERR_IO_PENDING)
164 rv = callback.WaitForResult(); 164 rv = callback.WaitForResult();
165 EXPECT_EQ(net::OK, rv); 165 EXPECT_EQ(net::OK, rv);
166 166
167 scoped_ptr<net::SSLClientSocket> sock( 167 scoped_ptr<net::SSLClientSocket> sock(
(...skipping 28 matching lines...) Expand all
196 // - Server closes the underlying TCP connection directly. 196 // - Server closes the underlying TCP connection directly.
197 // - Server sends data unexpectedly. 197 // - Server sends data unexpectedly.
198 198
199 TEST_F(SSLClientSocketTest, Read) { 199 TEST_F(SSLClientSocketTest, Read) {
200 StartOKServer(); 200 StartOKServer();
201 201
202 net::AddressList addr; 202 net::AddressList addr;
203 TestCompletionCallback callback; 203 TestCompletionCallback callback;
204 204
205 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); 205 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
206 int rv = resolver_->Resolve(info, &addr, &callback, NULL, NULL); 206 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog());
207 EXPECT_EQ(net::ERR_IO_PENDING, rv); 207 EXPECT_EQ(net::ERR_IO_PENDING, rv);
208 208
209 rv = callback.WaitForResult(); 209 rv = callback.WaitForResult();
210 EXPECT_EQ(net::OK, rv); 210 EXPECT_EQ(net::OK, rv);
211 211
212 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); 212 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
213 rv = transport->Connect(&callback); 213 rv = transport->Connect(&callback);
214 if (rv == net::ERR_IO_PENDING) 214 if (rv == net::ERR_IO_PENDING)
215 rv = callback.WaitForResult(); 215 rv = callback.WaitForResult();
216 EXPECT_EQ(net::OK, rv); 216 EXPECT_EQ(net::OK, rv);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Test the full duplex mode, with Read and Write pending at the same time. 258 // Test the full duplex mode, with Read and Write pending at the same time.
259 // This test also serves as a regression test for http://crbug.com/29815. 259 // This test also serves as a regression test for http://crbug.com/29815.
260 TEST_F(SSLClientSocketTest, Read_FullDuplex) { 260 TEST_F(SSLClientSocketTest, Read_FullDuplex) {
261 StartOKServer(); 261 StartOKServer();
262 262
263 net::AddressList addr; 263 net::AddressList addr;
264 TestCompletionCallback callback; // Used for everything except Write. 264 TestCompletionCallback callback; // Used for everything except Write.
265 TestCompletionCallback callback2; // Used for Write only. 265 TestCompletionCallback callback2; // Used for Write only.
266 266
267 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); 267 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
268 int rv = resolver_->Resolve(info, &addr, &callback, NULL, NULL); 268 int rv = resolver_->Resolve(info, &addr, &callback, NULL, net::BoundNetLog());
269 EXPECT_EQ(net::ERR_IO_PENDING, rv); 269 EXPECT_EQ(net::ERR_IO_PENDING, rv);
270 270
271 rv = callback.WaitForResult(); 271 rv = callback.WaitForResult();
272 EXPECT_EQ(net::OK, rv); 272 EXPECT_EQ(net::OK, rv);
273 273
274 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); 274 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
275 rv = transport->Connect(&callback); 275 rv = transport->Connect(&callback);
276 if (rv == net::ERR_IO_PENDING) 276 if (rv == net::ERR_IO_PENDING)
277 rv = callback.WaitForResult(); 277 rv = callback.WaitForResult();
278 EXPECT_EQ(net::OK, rv); 278 EXPECT_EQ(net::OK, rv);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 EXPECT_GT(rv, 0); 320 EXPECT_GT(rv, 0);
321 } 321 }
322 322
323 TEST_F(SSLClientSocketTest, Read_SmallChunks) { 323 TEST_F(SSLClientSocketTest, Read_SmallChunks) {
324 StartOKServer(); 324 StartOKServer();
325 325
326 net::AddressList addr; 326 net::AddressList addr;
327 TestCompletionCallback callback; 327 TestCompletionCallback callback;
328 328
329 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); 329 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
330 int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL); 330 int rv = resolver_->Resolve(info, &addr, NULL, NULL, net::BoundNetLog());
331 EXPECT_EQ(net::OK, rv); 331 EXPECT_EQ(net::OK, rv);
332 332
333 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); 333 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
334 rv = transport->Connect(&callback); 334 rv = transport->Connect(&callback);
335 if (rv == net::ERR_IO_PENDING) 335 if (rv == net::ERR_IO_PENDING)
336 rv = callback.WaitForResult(); 336 rv = callback.WaitForResult();
337 EXPECT_EQ(net::OK, rv); 337 EXPECT_EQ(net::OK, rv);
338 338
339 scoped_ptr<net::SSLClientSocket> sock( 339 scoped_ptr<net::SSLClientSocket> sock(
340 socket_factory_->CreateSSLClientSocket(transport, 340 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 } 375 }
376 376
377 TEST_F(SSLClientSocketTest, Read_Interrupted) { 377 TEST_F(SSLClientSocketTest, Read_Interrupted) {
378 StartOKServer(); 378 StartOKServer();
379 379
380 net::AddressList addr; 380 net::AddressList addr;
381 TestCompletionCallback callback; 381 TestCompletionCallback callback;
382 382
383 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort); 383 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
384 int rv = resolver_->Resolve(info, &addr, NULL, NULL, NULL); 384 int rv = resolver_->Resolve(info, &addr, NULL, NULL, net::BoundNetLog());
385 EXPECT_EQ(net::OK, rv); 385 EXPECT_EQ(net::OK, rv);
386 386
387 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL); 387 net::ClientSocket* transport = new net::TCPClientSocket(addr, NULL);
388 rv = transport->Connect(&callback); 388 rv = transport->Connect(&callback);
389 if (rv == net::ERR_IO_PENDING) 389 if (rv == net::ERR_IO_PENDING)
390 rv = callback.WaitForResult(); 390 rv = callback.WaitForResult();
391 EXPECT_EQ(net::OK, rv); 391 EXPECT_EQ(net::OK, rv);
392 392
393 scoped_ptr<net::SSLClientSocket> sock( 393 scoped_ptr<net::SSLClientSocket> sock(
394 socket_factory_->CreateSSLClientSocket(transport, 394 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 22 matching lines...) Expand all
417 // Do a partial read and then exit. This test should not crash! 417 // Do a partial read and then exit. This test should not crash!
418 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(512); 418 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(512);
419 rv = sock->Read(buf, 512, &callback); 419 rv = sock->Read(buf, 512, &callback);
420 EXPECT_TRUE(rv > 0 || rv == net::ERR_IO_PENDING); 420 EXPECT_TRUE(rv > 0 || rv == net::ERR_IO_PENDING);
421 421
422 if (rv == net::ERR_IO_PENDING) 422 if (rv == net::ERR_IO_PENDING)
423 rv = callback.WaitForResult(); 423 rv = callback.WaitForResult();
424 424
425 EXPECT_GT(rv, 0); 425 EXPECT_GT(rv, 0);
426 } 426 }
OLDNEW
« no previous file with comments | « net/socket/socks_client_socket_pool_unittest.cc ('k') | net/socket/ssl_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698