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

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

Issue 125107: * Move the global "DnsResolutionObserver" code depended on by DNS prefetcher,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address jar's comments Created 11 years, 6 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/base/host_resolver_unittest.cc ('k') | net/base/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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/address_list.h" 5 #include "net/base/address_list.h"
6 #include "net/base/client_socket_factory.h" 6 #include "net/base/client_socket_factory.h"
7 #include "net/base/host_resolver.h" 7 #include "net/base/host_resolver.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/ssl_client_socket.h" 10 #include "net/base/ssl_client_socket.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #define MAYBE_Read_Interrupted Read_Interrupted 69 #define MAYBE_Read_Interrupted Read_Interrupted
70 #endif 70 #endif
71 71
72 TEST_F(SSLClientSocketTest, MAYBE_Connect) { 72 TEST_F(SSLClientSocketTest, MAYBE_Connect) {
73 StartOKServer(); 73 StartOKServer();
74 74
75 net::AddressList addr; 75 net::AddressList addr;
76 net::HostResolver resolver; 76 net::HostResolver resolver;
77 TestCompletionCallback callback; 77 TestCompletionCallback callback;
78 78
79 int rv = resolver.Resolve(server_.kHostName, server_.kOKHTTPSPort, 79 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
80 &addr, NULL, NULL); 80 int rv = resolver.Resolve(info, &addr, NULL, NULL);
81 EXPECT_EQ(net::OK, rv); 81 EXPECT_EQ(net::OK, rv);
82 82
83 net::ClientSocket *transport = new net::TCPClientSocket(addr); 83 net::ClientSocket *transport = new net::TCPClientSocket(addr);
84 rv = transport->Connect(&callback); 84 rv = transport->Connect(&callback);
85 if (rv == net::ERR_IO_PENDING) 85 if (rv == net::ERR_IO_PENDING)
86 rv = callback.WaitForResult(); 86 rv = callback.WaitForResult();
87 EXPECT_EQ(net::OK, rv); 87 EXPECT_EQ(net::OK, rv);
88 88
89 scoped_ptr<net::SSLClientSocket> sock( 89 scoped_ptr<net::SSLClientSocket> sock(
90 socket_factory_->CreateSSLClientSocket(transport, 90 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 16 matching lines...) Expand all
107 EXPECT_FALSE(sock->IsConnected()); 107 EXPECT_FALSE(sock->IsConnected());
108 } 108 }
109 109
110 TEST_F(SSLClientSocketTest, MAYBE_ConnectExpired) { 110 TEST_F(SSLClientSocketTest, MAYBE_ConnectExpired) {
111 StartExpiredServer(); 111 StartExpiredServer();
112 112
113 net::AddressList addr; 113 net::AddressList addr;
114 net::HostResolver resolver; 114 net::HostResolver resolver;
115 TestCompletionCallback callback; 115 TestCompletionCallback callback;
116 116
117 int rv = resolver.Resolve(server_.kHostName, server_.kBadHTTPSPort, 117 net::HostResolver::RequestInfo info(server_.kHostName, server_.kBadHTTPSPort);
118 &addr, NULL, NULL); 118 int rv = resolver.Resolve(info, &addr, NULL, NULL);
119 EXPECT_EQ(net::OK, rv); 119 EXPECT_EQ(net::OK, rv);
120 120
121 net::ClientSocket *transport = new net::TCPClientSocket(addr); 121 net::ClientSocket *transport = new net::TCPClientSocket(addr);
122 rv = transport->Connect(&callback); 122 rv = transport->Connect(&callback);
123 if (rv == net::ERR_IO_PENDING) 123 if (rv == net::ERR_IO_PENDING)
124 rv = callback.WaitForResult(); 124 rv = callback.WaitForResult();
125 EXPECT_EQ(net::OK, rv); 125 EXPECT_EQ(net::OK, rv);
126 126
127 scoped_ptr<net::SSLClientSocket> sock( 127 scoped_ptr<net::SSLClientSocket> sock(
128 socket_factory_->CreateSSLClientSocket(transport, 128 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 15 matching lines...) Expand all
144 // leave it connected. 144 // leave it connected.
145 } 145 }
146 146
147 TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) { 147 TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
148 StartMismatchedServer(); 148 StartMismatchedServer();
149 149
150 net::AddressList addr; 150 net::AddressList addr;
151 net::HostResolver resolver; 151 net::HostResolver resolver;
152 TestCompletionCallback callback; 152 TestCompletionCallback callback;
153 153
154 int rv = resolver.Resolve(server_.kMismatchedHostName, server_.kOKHTTPSPort, 154 net::HostResolver::RequestInfo info(server_.kMismatchedHostName,
155 &addr, NULL, NULL); 155 server_.kOKHTTPSPort);
156 int rv = resolver.Resolve(info, &addr, NULL, NULL);
156 EXPECT_EQ(net::OK, rv); 157 EXPECT_EQ(net::OK, rv);
157 158
158 net::ClientSocket *transport = new net::TCPClientSocket(addr); 159 net::ClientSocket *transport = new net::TCPClientSocket(addr);
159 rv = transport->Connect(&callback); 160 rv = transport->Connect(&callback);
160 if (rv == net::ERR_IO_PENDING) 161 if (rv == net::ERR_IO_PENDING)
161 rv = callback.WaitForResult(); 162 rv = callback.WaitForResult();
162 EXPECT_EQ(net::OK, rv); 163 EXPECT_EQ(net::OK, rv);
163 164
164 scoped_ptr<net::SSLClientSocket> sock( 165 scoped_ptr<net::SSLClientSocket> sock(
165 socket_factory_->CreateSSLClientSocket(transport, 166 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 20 matching lines...) Expand all
186 // - Server closes the underlying TCP connection directly. 187 // - Server closes the underlying TCP connection directly.
187 // - Server sends data unexpectedly. 188 // - Server sends data unexpectedly.
188 189
189 TEST_F(SSLClientSocketTest, MAYBE_Read) { 190 TEST_F(SSLClientSocketTest, MAYBE_Read) {
190 StartOKServer(); 191 StartOKServer();
191 192
192 net::AddressList addr; 193 net::AddressList addr;
193 net::HostResolver resolver; 194 net::HostResolver resolver;
194 TestCompletionCallback callback; 195 TestCompletionCallback callback;
195 196
196 int rv = resolver.Resolve(server_.kHostName, server_.kOKHTTPSPort, 197 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
197 &addr, &callback, NULL); 198 int rv = resolver.Resolve(info, &addr, &callback, NULL);
198 EXPECT_EQ(net::ERR_IO_PENDING, rv); 199 EXPECT_EQ(net::ERR_IO_PENDING, rv);
199 200
200 rv = callback.WaitForResult(); 201 rv = callback.WaitForResult();
201 EXPECT_EQ(net::OK, rv); 202 EXPECT_EQ(net::OK, rv);
202 203
203 net::ClientSocket *transport = new net::TCPClientSocket(addr); 204 net::ClientSocket *transport = new net::TCPClientSocket(addr);
204 rv = transport->Connect(&callback); 205 rv = transport->Connect(&callback);
205 if (rv == net::ERR_IO_PENDING) 206 if (rv == net::ERR_IO_PENDING)
206 rv = callback.WaitForResult(); 207 rv = callback.WaitForResult();
207 EXPECT_EQ(net::OK, rv); 208 EXPECT_EQ(net::OK, rv);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 248 }
248 } 249 }
249 250
250 TEST_F(SSLClientSocketTest, MAYBE_Read_SmallChunks) { 251 TEST_F(SSLClientSocketTest, MAYBE_Read_SmallChunks) {
251 StartOKServer(); 252 StartOKServer();
252 253
253 net::AddressList addr; 254 net::AddressList addr;
254 net::HostResolver resolver; 255 net::HostResolver resolver;
255 TestCompletionCallback callback; 256 TestCompletionCallback callback;
256 257
257 int rv = resolver.Resolve(server_.kHostName, server_.kOKHTTPSPort, 258 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
258 &addr, NULL, NULL); 259 int rv = resolver.Resolve(info, &addr, NULL, NULL);
259 EXPECT_EQ(net::OK, rv); 260 EXPECT_EQ(net::OK, rv);
260 261
261 net::ClientSocket *transport = new net::TCPClientSocket(addr); 262 net::ClientSocket *transport = new net::TCPClientSocket(addr);
262 rv = transport->Connect(&callback); 263 rv = transport->Connect(&callback);
263 if (rv == net::ERR_IO_PENDING) 264 if (rv == net::ERR_IO_PENDING)
264 rv = callback.WaitForResult(); 265 rv = callback.WaitForResult();
265 EXPECT_EQ(net::OK, rv); 266 EXPECT_EQ(net::OK, rv);
266 267
267 scoped_ptr<net::SSLClientSocket> sock( 268 scoped_ptr<net::SSLClientSocket> sock(
268 socket_factory_->CreateSSLClientSocket(transport, 269 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 304 }
304 } 305 }
305 306
306 TEST_F(SSLClientSocketTest, MAYBE_Read_Interrupted) { 307 TEST_F(SSLClientSocketTest, MAYBE_Read_Interrupted) {
307 StartOKServer(); 308 StartOKServer();
308 309
309 net::AddressList addr; 310 net::AddressList addr;
310 net::HostResolver resolver; 311 net::HostResolver resolver;
311 TestCompletionCallback callback; 312 TestCompletionCallback callback;
312 313
313 int rv = resolver.Resolve(server_.kHostName, server_.kOKHTTPSPort, 314 net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
314 &addr, NULL, NULL); 315 int rv = resolver.Resolve(info, &addr, NULL, NULL);
315 EXPECT_EQ(net::OK, rv); 316 EXPECT_EQ(net::OK, rv);
316 317
317 net::ClientSocket *transport = new net::TCPClientSocket(addr); 318 net::ClientSocket *transport = new net::TCPClientSocket(addr);
318 rv = transport->Connect(&callback); 319 rv = transport->Connect(&callback);
319 if (rv == net::ERR_IO_PENDING) 320 if (rv == net::ERR_IO_PENDING)
320 rv = callback.WaitForResult(); 321 rv = callback.WaitForResult();
321 EXPECT_EQ(net::OK, rv); 322 EXPECT_EQ(net::OK, rv);
322 323
323 scoped_ptr<net::SSLClientSocket> sock( 324 scoped_ptr<net::SSLClientSocket> sock(
324 socket_factory_->CreateSSLClientSocket(transport, 325 socket_factory_->CreateSSLClientSocket(transport,
(...skipping 23 matching lines...) Expand all
348 // Do a partial read and then exit. This test should not crash! 349 // Do a partial read and then exit. This test should not crash!
349 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(512); 350 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(512);
350 rv = sock->Read(buf, 512, &callback); 351 rv = sock->Read(buf, 512, &callback);
351 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); 352 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
352 353
353 if (rv == net::ERR_IO_PENDING) 354 if (rv == net::ERR_IO_PENDING)
354 rv = callback.WaitForResult(); 355 rv = callback.WaitForResult();
355 356
356 EXPECT_NE(rv, 0); 357 EXPECT_NE(rv, 0);
357 } 358 }
OLDNEW
« no previous file with comments | « net/base/host_resolver_unittest.cc ('k') | net/base/ssl_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698