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

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

Issue 551135: Cleanup the unittest helpers in load_log_unittest.h.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Sync and merge conflicts Created 10 years, 10 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/http/http_cache_unittest.cc ('k') | net/proxy/proxy_resolver_v8_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) 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_util.h" 9 #include "net/base/load_log_util.h"
10 #include "net/base/load_log_unittest.h" 10 #include "net/base/load_log_unittest.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); 172 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
173 173
174 TestCompletionCallback callback; 174 TestCompletionCallback callback;
175 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); 175 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
176 InitProxyResolver init(&resolver, &fetcher); 176 InitProxyResolver init(&resolver, &fetcher);
177 EXPECT_EQ(OK, init.Init(config, &callback, log)); 177 EXPECT_EQ(OK, init.Init(config, &callback, log));
178 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); 178 EXPECT_EQ(rule.bytes(), resolver.pac_bytes());
179 179
180 // Check the LoadLog was filled correctly. 180 // Check the LoadLog was filled correctly.
181 EXPECT_EQ(9u, log->entries().size()); 181 EXPECT_EQ(9u, log->entries().size());
182 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, 182 EXPECT_TRUE(LogContainsBeginEvent(
183 LoadLog::PHASE_BEGIN); 183 *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
184 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 184 EXPECT_TRUE(LogContainsBeginEvent(
185 LoadLog::PHASE_BEGIN); 185 *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
186 ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 186 EXPECT_TRUE(LogContainsEndEvent(
187 LoadLog::PHASE_END); 187 *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
188 ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 188 EXPECT_TRUE(LogContainsBeginEvent(
189 LoadLog::PHASE_BEGIN); 189 *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
190 ExpectLogContains(log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 190 EXPECT_TRUE(LogContainsEndEvent(
191 LoadLog::PHASE_END); 191 *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
192 ExpectLogContains(log, 8, LoadLog::TYPE_INIT_PROXY_RESOLVER, 192 EXPECT_TRUE(LogContainsEndEvent(*log, 8, LoadLog::TYPE_INIT_PROXY_RESOLVER));
193 LoadLog::PHASE_END);
194 } 193 }
195 194
196 // Fail downloading the custom PAC script. 195 // Fail downloading the custom PAC script.
197 TEST(InitProxyResolverTest, CustomPacFails1) { 196 TEST(InitProxyResolverTest, CustomPacFails1) {
198 Rules rules; 197 Rules rules;
199 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); 198 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/);
200 RuleBasedProxyScriptFetcher fetcher(&rules); 199 RuleBasedProxyScriptFetcher fetcher(&rules);
201 200
202 ProxyConfig config; 201 ProxyConfig config;
203 config.pac_url = GURL("http://custom/proxy.pac"); 202 config.pac_url = GURL("http://custom/proxy.pac");
204 203
205 rules.AddFailDownloadRule("http://custom/proxy.pac"); 204 rules.AddFailDownloadRule("http://custom/proxy.pac");
206 205
207 TestCompletionCallback callback; 206 TestCompletionCallback callback;
208 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); 207 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
209 InitProxyResolver init(&resolver, &fetcher); 208 InitProxyResolver init(&resolver, &fetcher);
210 EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log)); 209 EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log));
211 EXPECT_EQ("", resolver.pac_bytes()); 210 EXPECT_EQ("", resolver.pac_bytes());
212 211
213 // Check the LoadLog was filled correctly. 212 // Check the LoadLog was filled correctly.
214 EXPECT_EQ(6u, log->entries().size()); 213 EXPECT_EQ(6u, log->entries().size());
215 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, 214 EXPECT_TRUE(LogContainsBeginEvent(
216 LoadLog::PHASE_BEGIN); 215 *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
217 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 216 EXPECT_TRUE(LogContainsBeginEvent(
218 LoadLog::PHASE_BEGIN); 217 *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
219 ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 218 EXPECT_TRUE(LogContainsEndEvent(
220 LoadLog::PHASE_END); 219 *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
221 ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER, 220 EXPECT_TRUE(LogContainsEndEvent(*log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER));
222 LoadLog::PHASE_END);
223 } 221 }
224 222
225 // Fail parsing the custom PAC script. 223 // Fail parsing the custom PAC script.
226 TEST(InitProxyResolverTest, CustomPacFails2) { 224 TEST(InitProxyResolverTest, CustomPacFails2) {
227 Rules rules; 225 Rules rules;
228 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); 226 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/);
229 RuleBasedProxyScriptFetcher fetcher(&rules); 227 RuleBasedProxyScriptFetcher fetcher(&rules);
230 228
231 ProxyConfig config; 229 ProxyConfig config;
232 config.pac_url = GURL("http://custom/proxy.pac"); 230 config.pac_url = GURL("http://custom/proxy.pac");
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 TestCompletionCallback callback; 303 TestCompletionCallback callback;
306 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); 304 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
307 InitProxyResolver init(&resolver, &fetcher); 305 InitProxyResolver init(&resolver, &fetcher);
308 EXPECT_EQ(OK, init.Init(config, &callback, log)); 306 EXPECT_EQ(OK, init.Init(config, &callback, log));
309 EXPECT_EQ(rule.bytes(), resolver.pac_bytes()); 307 EXPECT_EQ(rule.bytes(), resolver.pac_bytes());
310 308
311 // Check the LoadLog was filled correctly. 309 // Check the LoadLog was filled correctly.
312 // (Note that the Fetch and Set states are repeated since both WPAD and custom 310 // (Note that the Fetch and Set states are repeated since both WPAD and custom
313 // PAC scripts are tried). 311 // PAC scripts are tried).
314 EXPECT_EQ(17u, log->entries().size()); 312 EXPECT_EQ(17u, log->entries().size());
315 ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, 313 EXPECT_TRUE(LogContainsBeginEvent(
316 LoadLog::PHASE_BEGIN); 314 *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
317 ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 315 EXPECT_TRUE(LogContainsBeginEvent(
318 LoadLog::PHASE_BEGIN); 316 *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
319 ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 317 EXPECT_TRUE(LogContainsEndEvent(
320 LoadLog::PHASE_END); 318 *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
321 ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 319 EXPECT_TRUE(LogContainsBeginEvent(
322 LoadLog::PHASE_BEGIN); 320 *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
323 ExpectLogContains(log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 321 EXPECT_TRUE(LogContainsEndEvent(
324 LoadLog::PHASE_END); 322 *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
325 ExpectLogContains(log, 9, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 323 EXPECT_TRUE(LogContainsBeginEvent(
326 LoadLog::PHASE_BEGIN); 324 *log, 9, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
327 ExpectLogContains(log, 12, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, 325 EXPECT_TRUE(LogContainsEndEvent(
328 LoadLog::PHASE_END); 326 *log, 12, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
329 ExpectLogContains(log, 13, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 327 EXPECT_TRUE(LogContainsBeginEvent(
330 LoadLog::PHASE_BEGIN); 328 *log, 13, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
331 ExpectLogContains(log, 15, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, 329 EXPECT_TRUE(LogContainsEndEvent(
332 LoadLog::PHASE_END); 330 *log, 15, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
333 ExpectLogContains(log, 16, LoadLog::TYPE_INIT_PROXY_RESOLVER, 331 EXPECT_TRUE(LogContainsEndEvent(*log, 16, LoadLog::TYPE_INIT_PROXY_RESOLVER));
334 LoadLog::PHASE_END);
335 } 332 }
336 333
337 // Fails at WPAD (downloading), and fails at custom PAC (downloading). 334 // Fails at WPAD (downloading), and fails at custom PAC (downloading).
338 TEST(InitProxyResolverTest, AutodetectFailCustomFails1) { 335 TEST(InitProxyResolverTest, AutodetectFailCustomFails1) {
339 Rules rules; 336 Rules rules;
340 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/); 337 RuleBasedProxyResolver resolver(&rules, true /*expects_pac_bytes*/);
341 RuleBasedProxyScriptFetcher fetcher(&rules); 338 RuleBasedProxyScriptFetcher fetcher(&rules);
342 339
343 ProxyConfig config; 340 ProxyConfig config;
344 config.auto_detect = true; 341 config.auto_detect = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); 385 Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
389 386
390 TestCompletionCallback callback; 387 TestCompletionCallback callback;
391 InitProxyResolver init(&resolver, &fetcher); 388 InitProxyResolver init(&resolver, &fetcher);
392 EXPECT_EQ(OK, init.Init(config, &callback, NULL)); 389 EXPECT_EQ(OK, init.Init(config, &callback, NULL));
393 EXPECT_EQ(rule.url, resolver.pac_url()); 390 EXPECT_EQ(rule.url, resolver.pac_url());
394 } 391 }
395 392
396 } // namespace 393 } // namespace
397 } // namespace net 394 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | net/proxy/proxy_resolver_v8_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698