OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 // since the PAC script poller experienced a failure. | 3074 // since the PAC script poller experienced a failure. |
3075 ProxyInfo info3; | 3075 ProxyInfo info3; |
3076 TestCompletionCallback callback3; | 3076 TestCompletionCallback callback3; |
3077 rv = service.ResolveProxy( | 3077 rv = service.ResolveProxy( |
3078 GURL("http://request3"), net::LOAD_NORMAL, &info3, callback3.callback(), | 3078 GURL("http://request3"), net::LOAD_NORMAL, &info3, callback3.callback(), |
3079 NULL, NULL, BoundNetLog()); | 3079 NULL, NULL, BoundNetLog()); |
3080 EXPECT_EQ(OK, rv); | 3080 EXPECT_EQ(OK, rv); |
3081 EXPECT_TRUE(info3.is_direct()); | 3081 EXPECT_TRUE(info3.is_direct()); |
3082 } | 3082 } |
3083 | 3083 |
| 3084 // Test that the synchronous resolution fails when a PAC script is active. |
| 3085 TEST_F(ProxyServiceTest, SynchronousWithPAC) { |
| 3086 MockProxyConfigService* config_service = |
| 3087 new MockProxyConfigService("http://foopy/proxy.pac"); |
| 3088 |
| 3089 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver(); |
| 3090 |
| 3091 ProxyService service(config_service, resolver, NULL); |
| 3092 |
| 3093 GURL url("http://www.google.com/"); |
| 3094 |
| 3095 ProxyInfo info; |
| 3096 info.UseDirect(); |
| 3097 CapturingBoundNetLog log; |
| 3098 |
| 3099 bool synchronous_success = service.TryResolveProxySynchronously( |
| 3100 url, net::LOAD_NORMAL, &info, NULL, log.bound()); |
| 3101 EXPECT_FALSE(synchronous_success); |
| 3102 |
| 3103 // No request should have been queued. |
| 3104 EXPECT_EQ(0u, resolver->pending_requests().size()); |
| 3105 |
| 3106 // |info| should not have been modified. |
| 3107 EXPECT_TRUE(info.is_direct()); |
| 3108 } |
| 3109 |
| 3110 // Test that synchronous results are returned correctly if a fixed proxy |
| 3111 // configuration is active. |
| 3112 TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) { |
| 3113 ProxyConfig config; |
| 3114 config.proxy_rules().ParseFromString("foopy1:8080"); |
| 3115 config.set_auto_detect(false); |
| 3116 |
| 3117 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver(); |
| 3118 |
| 3119 ProxyService service(new MockProxyConfigService(config), resolver, NULL); |
| 3120 |
| 3121 GURL url("http://www.google.com/"); |
| 3122 |
| 3123 ProxyInfo info; |
| 3124 CapturingBoundNetLog log; |
| 3125 |
| 3126 bool synchronous_success = service.TryResolveProxySynchronously( |
| 3127 url, net::LOAD_NORMAL, &info, NULL, log.bound()); |
| 3128 EXPECT_TRUE(synchronous_success); |
| 3129 EXPECT_FALSE(info.is_direct()); |
| 3130 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); |
| 3131 |
| 3132 // No request should have been queued. |
| 3133 EXPECT_EQ(0u, resolver->pending_requests().size()); |
| 3134 } |
| 3135 |
3084 } // namespace net | 3136 } // namespace net |
OLD | NEW |