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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 TEST_F(ProxyServiceTest, Direct) { | 242 TEST_F(ProxyServiceTest, Direct) { |
243 MockAsyncProxyResolver resolver; | 243 MockAsyncProxyResolver resolver; |
244 ProxyService service( | 244 ProxyService service( |
245 new MockProxyConfigService(ProxyConfig::CreateDirect()), | 245 new MockProxyConfigService(ProxyConfig::CreateDirect()), |
246 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); | 246 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
247 | 247 |
248 GURL url("http://www.google.com/"); | 248 GURL url("http://www.google.com/"); |
249 | 249 |
250 ProxyInfo info; | 250 ProxyInfo info; |
251 TestCompletionCallback callback; | 251 TestCompletionCallback callback; |
252 CapturingBoundNetLog log; | 252 BoundTestNetLog log; |
253 int rv = service.ResolveProxy( | 253 int rv = service.ResolveProxy( |
254 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, | 254 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, |
255 log.bound()); | 255 log.bound()); |
256 EXPECT_EQ(OK, rv); | 256 EXPECT_EQ(OK, rv); |
257 EXPECT_TRUE(resolver.pending_requests().empty()); | 257 EXPECT_TRUE(resolver.pending_requests().empty()); |
258 | 258 |
259 EXPECT_TRUE(info.is_direct()); | 259 EXPECT_TRUE(info.is_direct()); |
260 EXPECT_TRUE(info.proxy_resolve_start_time().is_null()); | 260 EXPECT_TRUE(info.proxy_resolve_start_time().is_null()); |
261 EXPECT_TRUE(info.proxy_resolve_end_time().is_null()); | 261 EXPECT_TRUE(info.proxy_resolve_end_time().is_null()); |
262 | 262 |
263 // Check the NetLog was filled correctly. | 263 // Check the NetLog was filled correctly. |
264 CapturingNetLog::CapturedEntryList entries; | 264 TestNetLog::CapturedEntryList entries; |
265 log.GetEntries(&entries); | 265 log.GetEntries(&entries); |
266 | 266 |
267 EXPECT_EQ(3u, entries.size()); | 267 EXPECT_EQ(3u, entries.size()); |
268 EXPECT_TRUE(LogContainsBeginEvent( | 268 EXPECT_TRUE(LogContainsBeginEvent( |
269 entries, 0, NetLog::TYPE_PROXY_SERVICE)); | 269 entries, 0, NetLog::TYPE_PROXY_SERVICE)); |
270 EXPECT_TRUE(LogContainsEvent( | 270 EXPECT_TRUE(LogContainsEvent( |
271 entries, 1, NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, | 271 entries, 1, NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
272 NetLog::PHASE_NONE)); | 272 NetLog::PHASE_NONE)); |
273 EXPECT_TRUE(LogContainsEndEvent( | 273 EXPECT_TRUE(LogContainsEndEvent( |
274 entries, 2, NetLog::TYPE_PROXY_SERVICE)); | 274 entries, 2, NetLog::TYPE_PROXY_SERVICE)); |
275 } | 275 } |
276 | 276 |
277 TEST_F(ProxyServiceTest, OnResolveProxyCallbackAddProxy) { | 277 TEST_F(ProxyServiceTest, OnResolveProxyCallbackAddProxy) { |
278 ProxyConfig config; | 278 ProxyConfig config; |
279 config.proxy_rules().ParseFromString("foopy1:8080"); | 279 config.proxy_rules().ParseFromString("foopy1:8080"); |
280 config.set_auto_detect(false); | 280 config.set_auto_detect(false); |
281 config.proxy_rules().bypass_rules.ParseFromString("*.org"); | 281 config.proxy_rules().bypass_rules.ParseFromString("*.org"); |
282 | 282 |
283 ProxyService service(new MockProxyConfigService(config), nullptr, NULL); | 283 ProxyService service(new MockProxyConfigService(config), nullptr, NULL); |
284 | 284 |
285 GURL url("http://www.google.com/"); | 285 GURL url("http://www.google.com/"); |
286 GURL bypass_url("http://internet.org"); | 286 GURL bypass_url("http://internet.org"); |
287 | 287 |
288 ProxyInfo info; | 288 ProxyInfo info; |
289 TestCompletionCallback callback; | 289 TestCompletionCallback callback; |
290 CapturingBoundNetLog log; | 290 BoundTestNetLog log; |
291 | 291 |
292 // First, warm up the ProxyService. | 292 // First, warm up the ProxyService. |
293 int rv = service.ResolveProxy( | 293 int rv = service.ResolveProxy( |
294 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, | 294 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, |
295 log.bound()); | 295 log.bound()); |
296 EXPECT_EQ(OK, rv); | 296 EXPECT_EQ(OK, rv); |
297 | 297 |
298 // Verify that network delegate is invoked. | 298 // Verify that network delegate is invoked. |
299 TestResolveProxyNetworkDelegate delegate; | 299 TestResolveProxyNetworkDelegate delegate; |
300 rv = service.ResolveProxy( | 300 rv = service.ResolveProxy( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 config.set_auto_detect(false); | 339 config.set_auto_detect(false); |
340 config.proxy_rules().bypass_rules.ParseFromString("*.org"); | 340 config.proxy_rules().bypass_rules.ParseFromString("*.org"); |
341 | 341 |
342 ProxyService service(new MockProxyConfigService(config), nullptr, NULL); | 342 ProxyService service(new MockProxyConfigService(config), nullptr, NULL); |
343 | 343 |
344 GURL url("http://www.google.com/"); | 344 GURL url("http://www.google.com/"); |
345 GURL bypass_url("http://internet.org"); | 345 GURL bypass_url("http://internet.org"); |
346 | 346 |
347 ProxyInfo info; | 347 ProxyInfo info; |
348 TestCompletionCallback callback; | 348 TestCompletionCallback callback; |
349 CapturingBoundNetLog log; | 349 BoundTestNetLog log; |
350 | 350 |
351 // First, warm up the ProxyService. | 351 // First, warm up the ProxyService. |
352 int rv = service.ResolveProxy( | 352 int rv = service.ResolveProxy( |
353 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, | 353 url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, |
354 log.bound()); | 354 log.bound()); |
355 EXPECT_EQ(OK, rv); | 355 EXPECT_EQ(OK, rv); |
356 | 356 |
357 TestResolveProxyNetworkDelegate delegate; | 357 TestResolveProxyNetworkDelegate delegate; |
358 delegate.set_remove_proxy(true); | 358 delegate.set_remove_proxy(true); |
359 | 359 |
(...skipping 26 matching lines...) Expand all Loading... |
386 | 386 |
387 ProxyService service( | 387 ProxyService service( |
388 config_service, | 388 config_service, |
389 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); | 389 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
390 | 390 |
391 GURL url("http://www.google.com/"); | 391 GURL url("http://www.google.com/"); |
392 | 392 |
393 ProxyInfo info; | 393 ProxyInfo info; |
394 TestCompletionCallback callback; | 394 TestCompletionCallback callback; |
395 ProxyService::PacRequest* request; | 395 ProxyService::PacRequest* request; |
396 CapturingBoundNetLog log; | 396 BoundTestNetLog log; |
397 | 397 |
398 int rv = service.ResolveProxy( | 398 int rv = service.ResolveProxy( |
399 url, net::LOAD_NORMAL, &info, callback.callback(), &request, NULL, | 399 url, net::LOAD_NORMAL, &info, callback.callback(), &request, NULL, |
400 log.bound()); | 400 log.bound()); |
401 EXPECT_EQ(ERR_IO_PENDING, rv); | 401 EXPECT_EQ(ERR_IO_PENDING, rv); |
402 | 402 |
403 EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, service.GetLoadState(request)); | 403 EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, service.GetLoadState(request)); |
404 | 404 |
405 EXPECT_EQ(GURL("http://foopy/proxy.pac"), | 405 EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
406 resolver.pending_set_pac_script_request()->script_data()->url()); | 406 resolver.pending_set_pac_script_request()->script_data()->url()); |
407 resolver.pending_set_pac_script_request()->CompleteNow(OK); | 407 resolver.pending_set_pac_script_request()->CompleteNow(OK); |
408 | 408 |
409 ASSERT_EQ(1u, resolver.pending_requests().size()); | 409 ASSERT_EQ(1u, resolver.pending_requests().size()); |
410 EXPECT_EQ(url, resolver.pending_requests()[0]->url()); | 410 EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
411 | 411 |
412 // Set the result in proxy resolver. | 412 // Set the result in proxy resolver. |
413 resolver.pending_requests()[0]->results()->UseNamedProxy("foopy"); | 413 resolver.pending_requests()[0]->results()->UseNamedProxy("foopy"); |
414 resolver.pending_requests()[0]->CompleteNow(OK); | 414 resolver.pending_requests()[0]->CompleteNow(OK); |
415 | 415 |
416 EXPECT_EQ(OK, callback.WaitForResult()); | 416 EXPECT_EQ(OK, callback.WaitForResult()); |
417 EXPECT_FALSE(info.is_direct()); | 417 EXPECT_FALSE(info.is_direct()); |
418 EXPECT_EQ("foopy:80", info.proxy_server().ToURI()); | 418 EXPECT_EQ("foopy:80", info.proxy_server().ToURI()); |
419 EXPECT_TRUE(info.did_use_pac_script()); | 419 EXPECT_TRUE(info.did_use_pac_script()); |
420 | 420 |
421 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); | 421 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); |
422 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); | 422 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); |
423 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); | 423 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); |
424 | 424 |
425 // Check the NetLog was filled correctly. | 425 // Check the NetLog was filled correctly. |
426 CapturingNetLog::CapturedEntryList entries; | 426 TestNetLog::CapturedEntryList entries; |
427 log.GetEntries(&entries); | 427 log.GetEntries(&entries); |
428 | 428 |
429 EXPECT_EQ(5u, entries.size()); | 429 EXPECT_EQ(5u, entries.size()); |
430 EXPECT_TRUE(LogContainsBeginEvent( | 430 EXPECT_TRUE(LogContainsBeginEvent( |
431 entries, 0, NetLog::TYPE_PROXY_SERVICE)); | 431 entries, 0, NetLog::TYPE_PROXY_SERVICE)); |
432 EXPECT_TRUE(LogContainsBeginEvent( | 432 EXPECT_TRUE(LogContainsBeginEvent( |
433 entries, 1, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); | 433 entries, 1, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); |
434 EXPECT_TRUE(LogContainsEndEvent( | 434 EXPECT_TRUE(LogContainsEndEvent( |
435 entries, 2, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); | 435 entries, 2, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); |
436 EXPECT_TRUE(LogContainsEndEvent( | 436 EXPECT_TRUE(LogContainsEndEvent( |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); | 1906 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
1907 | 1907 |
1908 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; | 1908 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
1909 service.SetProxyScriptFetchers(fetcher, | 1909 service.SetProxyScriptFetchers(fetcher, |
1910 new DoNothingDhcpProxyScriptFetcher()); | 1910 new DoNothingDhcpProxyScriptFetcher()); |
1911 | 1911 |
1912 // Start 3 requests. | 1912 // Start 3 requests. |
1913 ProxyInfo info1; | 1913 ProxyInfo info1; |
1914 TestCompletionCallback callback1; | 1914 TestCompletionCallback callback1; |
1915 ProxyService::PacRequest* request1; | 1915 ProxyService::PacRequest* request1; |
1916 CapturingBoundNetLog log1; | 1916 BoundTestNetLog log1; |
1917 int rv = service.ResolveProxy(GURL("http://request1"), net::LOAD_NORMAL, | 1917 int rv = service.ResolveProxy(GURL("http://request1"), net::LOAD_NORMAL, |
1918 &info1, callback1.callback(), &request1, NULL, | 1918 &info1, callback1.callback(), &request1, NULL, |
1919 log1.bound()); | 1919 log1.bound()); |
1920 EXPECT_EQ(ERR_IO_PENDING, rv); | 1920 EXPECT_EQ(ERR_IO_PENDING, rv); |
1921 | 1921 |
1922 // The first request should have triggered download of PAC script. | 1922 // The first request should have triggered download of PAC script. |
1923 EXPECT_TRUE(fetcher->has_pending_request()); | 1923 EXPECT_TRUE(fetcher->has_pending_request()); |
1924 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); | 1924 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
1925 | 1925 |
1926 ProxyInfo info2; | 1926 ProxyInfo info2; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 resolver.pending_requests()[0]->CompleteNow(OK); | 1963 resolver.pending_requests()[0]->CompleteNow(OK); |
1964 | 1964 |
1965 EXPECT_EQ(OK, callback3.WaitForResult()); | 1965 EXPECT_EQ(OK, callback3.WaitForResult()); |
1966 EXPECT_EQ("request3:80", info3.proxy_server().ToURI()); | 1966 EXPECT_EQ("request3:80", info3.proxy_server().ToURI()); |
1967 | 1967 |
1968 EXPECT_TRUE(resolver.cancelled_requests().empty()); | 1968 EXPECT_TRUE(resolver.cancelled_requests().empty()); |
1969 | 1969 |
1970 EXPECT_FALSE(callback1.have_result()); // Cancelled. | 1970 EXPECT_FALSE(callback1.have_result()); // Cancelled. |
1971 EXPECT_FALSE(callback2.have_result()); // Cancelled. | 1971 EXPECT_FALSE(callback2.have_result()); // Cancelled. |
1972 | 1972 |
1973 CapturingNetLog::CapturedEntryList entries1; | 1973 TestNetLog::CapturedEntryList entries1; |
1974 log1.GetEntries(&entries1); | 1974 log1.GetEntries(&entries1); |
1975 | 1975 |
1976 // Check the NetLog for request 1 (which was cancelled) got filled properly. | 1976 // Check the NetLog for request 1 (which was cancelled) got filled properly. |
1977 EXPECT_EQ(4u, entries1.size()); | 1977 EXPECT_EQ(4u, entries1.size()); |
1978 EXPECT_TRUE(LogContainsBeginEvent( | 1978 EXPECT_TRUE(LogContainsBeginEvent( |
1979 entries1, 0, NetLog::TYPE_PROXY_SERVICE)); | 1979 entries1, 0, NetLog::TYPE_PROXY_SERVICE)); |
1980 EXPECT_TRUE(LogContainsBeginEvent( | 1980 EXPECT_TRUE(LogContainsBeginEvent( |
1981 entries1, 1, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); | 1981 entries1, 1, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); |
1982 // Note that TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC is never completed before | 1982 // Note that TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC is never completed before |
1983 // the cancellation occured. | 1983 // the cancellation occured. |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2416 | 2416 |
2417 EXPECT_TRUE(info2.is_direct()); | 2417 EXPECT_TRUE(info2.is_direct()); |
2418 } | 2418 } |
2419 | 2419 |
2420 TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { | 2420 TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
2421 MockProxyConfigService* config_service = | 2421 MockProxyConfigService* config_service = |
2422 new MockProxyConfigService("http://foopy/proxy.pac"); | 2422 new MockProxyConfigService("http://foopy/proxy.pac"); |
2423 | 2423 |
2424 MockAsyncProxyResolverExpectsBytes resolver; | 2424 MockAsyncProxyResolverExpectsBytes resolver; |
2425 | 2425 |
2426 CapturingNetLog log; | 2426 TestNetLog log; |
2427 | 2427 |
2428 ProxyService service( | 2428 ProxyService service( |
2429 config_service, | 2429 config_service, |
2430 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), &log); | 2430 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), &log); |
2431 | 2431 |
2432 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; | 2432 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
2433 service.SetProxyScriptFetchers(fetcher, | 2433 service.SetProxyScriptFetchers(fetcher, |
2434 new DoNothingDhcpProxyScriptFetcher()); | 2434 new DoNothingDhcpProxyScriptFetcher()); |
2435 | 2435 |
2436 // Disable the "wait after IP address changes" hack, so this unit-test can | 2436 // Disable the "wait after IP address changes" hack, so this unit-test can |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80"); | 2513 resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80"); |
2514 resolver.pending_requests()[0]->CompleteNow(OK); | 2514 resolver.pending_requests()[0]->CompleteNow(OK); |
2515 | 2515 |
2516 // Wait for completion callback, and verify that the request ran as expected. | 2516 // Wait for completion callback, and verify that the request ran as expected. |
2517 EXPECT_EQ(OK, callback2.WaitForResult()); | 2517 EXPECT_EQ(OK, callback2.WaitForResult()); |
2518 EXPECT_EQ("request2:80", info2.proxy_server().ToURI()); | 2518 EXPECT_EQ("request2:80", info2.proxy_server().ToURI()); |
2519 | 2519 |
2520 // Check that the expected events were output to the log stream. In particular | 2520 // Check that the expected events were output to the log stream. In particular |
2521 // PROXY_CONFIG_CHANGED should have only been emitted once (for the initial | 2521 // PROXY_CONFIG_CHANGED should have only been emitted once (for the initial |
2522 // setup), and NOT a second time when the IP address changed. | 2522 // setup), and NOT a second time when the IP address changed. |
2523 CapturingNetLog::CapturedEntryList entries; | 2523 TestNetLog::CapturedEntryList entries; |
2524 log.GetEntries(&entries); | 2524 log.GetEntries(&entries); |
2525 | 2525 |
2526 EXPECT_TRUE(LogContainsEntryWithType(entries, 0, | 2526 EXPECT_TRUE(LogContainsEntryWithType(entries, 0, |
2527 NetLog::TYPE_PROXY_CONFIG_CHANGED)); | 2527 NetLog::TYPE_PROXY_CONFIG_CHANGED)); |
2528 ASSERT_EQ(9u, entries.size()); | 2528 ASSERT_EQ(9u, entries.size()); |
2529 for (size_t i = 1; i < entries.size(); ++i) | 2529 for (size_t i = 1; i < entries.size(); ++i) |
2530 EXPECT_NE(NetLog::TYPE_PROXY_CONFIG_CHANGED, entries[i].type); | 2530 EXPECT_NE(NetLog::TYPE_PROXY_CONFIG_CHANGED, entries[i].type); |
2531 } | 2531 } |
2532 | 2532 |
2533 // This test verifies that the PAC script specified by the settings is | 2533 // This test verifies that the PAC script specified by the settings is |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 MockAsyncProxyResolver resolver; | 3124 MockAsyncProxyResolver resolver; |
3125 | 3125 |
3126 ProxyService service( | 3126 ProxyService service( |
3127 config_service, | 3127 config_service, |
3128 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); | 3128 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
3129 | 3129 |
3130 GURL url("http://www.google.com/"); | 3130 GURL url("http://www.google.com/"); |
3131 | 3131 |
3132 ProxyInfo info; | 3132 ProxyInfo info; |
3133 info.UseDirect(); | 3133 info.UseDirect(); |
3134 CapturingBoundNetLog log; | 3134 BoundTestNetLog log; |
3135 | 3135 |
3136 bool synchronous_success = service.TryResolveProxySynchronously( | 3136 bool synchronous_success = service.TryResolveProxySynchronously( |
3137 url, net::LOAD_NORMAL, &info, NULL, log.bound()); | 3137 url, net::LOAD_NORMAL, &info, NULL, log.bound()); |
3138 EXPECT_FALSE(synchronous_success); | 3138 EXPECT_FALSE(synchronous_success); |
3139 | 3139 |
3140 // No request should have been queued. | 3140 // No request should have been queued. |
3141 EXPECT_EQ(0u, resolver.pending_requests().size()); | 3141 EXPECT_EQ(0u, resolver.pending_requests().size()); |
3142 | 3142 |
3143 // |info| should not have been modified. | 3143 // |info| should not have been modified. |
3144 EXPECT_TRUE(info.is_direct()); | 3144 EXPECT_TRUE(info.is_direct()); |
3145 } | 3145 } |
3146 | 3146 |
3147 // Test that synchronous results are returned correctly if a fixed proxy | 3147 // Test that synchronous results are returned correctly if a fixed proxy |
3148 // configuration is active. | 3148 // configuration is active. |
3149 TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) { | 3149 TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) { |
3150 ProxyConfig config; | 3150 ProxyConfig config; |
3151 config.proxy_rules().ParseFromString("foopy1:8080"); | 3151 config.proxy_rules().ParseFromString("foopy1:8080"); |
3152 config.set_auto_detect(false); | 3152 config.set_auto_detect(false); |
3153 | 3153 |
3154 MockAsyncProxyResolver resolver; | 3154 MockAsyncProxyResolver resolver; |
3155 | 3155 |
3156 ProxyService service( | 3156 ProxyService service( |
3157 new MockProxyConfigService(config), | 3157 new MockProxyConfigService(config), |
3158 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); | 3158 make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
3159 | 3159 |
3160 GURL url("http://www.google.com/"); | 3160 GURL url("http://www.google.com/"); |
3161 | 3161 |
3162 ProxyInfo info; | 3162 ProxyInfo info; |
3163 CapturingBoundNetLog log; | 3163 BoundTestNetLog log; |
3164 | 3164 |
3165 bool synchronous_success = service.TryResolveProxySynchronously( | 3165 bool synchronous_success = service.TryResolveProxySynchronously( |
3166 url, net::LOAD_NORMAL, &info, NULL, log.bound()); | 3166 url, net::LOAD_NORMAL, &info, NULL, log.bound()); |
3167 EXPECT_TRUE(synchronous_success); | 3167 EXPECT_TRUE(synchronous_success); |
3168 EXPECT_FALSE(info.is_direct()); | 3168 EXPECT_FALSE(info.is_direct()); |
3169 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); | 3169 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); |
3170 | 3170 |
3171 // No request should have been queued. | 3171 // No request should have been queued. |
3172 EXPECT_EQ(0u, resolver.pending_requests().size()); | 3172 EXPECT_EQ(0u, resolver.pending_requests().size()); |
3173 } | 3173 } |
3174 | 3174 |
3175 } // namespace net | 3175 } // namespace net |
OLD | NEW |