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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 6698009: Add request_id to HttpRequestInfo and pass it to the NetworkDelegate for events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fixes Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <windows.h> 9 #include <windows.h>
10 #elif defined(USE_NSS) 10 #elif defined(USE_NSS)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 } 231 }
232 232
233 // This is the same as the previous test, but checks that the network delegate 233 // This is the same as the previous test, but checks that the network delegate
234 // registers the error. 234 // registers the error.
235 TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) { 235 TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) {
236 ASSERT_TRUE(test_server_.Start()); 236 ASSERT_TRUE(test_server_.Start());
237 237
238 TestDelegate d; 238 TestDelegate d;
239 { 239 {
240 TestNetworkDelegate network_delegate; // must outlive URLRequest
Matt Perry 2011/03/24 22:10:54 I had to reorder this because of the network deleg
240 net::URLRequest r(GURL("https://www.redirect.com/"), &d); 241 net::URLRequest r(GURL("https://www.redirect.com/"), &d);
241 scoped_refptr<TestURLRequestContext> context( 242 scoped_refptr<TestURLRequestContext> context(
242 new TestURLRequestContext(test_server_.host_port_pair().ToString())); 243 new TestURLRequestContext(test_server_.host_port_pair().ToString()));
243 TestNetworkDelegate network_delegate;
244 context->set_network_delegate(&network_delegate); 244 context->set_network_delegate(&network_delegate);
245 r.set_context(context); 245 r.set_context(context);
246 246
247 r.Start(); 247 r.Start();
248 EXPECT_TRUE(r.is_pending()); 248 EXPECT_TRUE(r.is_pending());
249 249
250 MessageLoop::current()->Run(); 250 MessageLoop::current()->Run();
251 251
252 EXPECT_EQ(net::URLRequestStatus::FAILED, r.status().status()); 252 EXPECT_EQ(net::URLRequestStatus::FAILED, r.status().status());
253 EXPECT_EQ(net::ERR_TUNNEL_CONNECTION_FAILED, r.status().os_error()); 253 EXPECT_EQ(net::ERR_TUNNEL_CONNECTION_FAILED, r.status().os_error());
(...skipping 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 TestURLRequest req(GURL("http://example.com"), &d); 2394 TestURLRequest req(GURL("http://example.com"), &d);
2395 TestURLRequest other_req(GURL("http://example.com"), &d); 2395 TestURLRequest other_req(GURL("http://example.com"), &d);
2396 2396
2397 ASSERT_NE(req.identifier(), other_req.identifier()); 2397 ASSERT_NE(req.identifier(), other_req.identifier());
2398 } 2398 }
2399 2399
2400 // Check that a failure to connect to the proxy is reported to the network 2400 // Check that a failure to connect to the proxy is reported to the network
2401 // delegate. 2401 // delegate.
2402 TEST_F(URLRequestTest, NetworkDelegateProxyError) { 2402 TEST_F(URLRequestTest, NetworkDelegateProxyError) {
2403 TestDelegate d; 2403 TestDelegate d;
2404 TestNetworkDelegate network_delegate;
2404 TestURLRequest req(GURL("http://example.com"), &d); 2405 TestURLRequest req(GURL("http://example.com"), &d);
2405 req.set_method("GET"); 2406 req.set_method("GET");
2406 2407
2407 scoped_ptr<net::MockHostResolverBase> host_resolver( 2408 scoped_ptr<net::MockHostResolverBase> host_resolver(
2408 new net::MockHostResolver); 2409 new net::MockHostResolver);
2409 host_resolver->rules()->AddSimulatedFailure("*"); 2410 host_resolver->rules()->AddSimulatedFailure("*");
2410 TestNetworkDelegate network_delegate;
2411 scoped_refptr<TestURLRequestContext> context( 2411 scoped_refptr<TestURLRequestContext> context(
2412 new TestURLRequestContext("myproxy:70", host_resolver.release())); 2412 new TestURLRequestContext("myproxy:70", host_resolver.release()));
2413 context->set_network_delegate(&network_delegate); 2413 context->set_network_delegate(&network_delegate);
2414 req.set_context(context); 2414 req.set_context(context);
2415 2415
2416 req.Start(); 2416 req.Start();
2417 MessageLoop::current()->Run(); 2417 MessageLoop::current()->Run();
2418 2418
2419 // Check we see a failed request. 2419 // Check we see a failed request.
2420 EXPECT_FALSE(req.status().is_success()); 2420 EXPECT_FALSE(req.status().is_success());
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 net::HttpRequestHeaders headers; 2827 net::HttpRequestHeaders headers;
2828 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); 2828 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)");
2829 req.SetExtraRequestHeaders(headers); 2829 req.SetExtraRequestHeaders(headers);
2830 req.Start(); 2830 req.Start();
2831 MessageLoop::current()->Run(); 2831 MessageLoop::current()->Run();
2832 // If the net tests are being run with ChromeFrame then we need to allow for 2832 // If the net tests are being run with ChromeFrame then we need to allow for
2833 // the 'chromeframe' suffix which is added to the user agent before the 2833 // the 'chromeframe' suffix which is added to the user agent before the
2834 // closing parentheses. 2834 // closing parentheses.
2835 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 2835 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
2836 } 2836 }
OLDNEW
« net/http/http_network_transaction.cc ('K') | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698