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

Side by Side Diff: net/proxy/init_proxy_resolver_unittest.cc

Issue 6322003: net: Remove prefix net:: from some places that already are in namespace net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | « no previous file | net/proxy/proxy_script_fetcher.h » ('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) 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 <vector> 5 #include <vector>
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/net_log.h" 10 #include "net/base/net_log.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const Rules::Rule& rule = rules_->GetRuleByUrl(url); 100 const Rules::Rule& rule = rules_->GetRuleByUrl(url);
101 int rv = rule.fetch_error; 101 int rv = rule.fetch_error;
102 EXPECT_NE(ERR_UNEXPECTED, rv); 102 EXPECT_NE(ERR_UNEXPECTED, rv);
103 if (rv == OK) 103 if (rv == OK)
104 *text = rule.text(); 104 *text = rule.text();
105 return rv; 105 return rv;
106 } 106 }
107 107
108 virtual void Cancel() {} 108 virtual void Cancel() {}
109 109
110 virtual net::URLRequestContext* GetRequestContext() { return NULL; } 110 virtual URLRequestContext* GetRequestContext() { return NULL; }
111 111
112 private: 112 private:
113 const Rules* rules_; 113 const Rules* rules_;
114 }; 114 };
115 115
116 class RuleBasedProxyResolver : public ProxyResolver { 116 class RuleBasedProxyResolver : public ProxyResolver {
117 public: 117 public:
118 RuleBasedProxyResolver(const Rules* rules, bool expects_pac_bytes) 118 RuleBasedProxyResolver(const Rules* rules, bool expects_pac_bytes)
119 : ProxyResolver(expects_pac_bytes), rules_(rules) {} 119 : ProxyResolver(expects_pac_bytes), rules_(rules) {}
120 120
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); 181 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
182 182
183 TestCompletionCallback callback; 183 TestCompletionCallback callback;
184 CapturingNetLog log(CapturingNetLog::kUnbounded); 184 CapturingNetLog log(CapturingNetLog::kUnbounded);
185 InitProxyResolver init(&resolver, &fetcher, &log); 185 InitProxyResolver init(&resolver, &fetcher, &log);
186 EXPECT_EQ(OK, init.Init(config, base::TimeDelta(), NULL, &callback)); 186 EXPECT_EQ(OK, init.Init(config, base::TimeDelta(), NULL, &callback));
187 EXPECT_EQ(rule.text(), resolver.script_data()->utf16()); 187 EXPECT_EQ(rule.text(), resolver.script_data()->utf16());
188 188
189 // Check the NetLog was filled correctly. 189 // Check the NetLog was filled correctly.
190 net::CapturingNetLog::EntryList entries; 190 CapturingNetLog::EntryList entries;
191 log.GetEntries(&entries); 191 log.GetEntries(&entries);
192 192
193 EXPECT_EQ(6u, entries.size()); 193 EXPECT_EQ(6u, entries.size());
194 EXPECT_TRUE(LogContainsBeginEvent( 194 EXPECT_TRUE(LogContainsBeginEvent(
195 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER)); 195 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
196 EXPECT_TRUE(LogContainsBeginEvent( 196 EXPECT_TRUE(LogContainsBeginEvent(
197 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 197 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
198 EXPECT_TRUE(LogContainsEndEvent( 198 EXPECT_TRUE(LogContainsEndEvent(
199 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 199 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
200 EXPECT_TRUE(LogContainsBeginEvent( 200 EXPECT_TRUE(LogContainsBeginEvent(
(...skipping 16 matching lines...) Expand all
217 rules.AddFailDownloadRule("http://custom/proxy.pac"); 217 rules.AddFailDownloadRule("http://custom/proxy.pac");
218 218
219 TestCompletionCallback callback; 219 TestCompletionCallback callback;
220 CapturingNetLog log(CapturingNetLog::kUnbounded); 220 CapturingNetLog log(CapturingNetLog::kUnbounded);
221 InitProxyResolver init(&resolver, &fetcher, &log); 221 InitProxyResolver init(&resolver, &fetcher, &log);
222 EXPECT_EQ(kFailedDownloading, 222 EXPECT_EQ(kFailedDownloading,
223 init.Init(config, base::TimeDelta(), NULL, &callback)); 223 init.Init(config, base::TimeDelta(), NULL, &callback));
224 EXPECT_EQ(NULL, resolver.script_data()); 224 EXPECT_EQ(NULL, resolver.script_data());
225 225
226 // Check the NetLog was filled correctly. 226 // Check the NetLog was filled correctly.
227 net::CapturingNetLog::EntryList entries; 227 CapturingNetLog::EntryList entries;
228 log.GetEntries(&entries); 228 log.GetEntries(&entries);
229 229
230 EXPECT_EQ(4u, entries.size()); 230 EXPECT_EQ(4u, entries.size());
231 EXPECT_TRUE(LogContainsBeginEvent( 231 EXPECT_TRUE(LogContainsBeginEvent(
232 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER)); 232 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
233 EXPECT_TRUE(LogContainsBeginEvent( 233 EXPECT_TRUE(LogContainsBeginEvent(
234 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 234 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
235 EXPECT_TRUE(LogContainsEndEvent( 235 EXPECT_TRUE(LogContainsEndEvent(
236 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 236 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
237 EXPECT_TRUE(LogContainsEndEvent( 237 EXPECT_TRUE(LogContainsEndEvent(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 EXPECT_EQ(rule.text(), resolver.script_data()->utf16()); 331 EXPECT_EQ(rule.text(), resolver.script_data()->utf16());
332 332
333 // Verify that the effective configuration no longer contains auto detect or 333 // Verify that the effective configuration no longer contains auto detect or
334 // any of the manual settings. 334 // any of the manual settings.
335 EXPECT_TRUE(effective_config.Equals( 335 EXPECT_TRUE(effective_config.Equals(
336 ProxyConfig::CreateFromCustomPacURL(GURL("http://custom/proxy.pac")))); 336 ProxyConfig::CreateFromCustomPacURL(GURL("http://custom/proxy.pac"))));
337 337
338 // Check the NetLog was filled correctly. 338 // Check the NetLog was filled correctly.
339 // (Note that the Fetch and Set states are repeated since both WPAD and custom 339 // (Note that the Fetch and Set states are repeated since both WPAD and custom
340 // PAC scripts are tried). 340 // PAC scripts are tried).
341 net::CapturingNetLog::EntryList entries; 341 CapturingNetLog::EntryList entries;
342 log.GetEntries(&entries); 342 log.GetEntries(&entries);
343 343
344 EXPECT_EQ(11u, entries.size()); 344 EXPECT_EQ(11u, entries.size());
345 EXPECT_TRUE(LogContainsBeginEvent( 345 EXPECT_TRUE(LogContainsBeginEvent(
346 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER)); 346 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
347 EXPECT_TRUE(LogContainsBeginEvent( 347 EXPECT_TRUE(LogContainsBeginEvent(
348 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 348 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
349 EXPECT_TRUE(LogContainsEndEvent( 349 EXPECT_TRUE(LogContainsEndEvent(
350 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 350 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
351 EXPECT_TRUE(LogContainsBeginEvent( 351 EXPECT_TRUE(LogContainsBeginEvent(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 CapturingNetLog log(CapturingNetLog::kUnbounded); 446 CapturingNetLog log(CapturingNetLog::kUnbounded);
447 InitProxyResolver init(&resolver, &fetcher, &log); 447 InitProxyResolver init(&resolver, &fetcher, &log);
448 EXPECT_EQ(ERR_IO_PENDING, 448 EXPECT_EQ(ERR_IO_PENDING,
449 init.Init(config, base::TimeDelta::FromMilliseconds(1), 449 init.Init(config, base::TimeDelta::FromMilliseconds(1),
450 NULL, &callback)); 450 NULL, &callback));
451 451
452 EXPECT_EQ(kFailedDownloading, callback.WaitForResult()); 452 EXPECT_EQ(kFailedDownloading, callback.WaitForResult());
453 EXPECT_EQ(NULL, resolver.script_data()); 453 EXPECT_EQ(NULL, resolver.script_data());
454 454
455 // Check the NetLog was filled correctly. 455 // Check the NetLog was filled correctly.
456 net::CapturingNetLog::EntryList entries; 456 CapturingNetLog::EntryList entries;
457 log.GetEntries(&entries); 457 log.GetEntries(&entries);
458 458
459 EXPECT_EQ(6u, entries.size()); 459 EXPECT_EQ(6u, entries.size());
460 EXPECT_TRUE(LogContainsBeginEvent( 460 EXPECT_TRUE(LogContainsBeginEvent(
461 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER)); 461 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
462 EXPECT_TRUE(LogContainsBeginEvent( 462 EXPECT_TRUE(LogContainsBeginEvent(
463 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT)); 463 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT));
464 EXPECT_TRUE(LogContainsEndEvent( 464 EXPECT_TRUE(LogContainsEndEvent(
465 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT)); 465 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT));
466 EXPECT_TRUE(LogContainsBeginEvent( 466 EXPECT_TRUE(LogContainsBeginEvent(
(...skipping 19 matching lines...) Expand all
486 486
487 TestCompletionCallback callback; 487 TestCompletionCallback callback;
488 CapturingNetLog log(CapturingNetLog::kUnbounded); 488 CapturingNetLog log(CapturingNetLog::kUnbounded);
489 InitProxyResolver init(&resolver, &fetcher, &log); 489 InitProxyResolver init(&resolver, &fetcher, &log);
490 EXPECT_EQ(kFailedDownloading, 490 EXPECT_EQ(kFailedDownloading,
491 init.Init(config, base::TimeDelta::FromSeconds(-5), 491 init.Init(config, base::TimeDelta::FromSeconds(-5),
492 NULL, &callback)); 492 NULL, &callback));
493 EXPECT_EQ(NULL, resolver.script_data()); 493 EXPECT_EQ(NULL, resolver.script_data());
494 494
495 // Check the NetLog was filled correctly. 495 // Check the NetLog was filled correctly.
496 net::CapturingNetLog::EntryList entries; 496 CapturingNetLog::EntryList entries;
497 log.GetEntries(&entries); 497 log.GetEntries(&entries);
498 498
499 EXPECT_EQ(4u, entries.size()); 499 EXPECT_EQ(4u, entries.size());
500 EXPECT_TRUE(LogContainsBeginEvent( 500 EXPECT_TRUE(LogContainsBeginEvent(
501 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER)); 501 entries, 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
502 EXPECT_TRUE(LogContainsBeginEvent( 502 EXPECT_TRUE(LogContainsBeginEvent(
503 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 503 entries, 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
504 EXPECT_TRUE(LogContainsEndEvent( 504 EXPECT_TRUE(LogContainsEndEvent(
505 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); 505 entries, 2, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
506 EXPECT_TRUE(LogContainsEndEvent( 506 EXPECT_TRUE(LogContainsEndEvent(
507 entries, 3, NetLog::TYPE_INIT_PROXY_RESOLVER)); 507 entries, 3, NetLog::TYPE_INIT_PROXY_RESOLVER));
508 } 508 }
509 509
510 } // namespace 510 } // namespace
511 } // namespace net 511 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/proxy/proxy_script_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698