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

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

Issue 10546071: CapturingNetLog - remove maximum entries constructor argument. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 8 years, 6 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 | « net/proxy/proxy_resolver_v8_unittest.cc ('k') | net/proxy/proxy_service_unittest.cc » ('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) 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Rules rules; 120 Rules rules;
121 RuleBasedProxyScriptFetcher fetcher(&rules); 121 RuleBasedProxyScriptFetcher fetcher(&rules);
122 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; 122 DoNothingDhcpProxyScriptFetcher dhcp_fetcher;
123 123
124 ProxyConfig config; 124 ProxyConfig config;
125 config.set_pac_url(GURL("http://custom/proxy.pac")); 125 config.set_pac_url(GURL("http://custom/proxy.pac"));
126 126
127 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); 127 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
128 128
129 TestCompletionCallback callback; 129 TestCompletionCallback callback;
130 CapturingNetLog log(CapturingNetLog::kUnbounded); 130 CapturingNetLog log;
131 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log); 131 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
132 EXPECT_EQ(OK, decider.Start( 132 EXPECT_EQ(OK, decider.Start(
133 config, base::TimeDelta(), true, callback.callback())); 133 config, base::TimeDelta(), true, callback.callback()));
134 EXPECT_EQ(rule.text(), decider.script_data()->utf16()); 134 EXPECT_EQ(rule.text(), decider.script_data()->utf16());
135 135
136 // Check the NetLog was filled correctly. 136 // Check the NetLog was filled correctly.
137 CapturingNetLog::CapturedEntryList entries; 137 CapturingNetLog::CapturedEntryList entries;
138 log.GetEntries(&entries); 138 log.GetEntries(&entries);
139 139
140 EXPECT_EQ(4u, entries.size()); 140 EXPECT_EQ(4u, entries.size());
(...skipping 15 matching lines...) Expand all
156 Rules rules; 156 Rules rules;
157 RuleBasedProxyScriptFetcher fetcher(&rules); 157 RuleBasedProxyScriptFetcher fetcher(&rules);
158 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; 158 DoNothingDhcpProxyScriptFetcher dhcp_fetcher;
159 159
160 ProxyConfig config; 160 ProxyConfig config;
161 config.set_pac_url(GURL("http://custom/proxy.pac")); 161 config.set_pac_url(GURL("http://custom/proxy.pac"));
162 162
163 rules.AddFailDownloadRule("http://custom/proxy.pac"); 163 rules.AddFailDownloadRule("http://custom/proxy.pac");
164 164
165 TestCompletionCallback callback; 165 TestCompletionCallback callback;
166 CapturingNetLog log(CapturingNetLog::kUnbounded); 166 CapturingNetLog log;
167 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log); 167 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
168 EXPECT_EQ(kFailedDownloading, 168 EXPECT_EQ(kFailedDownloading,
169 decider.Start(config, base::TimeDelta(), true, 169 decider.Start(config, base::TimeDelta(), true,
170 callback.callback())); 170 callback.callback()));
171 EXPECT_EQ(NULL, decider.script_data()); 171 EXPECT_EQ(NULL, decider.script_data());
172 172
173 // Check the NetLog was filled correctly. 173 // Check the NetLog was filled correctly.
174 CapturingNetLog::CapturedEntryList entries; 174 CapturingNetLog::CapturedEntryList entries;
175 log.GetEntries(&entries); 175 log.GetEntries(&entries);
176 176
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 ProxyConfig config; 276 ProxyConfig config;
277 config.set_auto_detect(true); 277 config.set_auto_detect(true);
278 config.set_pac_url(GURL("http://custom/proxy.pac")); 278 config.set_pac_url(GURL("http://custom/proxy.pac"));
279 config.proxy_rules().ParseFromString("unused-manual-proxy:99"); 279 config.proxy_rules().ParseFromString("unused-manual-proxy:99");
280 280
281 rules.AddFailParsingRule("http://wpad/wpad.dat"); 281 rules.AddFailParsingRule("http://wpad/wpad.dat");
282 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); 282 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
283 283
284 TestCompletionCallback callback; 284 TestCompletionCallback callback;
285 CapturingNetLog log(CapturingNetLog::kUnbounded); 285 CapturingNetLog log;
286 286
287 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log); 287 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
288 EXPECT_EQ(OK, decider.Start(config, base::TimeDelta(), 288 EXPECT_EQ(OK, decider.Start(config, base::TimeDelta(),
289 true, callback.callback())); 289 true, callback.callback()));
290 EXPECT_EQ(rule.text(), decider.script_data()->utf16()); 290 EXPECT_EQ(rule.text(), decider.script_data()->utf16());
291 291
292 // Verify that the effective configuration no longer contains auto detect or 292 // Verify that the effective configuration no longer contains auto detect or
293 // any of the manual settings. 293 // any of the manual settings.
294 EXPECT_TRUE(decider.effective_config().Equals( 294 EXPECT_TRUE(decider.effective_config().Equals(
295 ProxyConfig::CreateFromCustomPacURL(GURL("http://custom/proxy.pac")))); 295 ProxyConfig::CreateFromCustomPacURL(GURL("http://custom/proxy.pac"))));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 Rules rules; 380 Rules rules;
381 RuleBasedProxyScriptFetcher fetcher(&rules); 381 RuleBasedProxyScriptFetcher fetcher(&rules);
382 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; 382 DoNothingDhcpProxyScriptFetcher dhcp_fetcher;
383 383
384 ProxyConfig config; 384 ProxyConfig config;
385 config.set_pac_url(GURL("http://custom/proxy.pac")); 385 config.set_pac_url(GURL("http://custom/proxy.pac"));
386 386
387 rules.AddFailDownloadRule("http://custom/proxy.pac"); 387 rules.AddFailDownloadRule("http://custom/proxy.pac");
388 388
389 TestCompletionCallback callback; 389 TestCompletionCallback callback;
390 CapturingNetLog log(CapturingNetLog::kUnbounded); 390 CapturingNetLog log;
391 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log); 391 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
392 EXPECT_EQ(ERR_IO_PENDING, 392 EXPECT_EQ(ERR_IO_PENDING,
393 decider.Start(config, base::TimeDelta::FromMilliseconds(1), 393 decider.Start(config, base::TimeDelta::FromMilliseconds(1),
394 true, callback.callback())); 394 true, callback.callback()));
395 395
396 EXPECT_EQ(kFailedDownloading, callback.WaitForResult()); 396 EXPECT_EQ(kFailedDownloading, callback.WaitForResult());
397 EXPECT_EQ(NULL, decider.script_data()); 397 EXPECT_EQ(NULL, decider.script_data());
398 398
399 // Check the NetLog was filled correctly. 399 // Check the NetLog was filled correctly.
400 CapturingNetLog::CapturedEntryList entries; 400 CapturingNetLog::CapturedEntryList entries;
(...skipping 21 matching lines...) Expand all
422 Rules rules; 422 Rules rules;
423 RuleBasedProxyScriptFetcher fetcher(&rules); 423 RuleBasedProxyScriptFetcher fetcher(&rules);
424 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; 424 DoNothingDhcpProxyScriptFetcher dhcp_fetcher;
425 425
426 ProxyConfig config; 426 ProxyConfig config;
427 config.set_pac_url(GURL("http://custom/proxy.pac")); 427 config.set_pac_url(GURL("http://custom/proxy.pac"));
428 428
429 rules.AddFailDownloadRule("http://custom/proxy.pac"); 429 rules.AddFailDownloadRule("http://custom/proxy.pac");
430 430
431 TestCompletionCallback callback; 431 TestCompletionCallback callback;
432 CapturingNetLog log(CapturingNetLog::kUnbounded); 432 CapturingNetLog log;
433 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log); 433 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
434 EXPECT_EQ(kFailedDownloading, 434 EXPECT_EQ(kFailedDownloading,
435 decider.Start(config, base::TimeDelta::FromSeconds(-5), 435 decider.Start(config, base::TimeDelta::FromSeconds(-5),
436 true, callback.callback())); 436 true, callback.callback()));
437 EXPECT_EQ(NULL, decider.script_data()); 437 EXPECT_EQ(NULL, decider.script_data());
438 438
439 // Check the NetLog was filled correctly. 439 // Check the NetLog was filled correctly.
440 CapturingNetLog::CapturedEntryList entries; 440 CapturingNetLog::CapturedEntryList entries;
441 log.GetEntries(&entries); 441 log.GetEntries(&entries);
442 442
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 588
589 // Run the message loop to let the DHCP fetch complete and post the results 589 // Run the message loop to let the DHCP fetch complete and post the results
590 // back. Before the fix linked to above, this would try to invoke on 590 // back. Before the fix linked to above, this would try to invoke on
591 // the callback object provided by ProxyScriptDecider after it was 591 // the callback object provided by ProxyScriptDecider after it was
592 // no longer valid. 592 // no longer valid.
593 MessageLoop::current()->RunAllPending(); 593 MessageLoop::current()->RunAllPending();
594 } 594 }
595 595
596 } // namespace 596 } // namespace
597 } // namespace net 597 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8_unittest.cc ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698