Index: net/proxy/proxy_service_unittest.cc |
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc |
index db4151dbc51557aedae644b8fdc9ac13b1d18b86..f251933821a90b28eccde5ed8a1311ac2caf8d0c 100644 |
--- a/net/proxy/proxy_service_unittest.cc |
+++ b/net/proxy/proxy_service_unittest.cc |
@@ -240,10 +240,10 @@ class TestProxyFallbackNetworkDelegate : public NetworkDelegateImpl { |
} // namespace |
TEST_F(ProxyServiceTest, Direct) { |
- MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
new MockProxyConfigService(ProxyConfig::CreateDirect()), |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
eroman
2015/04/22 16:30:38
Would it be clearer to just get rid of ForwardingP
Sam McNally
2015/04/23 03:04:44
Done.
|
GURL url("http://www.google.com/"); |
@@ -254,7 +254,7 @@ TEST_F(ProxyServiceTest, Direct) { |
url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, |
log.bound()); |
EXPECT_EQ(OK, rv); |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
EXPECT_TRUE(info.is_direct()); |
EXPECT_TRUE(info.proxy_resolve_start_time().is_null()); |
@@ -383,10 +383,11 @@ TEST_F(ProxyServiceTest, PAC) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -402,9 +403,10 @@ TEST_F(ProxyServiceTest, PAC) { |
EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, service.GetLoadState(request)); |
+ ASSERT_EQ(1u, factory.pending_requests().size()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -444,10 +446,11 @@ TEST_F(ProxyServiceTest, PAC_NoIdentityOrHash) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://username:password@www.google.com/?ref#hash#hash"); |
@@ -459,8 +462,8 @@ TEST_F(ProxyServiceTest, PAC_NoIdentityOrHash) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
// The URL should have been simplified, stripping the username/password/hash. |
@@ -475,10 +478,11 @@ TEST_F(ProxyServiceTest, PAC_FailoverWithoutDirect) { |
MockProxyConfigService* config_service = |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -490,8 +494,8 @@ TEST_F(ProxyServiceTest, PAC_FailoverWithoutDirect) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -529,10 +533,11 @@ TEST_F(ProxyServiceTest, PAC_RuntimeError) { |
MockProxyConfigService* config_service = |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://this-causes-js-error/"); |
@@ -544,8 +549,8 @@ TEST_F(ProxyServiceTest, PAC_RuntimeError) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -587,10 +592,11 @@ TEST_F(ProxyServiceTest, PAC_FailoverAfterDirect) { |
MockProxyConfigService* config_service = |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -602,8 +608,8 @@ TEST_F(ProxyServiceTest, PAC_FailoverAfterDirect) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -668,9 +674,10 @@ TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Resolve something. |
GURL url("http://www.google.com/"); |
@@ -680,7 +687,7 @@ TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { |
url, net::LOAD_NORMAL, &info, callback.callback(), NULL, NULL, |
BoundNetLog()); |
ASSERT_EQ(ERR_IO_PENDING, rv); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
// Set the result in proxy resolver. |
@@ -705,10 +712,11 @@ TEST_F(ProxyServiceTest, ProxyResolverFails) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Start first resolve request. |
GURL url("http://www.google.com/"); |
@@ -720,8 +728,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFails) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -770,11 +778,11 @@ TEST_F(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
- MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Start first resolve request. |
GURL url("http://www.google.com/"); |
@@ -786,18 +794,18 @@ TEST_F(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(ERR_FAILED); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNow(ERR_FAILED, nullptr); |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
- // As the proxy resolver failed the request and is configured for a mandatory |
- // PAC script, ProxyService must not implicitly fall-back to DIRECT. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
+ // As the proxy resolver factory failed the request and is configured for a |
+ // mandatory PAC script, ProxyService must not implicitly fall-back to DIRECT. |
EXPECT_EQ(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, |
callback1.WaitForResult()); |
EXPECT_FALSE(info.is_direct()); |
- // As the proxy resolver failed the request and is configured for a mandatory |
- // PAC script, ProxyService must not implicitly fall-back to DIRECT. |
+ // As the proxy resolver factory failed the request and is configured for a |
+ // mandatory PAC script, ProxyService must not implicitly fall-back to DIRECT. |
TestCompletionCallback callback2; |
rv = service.ResolveProxy( |
url, net::LOAD_NORMAL, &info, callback2.callback(), NULL, NULL, |
@@ -817,11 +825,11 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
- MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
DhcpProxyScriptFetcher* dhcp_fetcher = new DoNothingDhcpProxyScriptFetcher(); |
@@ -836,8 +844,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// Downloading the PAC script succeeds. |
EXPECT_TRUE(fetcher->has_pending_request()); |
@@ -845,7 +853,7 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) { |
fetcher->NotifyFetchCompletion(OK, "invalid-script-contents"); |
EXPECT_FALSE(fetcher->has_pending_request()); |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// Since ProxyScriptDecider failed to identify a valid PAC and PAC was |
// mandatory for this configuration, the ProxyService must not implicitly |
@@ -868,10 +876,11 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Start first resolve request. |
GURL url("http://www.google.com/"); |
@@ -883,8 +892,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -927,10 +936,11 @@ TEST_F(ProxyServiceTest, ProxyFallback) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -943,8 +953,8 @@ TEST_F(ProxyServiceTest, ProxyFallback) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1082,10 +1092,11 @@ TEST_F(ProxyServiceTest, ProxyFallbackToDirect) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -1098,8 +1109,8 @@ TEST_F(ProxyServiceTest, ProxyFallbackToDirect) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1158,10 +1169,11 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -1174,8 +1186,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1202,8 +1214,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy-new/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1239,8 +1251,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy-new2/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1264,10 +1276,11 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfig) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -1280,8 +1293,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfig) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1365,10 +1378,11 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfigMandatory) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -1381,8 +1395,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfigMandatory) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(url, resolver.pending_requests()[0]->url()); |
@@ -1655,10 +1669,11 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Start 3 requests. |
@@ -1669,14 +1684,10 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Nothing has been sent to the proxy resolver yet, since the proxy |
- // resolver has not been configured yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
- |
// Successfully initialize the PAC script. |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->url()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -1732,10 +1743,11 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -1771,8 +1783,8 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
EXPECT_EQ(LOAD_STATE_DOWNLOADING_PROXY_SCRIPT, |
service.GetLoadState(request1)); |
@@ -1789,8 +1801,8 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) { |
// Now that the PAC script is downloaded, it will have been sent to the proxy |
// resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(3u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -1839,10 +1851,11 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -1878,16 +1891,16 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) { |
service.SetProxyScriptFetchers(fetcher, |
new DoNothingDhcpProxyScriptFetcher()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
fetcher->NotifyFetchCompletion(OK, kValidPacScript1); |
// Now that the PAC script is downloaded, it will have been sent to the proxy |
// resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(2u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -1900,10 +1913,11 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -1937,8 +1951,8 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) { |
callback3.callback(), NULL, NULL, BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// Cancel the first 2 requests. |
service.CancelPacRequest(request1); |
@@ -1952,8 +1966,8 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) { |
// Now that the PAC script is downloaded, it will have been sent to the |
// proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request3"), resolver.pending_requests()[0]->url()); |
@@ -1996,9 +2010,10 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2021,8 +2036,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// It should be trying to auto-detect first -- FAIL the autodetect during |
// the script download. |
@@ -2036,8 +2051,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) { |
fetcher->NotifyFetchCompletion(OK, kValidPacScript1); |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
// Now finally, the pending requests should have been sent to the resolver |
// (which was initialized with custom PAC script). |
@@ -2076,9 +2091,10 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2101,8 +2117,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// It should be trying to auto-detect first -- succeed the download. |
EXPECT_TRUE(fetcher->has_pending_request()); |
@@ -2118,8 +2134,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) { |
fetcher->NotifyFetchCompletion(OK, kValidPacScript1); |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
// Now finally, the pending requests should have been sent to the resolver |
// (which was initialized with custom PAC script). |
@@ -2151,10 +2167,10 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) { |
config.proxy_rules().ParseFromString("http=foopy:80"); |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
- MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2177,8 +2193,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// It should be trying to auto-detect first -- fail the download. |
EXPECT_TRUE(fetcher->has_pending_request()); |
@@ -2192,7 +2208,7 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) { |
// Since we never managed to initialize a resolver, nothing should have been |
// sent to it. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// Verify that requests ran as expected -- they should have fallen back to |
// the manual proxy configuration for HTTP urls. |
@@ -2213,9 +2229,10 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2230,8 +2247,8 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) { |
callback1.callback(), NULL, NULL, BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// It should be trying to auto-detect first -- succeed the download. |
EXPECT_TRUE(fetcher->has_pending_request()); |
@@ -2239,8 +2256,8 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) { |
fetcher->NotifyFetchCompletion(OK, kValidPacScript1); |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://www.google.com"), |
@@ -2283,10 +2300,10 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) { |
ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
- MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2301,8 +2318,8 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
+ // Check that nothing has been sent to the proxy resolver factory yet. |
+ ASSERT_EQ(0u, factory.pending_requests().size()); |
// InitProxyResolver should have issued a request to the ProxyScriptFetcher |
// and be waiting on that to complete. |
@@ -2318,11 +2335,11 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) { |
MockProxyConfigService* config_service = |
new MockProxyConfigService("http://foopy/proxy.pac"); |
- MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -2334,7 +2351,7 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) { |
EXPECT_EQ(ERR_IO_PENDING, rv); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), |
- resolver.pending_set_pac_script_request()->script_data()->url()); |
+ factory.pending_requests()[0]->script_data()->url()); |
} |
TEST_F(ProxyServiceTest, ResetProxyConfigService) { |
@@ -2369,9 +2386,10 @@ TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) { |
MockProxyConfigService* config_service = new MockProxyConfigService(config); |
MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
// Start 1 request. |
@@ -2382,13 +2400,10 @@ TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) { |
BoundNetLog()); |
EXPECT_EQ(ERR_IO_PENDING, rv); |
- // Check that nothing has been sent to the proxy resolver yet. |
- ASSERT_EQ(0u, resolver.pending_requests().size()); |
- |
// Successfully set the autodetect script. |
EXPECT_EQ(ProxyResolverScriptData::TYPE_AUTO_DETECT, |
- resolver.pending_set_pac_script_request()->script_data()->type()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->type()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
// Complete the pending request. |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
@@ -2422,12 +2437,13 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
TestNetLog log; |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), &log); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), &log); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2450,8 +2466,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -2461,8 +2477,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
// Now that the PAC script is downloaded, the request will have been sent to |
// the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -2493,8 +2509,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// Simulate the PAC script fetch as having completed (this time with |
// different data). |
@@ -2503,8 +2519,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { |
// Now that the PAC script is downloaded, the second request will have been |
// sent to the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript2), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request2"), resolver.pending_requests()[0]->url()); |
@@ -2544,10 +2560,11 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2566,8 +2583,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -2577,7 +2594,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) { |
// fall-back to DIRECT connections. |
fetcher->NotifyFetchCompletion(ERR_FAILED, std::string()); |
- ASSERT_TRUE(resolver.pending_requests().empty()); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
// Wait for completion callback, and verify it used DIRECT. |
EXPECT_EQ(OK, callback1.WaitForResult()); |
@@ -2593,7 +2610,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) { |
// special unit-test mode. |
fetcher->WaitUntilFetch(); |
- ASSERT_TRUE(resolver.pending_requests().empty()); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
// Make sure that our background checker is trying to download the expected |
// PAC script (same one as before). This time we will simulate a successful |
@@ -2607,8 +2624,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) { |
// Now that the PAC script is downloaded, it should be used to initialize the |
// ProxyResolver. Simulate a successful parse. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
// At this point the ProxyService should have re-configured itself to use the |
// PAC script (thereby recovering from the initial fetch failure). We will |
@@ -2650,10 +2667,11 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2672,8 +2690,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -2683,8 +2701,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) { |
// Now that the PAC script is downloaded, the request will have been sent to |
// the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -2706,6 +2724,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) { |
// special unit-test mode. |
fetcher->WaitUntilFetch(); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
ASSERT_TRUE(resolver.pending_requests().empty()); |
// Make sure that our background checker is trying to download the expected |
@@ -2720,8 +2739,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) { |
// Now that the PAC script is downloaded, it should be used to initialize the |
// ProxyResolver. Simulate a successful parse. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript2), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
// At this point the ProxyService should have re-configured itself to use the |
// new PAC script. |
@@ -2761,10 +2780,11 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2783,8 +2803,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -2794,8 +2814,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) { |
// Now that the PAC script is downloaded, the request will have been sent to |
// the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -2817,6 +2837,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) { |
// special unit-test mode. |
fetcher->WaitUntilFetch(); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
ASSERT_TRUE(resolver.pending_requests().empty()); |
// Make sure that our background checker is trying to download the expected |
@@ -2828,7 +2849,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) { |
base::MessageLoop::current()->RunUntilIdle(); |
- ASSERT_FALSE(resolver.has_pending_set_pac_script_request()); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
+ ASSERT_TRUE(resolver.pending_requests().empty()); |
// At this point the ProxyService is still running the same PAC script as |
// before. |
@@ -2868,10 +2890,11 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -2890,8 +2913,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -2901,8 +2924,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) { |
// Now that the PAC script is downloaded, the request will have been sent to |
// the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -2924,6 +2947,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) { |
// special unit-test mode. |
fetcher->WaitUntilFetch(); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
ASSERT_TRUE(resolver.pending_requests().empty()); |
// Make sure that our background checker is trying to download the expected |
@@ -3021,10 +3045,11 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) { |
new MockProxyConfigService("http://foopy/proxy.pac"); |
MockAsyncProxyResolverExpectsBytes resolver; |
+ MockAsyncProxyResolverFactory factory(true); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; |
service.SetProxyScriptFetchers(fetcher, |
@@ -3043,8 +3068,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) { |
EXPECT_TRUE(fetcher->has_pending_request()); |
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); |
- // Nothing has been sent to the resolver yet. |
- EXPECT_TRUE(resolver.pending_requests().empty()); |
+ // Nothing has been sent to the factory yet. |
+ EXPECT_TRUE(factory.pending_requests().empty()); |
// At this point the ProxyService should be waiting for the |
// ProxyScriptFetcher to invoke its completion callback, notifying it of |
@@ -3054,8 +3079,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) { |
// Now that the PAC script is downloaded, the request will have been sent to |
// the proxy resolver. |
EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), |
- resolver.pending_set_pac_script_request()->script_data()->utf16()); |
- resolver.pending_set_pac_script_request()->CompleteNow(OK); |
+ factory.pending_requests()[0]->script_data()->utf16()); |
+ factory.pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver); |
ASSERT_EQ(1u, resolver.pending_requests().size()); |
EXPECT_EQ(GURL("http://request1"), resolver.pending_requests()[0]->url()); |
@@ -3073,6 +3098,7 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) { |
// (i.e. another call to ResolveProxy()). |
ASSERT_FALSE(fetcher->has_pending_request()); |
+ ASSERT_TRUE(factory.pending_requests().empty()); |
ASSERT_TRUE(resolver.pending_requests().empty()); |
// Start a second request. |
@@ -3121,11 +3147,11 @@ TEST_F(ProxyServiceTest, SynchronousWithPAC) { |
MockProxyConfigService* config_service = |
new MockProxyConfigService("http://foopy/proxy.pac"); |
- MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
config_service, |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -3137,9 +3163,6 @@ TEST_F(ProxyServiceTest, SynchronousWithPAC) { |
url, net::LOAD_NORMAL, &info, NULL, log.bound()); |
EXPECT_FALSE(synchronous_success); |
- // No request should have been queued. |
- EXPECT_EQ(0u, resolver.pending_requests().size()); |
- |
// |info| should not have been modified. |
EXPECT_TRUE(info.is_direct()); |
} |
@@ -3151,11 +3174,11 @@ TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) { |
config.proxy_rules().ParseFromString("foopy1:8080"); |
config.set_auto_detect(false); |
- MockAsyncProxyResolver resolver; |
+ MockAsyncProxyResolverFactory factory(false); |
ProxyService service( |
new MockProxyConfigService(config), |
- make_scoped_ptr(new ForwardingProxyResolverFactory(&resolver)), NULL); |
+ make_scoped_ptr(new ForwardingProxyResolverFactory(&factory)), NULL); |
GURL url("http://www.google.com/"); |
@@ -3169,7 +3192,7 @@ TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) { |
EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); |
// No request should have been queued. |
- EXPECT_EQ(0u, resolver.pending_requests().size()); |
+ EXPECT_EQ(0u, factory.pending_requests().size()); |
} |
} // namespace net |