OLD | NEW |
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) |
11 #include "base/nss_util.h" | 11 #include "base/nss_util.h" |
12 #endif | 12 #endif |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
22 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
23 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
27 #include "net/base/cookie_monster.h" | 27 #include "net/base/cookie_monster.h" |
28 #include "net/base/cookie_policy.h" | 28 #include "net/base/cookie_policy.h" |
29 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
| 30 #include "net/base/mock_host_resolver.h" |
30 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
31 #include "net/base/net_log.h" | 32 #include "net/base/net_log.h" |
32 #include "net/base/net_log_unittest.h" | 33 #include "net/base/net_log_unittest.h" |
33 #include "net/base/net_module.h" | 34 #include "net/base/net_module.h" |
34 #include "net/base/net_util.h" | 35 #include "net/base/net_util.h" |
35 #include "net/base/ssl_connection_status_flags.h" | 36 #include "net/base/ssl_connection_status_flags.h" |
36 #include "net/base/upload_data.h" | 37 #include "net/base/upload_data.h" |
37 #include "net/disk_cache/disk_cache.h" | 38 #include "net/disk_cache/disk_cache.h" |
38 #include "net/ftp/ftp_network_layer.h" | 39 #include "net/ftp/ftp_network_layer.h" |
39 #include "net/http/http_cache.h" | 40 #include "net/http/http_cache.h" |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 | 2342 |
2342 // Check that two different URL requests have different identifiers. | 2343 // Check that two different URL requests have different identifiers. |
2343 TEST_F(URLRequestTest, Identifiers) { | 2344 TEST_F(URLRequestTest, Identifiers) { |
2344 TestDelegate d; | 2345 TestDelegate d; |
2345 TestURLRequest req(GURL("http://example.com"), &d); | 2346 TestURLRequest req(GURL("http://example.com"), &d); |
2346 TestURLRequest other_req(GURL("http://example.com"), &d); | 2347 TestURLRequest other_req(GURL("http://example.com"), &d); |
2347 | 2348 |
2348 ASSERT_NE(req.identifier(), other_req.identifier()); | 2349 ASSERT_NE(req.identifier(), other_req.identifier()); |
2349 } | 2350 } |
2350 | 2351 |
| 2352 // Check that a failure to connect to the proxy is reported to the network |
| 2353 // delegate. |
| 2354 TEST_F(URLRequestTest, NetworkDelegateProxyError) { |
| 2355 TestDelegate d; |
| 2356 TestURLRequest req(GURL("http://example.com"), &d); |
| 2357 req.set_method("GET"); |
| 2358 |
| 2359 scoped_ptr<net::MockHostResolverBase> host_resolver( |
| 2360 new net::MockHostResolver); |
| 2361 host_resolver->rules()->AddSimulatedFailure("*"); |
| 2362 scoped_refptr<TestURLRequestContext> context( |
| 2363 new TestURLRequestContext("myproxy:70", host_resolver.release())); |
| 2364 TestHttpNetworkDelegate network_delegate; |
| 2365 context->set_network_delegate(&network_delegate); |
| 2366 req.set_context(context); |
| 2367 |
| 2368 req.Start(); |
| 2369 MessageLoop::current()->Run(); |
| 2370 |
| 2371 // Check we see a failed request. |
| 2372 EXPECT_FALSE(req.status().is_success()); |
| 2373 EXPECT_EQ(net::URLRequestStatus::FAILED, req.status().status()); |
| 2374 EXPECT_EQ(net::ERR_PROXY_CONNECTION_FAILED, req.status().os_error()); |
| 2375 |
| 2376 EXPECT_EQ(1, network_delegate.error_count()); |
| 2377 EXPECT_EQ(net::ERR_PROXY_CONNECTION_FAILED, network_delegate.last_os_error()); |
| 2378 } |
| 2379 |
2351 class URLRequestTestFTP : public URLRequestTest { | 2380 class URLRequestTestFTP : public URLRequestTest { |
2352 public: | 2381 public: |
2353 URLRequestTestFTP() : test_server_(net::TestServer::TYPE_FTP, FilePath()) { | 2382 URLRequestTestFTP() : test_server_(net::TestServer::TYPE_FTP, FilePath()) { |
2354 } | 2383 } |
2355 | 2384 |
2356 protected: | 2385 protected: |
2357 net::TestServer test_server_; | 2386 net::TestServer test_server_; |
2358 }; | 2387 }; |
2359 | 2388 |
2360 // Flaky, see http://crbug.com/25045. | 2389 // Flaky, see http://crbug.com/25045. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 net::HttpRequestHeaders headers; | 2767 net::HttpRequestHeaders headers; |
2739 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); | 2768 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); |
2740 req.SetExtraRequestHeaders(headers); | 2769 req.SetExtraRequestHeaders(headers); |
2741 req.Start(); | 2770 req.Start(); |
2742 MessageLoop::current()->Run(); | 2771 MessageLoop::current()->Run(); |
2743 // If the net tests are being run with ChromeFrame then we need to allow for | 2772 // If the net tests are being run with ChromeFrame then we need to allow for |
2744 // the 'chromeframe' suffix which is added to the user agent before the | 2773 // the 'chromeframe' suffix which is added to the user agent before the |
2745 // closing parentheses. | 2774 // closing parentheses. |
2746 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 2775 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
2747 } | 2776 } |
OLD | NEW |