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

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

Issue 1680893002: Moving proxy resolution logic out of NetworkDelegate and into ProxyDelegate for DataReductionProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | net/url_request/url_request_test_util.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) 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 <cstdarg> 7 #include <cstdarg>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/network_delegate_impl.h" 17 #include "net/base/proxy_delegate.h"
18 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
19 #include "net/log/net_log.h" 19 #include "net/log/net_log.h"
20 #include "net/log/test_net_log.h" 20 #include "net/log/test_net_log.h"
21 #include "net/log/test_net_log_entry.h" 21 #include "net/log/test_net_log_entry.h"
22 #include "net/log/test_net_log_util.h" 22 #include "net/log/test_net_log_util.h"
23 #include "net/proxy/dhcp_proxy_script_fetcher.h" 23 #include "net/proxy/dhcp_proxy_script_fetcher.h"
24 #include "net/proxy/mock_proxy_resolver.h" 24 #include "net/proxy/mock_proxy_resolver.h"
25 #include "net/proxy/mock_proxy_script_fetcher.h" 25 #include "net/proxy/mock_proxy_script_fetcher.h"
26 #include "net/proxy/proxy_config_service.h" 26 #include "net/proxy/proxy_config_service.h"
27 #include "net/proxy/proxy_resolver.h" 27 #include "net/proxy/proxy_resolver.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 OnProxyConfigChanged(config_, availability_)); 155 OnProxyConfigChanged(config_, availability_));
156 } 156 }
157 157
158 private: 158 private:
159 ConfigAvailability availability_; 159 ConfigAvailability availability_;
160 ProxyConfig config_; 160 ProxyConfig config_;
161 base::ObserverList<Observer, true> observers_; 161 base::ObserverList<Observer, true> observers_;
162 }; 162 };
163 163
164 // A test network delegate that exercises the OnResolveProxy callback. 164 // A test network delegate that exercises the OnResolveProxy callback.
165 class TestResolveProxyNetworkDelegate : public NetworkDelegateImpl { 165 class TestResolveProxyDelegate : public ProxyDelegate {
166 public: 166 public:
167 TestResolveProxyNetworkDelegate() 167 TestResolveProxyDelegate()
168 : on_resolve_proxy_called_(false), 168 : on_resolve_proxy_called_(false),
169 add_proxy_(false), 169 add_proxy_(false),
170 remove_proxy_(false), 170 remove_proxy_(false),
171 proxy_service_(NULL) { 171 proxy_service_(nullptr) {}
172 }
173 172
174 void OnResolveProxy(const GURL& url, 173 void OnResolveProxy(const GURL& url,
175 int load_flags, 174 int load_flags,
176 const ProxyService& proxy_service, 175 const ProxyService& proxy_service,
177 ProxyInfo* result) override { 176 ProxyInfo* result) override {
178 on_resolve_proxy_called_ = true; 177 on_resolve_proxy_called_ = true;
179 proxy_service_ = &proxy_service; 178 proxy_service_ = &proxy_service;
180 DCHECK(!add_proxy_ || !remove_proxy_); 179 DCHECK(!add_proxy_ || !remove_proxy_);
181 if (add_proxy_) { 180 if (add_proxy_) {
182 result->UseNamedProxy("delegate_proxy.com"); 181 result->UseNamedProxy("delegate_proxy.com");
(...skipping 11 matching lines...) Expand all
194 } 193 }
195 194
196 void set_remove_proxy(bool remove_proxy) { 195 void set_remove_proxy(bool remove_proxy) {
197 remove_proxy_ = remove_proxy; 196 remove_proxy_ = remove_proxy;
198 } 197 }
199 198
200 const ProxyService* proxy_service() const { 199 const ProxyService* proxy_service() const {
201 return proxy_service_; 200 return proxy_service_;
202 } 201 }
203 202
203 void OnTunnelConnectCompleted(const HostPortPair& endpoint,
204 const HostPortPair& proxy_server,
205 int net_error) override {}
206 void OnFallback(const ProxyServer& bad_proxy, int net_error) override {}
207 void OnBeforeSendHeaders(URLRequest* request,
208 const ProxyInfo& proxy_info,
209 HttpRequestHeaders* headers) override {}
210 void OnBeforeTunnelRequest(const HostPortPair& proxy_server,
211 HttpRequestHeaders* extra_headers) override {}
212 void OnTunnelHeadersReceived(
213 const HostPortPair& origin,
214 const HostPortPair& proxy_server,
215 const HttpResponseHeaders& response_headers) override {}
216 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override {
217 return true;
218 }
219
204 private: 220 private:
205 bool on_resolve_proxy_called_; 221 bool on_resolve_proxy_called_;
206 bool add_proxy_; 222 bool add_proxy_;
207 bool remove_proxy_; 223 bool remove_proxy_;
208 const ProxyService* proxy_service_; 224 const ProxyService* proxy_service_;
209 }; 225 };
210 226
211 // A test network delegate that exercises the OnProxyFallback callback. 227 // A test network delegate that exercises the OnProxyFallback callback.
212 class TestProxyFallbackNetworkDelegate : public NetworkDelegateImpl { 228 class TestProxyFallbackProxyDelegate : public ProxyDelegate {
213 public: 229 public:
214 TestProxyFallbackNetworkDelegate() 230 TestProxyFallbackProxyDelegate()
215 : on_proxy_fallback_called_(false), 231 : on_proxy_fallback_called_(false), proxy_fallback_net_error_(OK) {}
216 proxy_fallback_net_error_(OK) {
217 }
218 232
219 void OnProxyFallback(const ProxyServer& proxy_server, 233 // ProxyDelegate implementation:
220 int net_error) override { 234 void OnResolveProxy(const GURL& url,
221 proxy_server_ = proxy_server; 235 int load_flags,
236 const ProxyService& proxy_service,
237 ProxyInfo* result) override {}
238 void OnTunnelConnectCompleted(const HostPortPair& endpoint,
239 const HostPortPair& proxy_server,
240 int net_error) override {}
241 void OnFallback(const ProxyServer& bad_proxy, int net_error) override {
242 proxy_server_ = bad_proxy;
222 proxy_fallback_net_error_ = net_error; 243 proxy_fallback_net_error_ = net_error;
223 on_proxy_fallback_called_ = true; 244 on_proxy_fallback_called_ = true;
224 } 245 }
246 void OnBeforeSendHeaders(URLRequest* request,
247 const ProxyInfo& proxy_info,
248 HttpRequestHeaders* headers) override {}
249 void OnBeforeTunnelRequest(const HostPortPair& proxy_server,
250 HttpRequestHeaders* extra_headers) override {}
251 void OnTunnelHeadersReceived(
252 const HostPortPair& origin,
253 const HostPortPair& proxy_server,
254 const HttpResponseHeaders& response_headers) override {}
255 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override {
256 return true;
257 }
225 258
226 bool on_proxy_fallback_called() const { 259 bool on_proxy_fallback_called() const {
227 return on_proxy_fallback_called_; 260 return on_proxy_fallback_called_;
228 } 261 }
229 262
230 const ProxyServer& proxy_server() const { 263 const ProxyServer& proxy_server() const {
231 return proxy_server_; 264 return proxy_server_;
232 } 265 }
233 266
234 int proxy_fallback_net_error() const { 267 int proxy_fallback_net_error() const {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 ProxyInfo info; 392 ProxyInfo info;
360 TestCompletionCallback callback; 393 TestCompletionCallback callback;
361 BoundTestNetLog log; 394 BoundTestNetLog log;
362 395
363 // First, warm up the ProxyService. 396 // First, warm up the ProxyService.
364 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), 397 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(),
365 NULL, NULL, log.bound()); 398 NULL, NULL, log.bound());
366 EXPECT_EQ(OK, rv); 399 EXPECT_EQ(OK, rv);
367 400
368 // Verify that network delegate is invoked. 401 // Verify that network delegate is invoked.
369 TestResolveProxyNetworkDelegate delegate; 402 TestResolveProxyDelegate delegate;
370 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, 403 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL,
371 &delegate, log.bound()); 404 &delegate, log.bound());
372 EXPECT_TRUE(delegate.on_resolve_proxy_called()); 405 EXPECT_TRUE(delegate.on_resolve_proxy_called());
373 EXPECT_EQ(&service, delegate.proxy_service()); 406 EXPECT_EQ(&service, delegate.proxy_service());
374 407
375 // Verify that the NetworkDelegate's behavior is stateless across 408 // Verify that the ProxyDelegate's behavior is stateless across
376 // invocations of ResolveProxy. Start by having the callback add a proxy 409 // invocations of ResolveProxy. Start by having the callback add a proxy
377 // and checking that subsequent requests are not affected. 410 // and checking that subsequent requests are not affected.
378 delegate.set_add_proxy(true); 411 delegate.set_add_proxy(true);
379 412
380 // Callback should interpose: 413 // Callback should interpose:
381 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, 414 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL,
382 &delegate, log.bound()); 415 &delegate, log.bound());
383 EXPECT_FALSE(info.is_direct()); 416 EXPECT_FALSE(info.is_direct());
384 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); 417 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com");
385 delegate.set_add_proxy(false); 418 delegate.set_add_proxy(false);
386 419
387 // Check non-bypassed URL: 420 // Check non-bypassed URL:
388 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, 421 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL,
389 &delegate, log.bound()); 422 &delegate, log.bound());
390 EXPECT_FALSE(info.is_direct()); 423 EXPECT_FALSE(info.is_direct());
391 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); 424 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1");
392 425
393 // Check bypassed URL: 426 // Check bypassed URL:
394 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(), 427 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(),
395 NULL, &delegate, log.bound()); 428 NULL, &delegate, log.bound());
396 EXPECT_TRUE(info.is_direct()); 429 EXPECT_TRUE(info.is_direct());
397 } 430 }
398 431
399 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) { 432 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) {
400 // Same as OnResolveProxyCallbackAddProxy, but verify that the 433 // Same as OnResolveProxyCallbackAddProxy, but verify that the
401 // NetworkDelegate's behavior is stateless across invocations after it 434 // ProxyDelegate's behavior is stateless across invocations after it
402 // *removes* a proxy. 435 // *removes* a proxy.
403 ProxyConfig config; 436 ProxyConfig config;
404 config.proxy_rules().ParseFromString("foopy1:8080"); 437 config.proxy_rules().ParseFromString("foopy1:8080");
405 config.set_auto_detect(false); 438 config.set_auto_detect(false);
406 config.proxy_rules().bypass_rules.ParseFromString("*.org"); 439 config.proxy_rules().bypass_rules.ParseFromString("*.org");
407 440
408 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)), 441 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
409 nullptr, NULL); 442 nullptr, NULL);
410 443
411 GURL url("http://www.google.com/"); 444 GURL url("http://www.google.com/");
412 GURL bypass_url("http://internet.org"); 445 GURL bypass_url("http://internet.org");
413 446
414 ProxyInfo info; 447 ProxyInfo info;
415 TestCompletionCallback callback; 448 TestCompletionCallback callback;
416 BoundTestNetLog log; 449 BoundTestNetLog log;
417 450
418 // First, warm up the ProxyService. 451 // First, warm up the ProxyService.
419 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), 452 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(),
420 NULL, NULL, log.bound()); 453 NULL, NULL, log.bound());
421 EXPECT_EQ(OK, rv); 454 EXPECT_EQ(OK, rv);
422 455
423 TestResolveProxyNetworkDelegate delegate; 456 TestResolveProxyDelegate delegate;
424 delegate.set_remove_proxy(true); 457 delegate.set_remove_proxy(true);
425 458
426 // Callback should interpose: 459 // Callback should interpose:
427 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, 460 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL,
428 &delegate, log.bound()); 461 &delegate, log.bound());
429 EXPECT_TRUE(info.is_direct()); 462 EXPECT_TRUE(info.is_direct());
430 delegate.set_remove_proxy(false); 463 delegate.set_remove_proxy(false);
431 464
432 // Check non-bypassed URL: 465 // Check non-bypassed URL:
433 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, 466 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI()); 602 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI());
570 EXPECT_TRUE(info.did_use_pac_script()); 603 EXPECT_TRUE(info.did_use_pac_script());
571 604
572 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); 605 EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
573 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); 606 EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
574 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); 607 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
575 608
576 // Now, imagine that connecting to foopy:8080 fails: there is nothing 609 // Now, imagine that connecting to foopy:8080 fails: there is nothing
577 // left to fallback to, since our proxy list was NOT terminated by 610 // left to fallback to, since our proxy list was NOT terminated by
578 // DIRECT. 611 // DIRECT.
579 NetworkDelegateImpl network_delegate; 612 TestResolveProxyDelegate proxy_delegate;
580 TestCompletionCallback callback2; 613 TestCompletionCallback callback2;
581 ProxyServer expected_proxy_server = info.proxy_server(); 614 ProxyServer expected_proxy_server = info.proxy_server();
582 rv = service.ReconsiderProxyAfterError( 615 rv = service.ReconsiderProxyAfterError(
583 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, 616 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
584 callback2.callback(), NULL, &network_delegate, BoundNetLog()); 617 callback2.callback(), NULL, &proxy_delegate, BoundNetLog());
585 // ReconsiderProxyAfterError returns error indicating nothing left. 618 // ReconsiderProxyAfterError returns error indicating nothing left.
586 EXPECT_EQ(ERR_FAILED, rv); 619 EXPECT_EQ(ERR_FAILED, rv);
587 EXPECT_TRUE(info.is_empty()); 620 EXPECT_TRUE(info.is_empty());
588 } 621 }
589 622
590 // Test that if the execution of the PAC script fails (i.e. javascript runtime 623 // Test that if the execution of the PAC script fails (i.e. javascript runtime
591 // error), and the PAC settings are non-mandatory, that we fall-back to direct. 624 // error), and the PAC settings are non-mandatory, that we fall-back to direct.
592 TEST_F(ProxyServiceTest, PAC_RuntimeError) { 625 TEST_F(ProxyServiceTest, PAC_RuntimeError) {
593 MockProxyConfigService* config_service = 626 MockProxyConfigService* config_service =
594 new MockProxyConfigService("http://foopy/proxy.pac"); 627 new MockProxyConfigService("http://foopy/proxy.pac");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // Fallback 1. 716 // Fallback 1.
684 TestCompletionCallback callback2; 717 TestCompletionCallback callback2;
685 rv = service.ReconsiderProxyAfterError( 718 rv = service.ReconsiderProxyAfterError(
686 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, 719 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
687 callback2.callback(), NULL, NULL, BoundNetLog()); 720 callback2.callback(), NULL, NULL, BoundNetLog());
688 EXPECT_EQ(OK, rv); 721 EXPECT_EQ(OK, rv);
689 EXPECT_FALSE(info.is_direct()); 722 EXPECT_FALSE(info.is_direct());
690 EXPECT_EQ("foobar:10", info.proxy_server().ToURI()); 723 EXPECT_EQ("foobar:10", info.proxy_server().ToURI());
691 724
692 // Fallback 2. 725 // Fallback 2.
693 NetworkDelegateImpl network_delegate; 726 TestResolveProxyDelegate proxy_delegate;
694 ProxyServer expected_proxy_server3 = info.proxy_server(); 727 ProxyServer expected_proxy_server3 = info.proxy_server();
695 TestCompletionCallback callback3; 728 TestCompletionCallback callback3;
696 rv = service.ReconsiderProxyAfterError( 729 rv = service.ReconsiderProxyAfterError(
697 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, 730 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
698 callback3.callback(), NULL, &network_delegate, BoundNetLog()); 731 callback3.callback(), NULL, &proxy_delegate, BoundNetLog());
699 EXPECT_EQ(OK, rv); 732 EXPECT_EQ(OK, rv);
700 EXPECT_TRUE(info.is_direct()); 733 EXPECT_TRUE(info.is_direct());
701 734
702 // Fallback 3. 735 // Fallback 3.
703 ProxyServer expected_proxy_server4 = info.proxy_server(); 736 ProxyServer expected_proxy_server4 = info.proxy_server();
704 TestCompletionCallback callback4; 737 TestCompletionCallback callback4;
705 rv = service.ReconsiderProxyAfterError( 738 rv = service.ReconsiderProxyAfterError(
706 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, 739 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
707 callback4.callback(), NULL, &network_delegate, BoundNetLog()); 740 callback4.callback(), NULL, &proxy_delegate, BoundNetLog());
708 EXPECT_EQ(OK, rv); 741 EXPECT_EQ(OK, rv);
709 EXPECT_FALSE(info.is_direct()); 742 EXPECT_FALSE(info.is_direct());
710 EXPECT_EQ("foobar:20", info.proxy_server().ToURI()); 743 EXPECT_EQ("foobar:20", info.proxy_server().ToURI());
711 744
712 // Fallback 4 -- Nothing to fall back to! 745 // Fallback 4 -- Nothing to fall back to!
713 ProxyServer expected_proxy_server5 = info.proxy_server(); 746 ProxyServer expected_proxy_server5 = info.proxy_server();
714 TestCompletionCallback callback5; 747 TestCompletionCallback callback5;
715 rv = service.ReconsiderProxyAfterError( 748 rv = service.ReconsiderProxyAfterError(
716 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, 749 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
717 callback5.callback(), NULL, &network_delegate, BoundNetLog()); 750 callback5.callback(), NULL, &proxy_delegate, BoundNetLog());
718 EXPECT_EQ(ERR_FAILED, rv); 751 EXPECT_EQ(ERR_FAILED, rv);
719 EXPECT_TRUE(info.is_empty()); 752 EXPECT_TRUE(info.is_empty());
720 } 753 }
721 754
722 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { 755 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) {
723 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied 756 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied
724 // to ProxyInfo after the proxy is resolved via a PAC script. 757 // to ProxyInfo after the proxy is resolved via a PAC script.
725 ProxyConfig config = 758 ProxyConfig config =
726 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); 759 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac"));
727 config.set_source(PROXY_CONFIG_SOURCE_TEST); 760 config.set_source(PROXY_CONFIG_SOURCE_TEST);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 EXPECT_EQ(OK, rv); 1201 EXPECT_EQ(OK, rv);
1169 1202
1170 // Proxy times should not have been modified by fallback. 1203 // Proxy times should not have been modified by fallback.
1171 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time()); 1204 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time());
1172 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); 1205 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time());
1173 1206
1174 // The second proxy should be specified. 1207 // The second proxy should be specified.
1175 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); 1208 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
1176 // Report back that the second proxy worked. This will globally mark the 1209 // Report back that the second proxy worked. This will globally mark the
1177 // first proxy as bad. 1210 // first proxy as bad.
1178 TestProxyFallbackNetworkDelegate test_delegate; 1211 TestProxyFallbackProxyDelegate test_delegate;
1179 service.ReportSuccess(info, &test_delegate); 1212 service.ReportSuccess(info, &test_delegate);
1180 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI()); 1213 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI());
1181 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, 1214 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
1182 test_delegate.proxy_fallback_net_error()); 1215 test_delegate.proxy_fallback_net_error());
1183 1216
1184 TestCompletionCallback callback3; 1217 TestCompletionCallback callback3;
1185 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL, 1218 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL,
1186 NULL, BoundNetLog()); 1219 NULL, BoundNetLog());
1187 EXPECT_EQ(ERR_IO_PENDING, rv); 1220 EXPECT_EQ(ERR_IO_PENDING, rv);
1188 1221
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3377 url, LOAD_NORMAL, &info, NULL, log.bound()); 3410 url, LOAD_NORMAL, &info, NULL, log.bound());
3378 EXPECT_TRUE(synchronous_success); 3411 EXPECT_TRUE(synchronous_success);
3379 EXPECT_FALSE(info.is_direct()); 3412 EXPECT_FALSE(info.is_direct());
3380 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); 3413 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host());
3381 3414
3382 // No request should have been queued. 3415 // No request should have been queued.
3383 EXPECT_EQ(0u, factory->pending_requests().size()); 3416 EXPECT_EQ(0u, factory->pending_requests().size());
3384 } 3417 }
3385 3418
3386 } // namespace net 3419 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698