| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 8 #include "net/base/load_log.h" | 8 #include "net/base/load_log.h" |
| 9 #include "net/base/load_log_unittest.h" | 9 #include "net/base/load_log_unittest.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 Rules rules; | 164 Rules rules; |
| 165 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); | 165 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); |
| 166 RuleBasedProxyScriptFetcher fetcher(&rules); | 166 RuleBasedProxyScriptFetcher fetcher(&rules); |
| 167 | 167 |
| 168 ProxyConfig config; | 168 ProxyConfig config; |
| 169 config.pac_url = GURL("http://custom/proxy.pac"); | 169 config.pac_url = GURL("http://custom/proxy.pac"); |
| 170 | 170 |
| 171 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); | 171 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); |
| 172 | 172 |
| 173 TestCompletionCallback callback; | 173 TestCompletionCallback callback; |
| 174 scoped_refptr<LoadLog> log(new LoadLog); | 174 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); |
| 175 InitProxyResolver init(&resolver, &fetcher); | 175 InitProxyResolver init(&resolver, &fetcher); |
| 176 EXPECT_EQ(OK, init.Init(config, &callback, log)); | 176 EXPECT_EQ(OK, init.Init(config, &callback, log)); |
| 177 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); | 177 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); |
| 178 | 178 |
| 179 // Check the LoadLog was filled correctly. | 179 // Check the LoadLog was filled correctly. |
| 180 EXPECT_EQ(6u, log->events().size()); | 180 EXPECT_EQ(6u, log->events().size()); |
| 181 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, | 181 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, |
| 182 LoadLog::PHASE_BEGIN); | 182 LoadLog::PHASE_BEGIN); |
| 183 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 183 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 184 LoadLog::PHASE_BEGIN); | 184 LoadLog::PHASE_BEGIN); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 197 Rules rules; | 197 Rules rules; |
| 198 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); | 198 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); |
| 199 RuleBasedProxyScriptFetcher fetcher(&rules); | 199 RuleBasedProxyScriptFetcher fetcher(&rules); |
| 200 | 200 |
| 201 ProxyConfig config; | 201 ProxyConfig config; |
| 202 config.pac_url = GURL("http://custom/proxy.pac"); | 202 config.pac_url = GURL("http://custom/proxy.pac"); |
| 203 | 203 |
| 204 rules.AddFailDownloadRule("http://custom/proxy.pac"); | 204 rules.AddFailDownloadRule("http://custom/proxy.pac"); |
| 205 | 205 |
| 206 TestCompletionCallback callback; | 206 TestCompletionCallback callback; |
| 207 scoped_refptr<LoadLog> log(new LoadLog); | 207 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); |
| 208 InitProxyResolver init(&resolver, &fetcher); | 208 InitProxyResolver init(&resolver, &fetcher); |
| 209 EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log)); | 209 EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log)); |
| 210 EXPECT_EQ("", resolver.pac_bytes()); | 210 EXPECT_EQ("", resolver.pac_bytes()); |
| 211 | 211 |
| 212 // Check the LoadLog was filled correctly. | 212 // Check the LoadLog was filled correctly. |
| 213 EXPECT_EQ(4u, log->events().size()); | 213 EXPECT_EQ(4u, log->events().size()); |
| 214 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, | 214 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, |
| 215 LoadLog::PHASE_BEGIN); | 215 LoadLog::PHASE_BEGIN); |
| 216 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 216 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 217 LoadLog::PHASE_BEGIN); | 217 LoadLog::PHASE_BEGIN); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 RuleBasedProxyScriptFetcher fetcher(&rules); | 281 RuleBasedProxyScriptFetcher fetcher(&rules); |
| 282 | 282 |
| 283 ProxyConfig config; | 283 ProxyConfig config; |
| 284 config.auto_detect = true; | 284 config.auto_detect = true; |
| 285 config.pac_url = GURL("http://custom/proxy.pac"); | 285 config.pac_url = GURL("http://custom/proxy.pac"); |
| 286 | 286 |
| 287 rules.AddFailParsingRule("http://wpad/wpad.dat"); | 287 rules.AddFailParsingRule("http://wpad/wpad.dat"); |
| 288 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); | 288 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); |
| 289 | 289 |
| 290 TestCompletionCallback callback; | 290 TestCompletionCallback callback; |
| 291 scoped_refptr<LoadLog> log(new LoadLog); | 291 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); |
| 292 InitProxyResolver init(&resolver, &fetcher); | 292 InitProxyResolver init(&resolver, &fetcher); |
| 293 EXPECT_EQ(OK, init.Init(config, &callback, log)); | 293 EXPECT_EQ(OK, init.Init(config, &callback, log)); |
| 294 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); | 294 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); |
| 295 | 295 |
| 296 // Check the LoadLog was filled correctly. | 296 // Check the LoadLog was filled correctly. |
| 297 // (Note that the Fetch and Set states are repeated since both WPAD and custom | 297 // (Note that the Fetch and Set states are repeated since both WPAD and custom |
| 298 // PAC scripts are tried). | 298 // PAC scripts are tried). |
| 299 EXPECT_EQ(10u, log->events().size()); | 299 EXPECT_EQ(10u, log->events().size()); |
| 300 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, | 300 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, |
| 301 LoadLog::PHASE_BEGIN); | 301 LoadLog::PHASE_BEGIN); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); | 373 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); |
| 374 | 374 |
| 375 TestCompletionCallback callback; | 375 TestCompletionCallback callback; |
| 376 InitProxyResolver init(&resolver, &fetcher); | 376 InitProxyResolver init(&resolver, &fetcher); |
| 377 EXPECT_EQ(OK, init.Init(config, &callback, NULL)); | 377 EXPECT_EQ(OK, init.Init(config, &callback, NULL)); |
| 378 EXPECT_EQ(rule.url, resolver.pac_url()); | 378 EXPECT_EQ(rule.url, resolver.pac_url()); |
| 379 } | 379 } |
| 380 | 380 |
| 381 } // namespace | 381 } // namespace |
| 382 } // namespace net | 382 } // namespace net |
| OLD | NEW |