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

Unified Diff: net/proxy/proxy_service_unittest.cc

Issue 2845643003: Allow ProxyService to share URLRequestContext with everything else. (Closed)
Patch Set: Fix test Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: net/proxy/proxy_service_unittest.cc
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index c57b23834f90683b68f594eb962f5dd284b2adfd..bffd00033dc8520aee49c1d56c87eab2e5bbbe87 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -3685,4 +3685,65 @@ TEST_F(ProxyServiceTest, SanitizeUrlForPacScriptCryptographic) {
}
}
+TEST_F(ProxyServiceTest, OnShutdownWithLiveRequest) {
mmenke 2017/05/01 16:52:14 The tests don't test all paths - this one depends
+ MockProxyConfigService* config_service =
+ new MockProxyConfigService("http://foopy/proxy.pac");
+
+ MockAsyncProxyResolver resolver;
+ MockAsyncProxyResolverFactory* factory =
+ new MockAsyncProxyResolverFactory(true);
+
+ ProxyService service(base::WrapUnique(config_service),
+ base::WrapUnique(factory), nullptr);
+
+ MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
+ service.SetProxyScriptFetchers(
+ fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
+
+ ProxyInfo info;
+ TestCompletionCallback callback;
+ ProxyService::PacRequest* request;
+ int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info,
+ callback.callback(), &request, nullptr,
+ NetLogWithSource());
+ EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
+
+ // The first request should have triggered download of PAC script.
+ EXPECT_TRUE(fetcher->has_pending_request());
+ EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
+
+ service.OnShutdown();
+ EXPECT_THAT(callback.WaitForResult(), IsOk());
+ EXPECT_FALSE(fetcher->has_pending_request());
+ EXPECT_TRUE(info.is_direct());
+}
+
+TEST_F(ProxyServiceTest, OnShutdownFollowedByRequest) {
+ MockProxyConfigService* config_service =
+ new MockProxyConfigService("http://foopy/proxy.pac");
+
+ MockAsyncProxyResolver resolver;
+ MockAsyncProxyResolverFactory* factory =
+ new MockAsyncProxyResolverFactory(true);
+
+ ProxyService service(base::WrapUnique(config_service),
+ base::WrapUnique(factory), nullptr);
+
+ MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
+ service.SetProxyScriptFetchers(
+ fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
+
+ service.OnShutdown();
+
+ ProxyInfo info;
+ TestCompletionCallback callback;
+ ProxyService::PacRequest* request;
+ int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info,
+ callback.callback(), &request, nullptr,
+ NetLogWithSource());
+ EXPECT_THAT(rv, IsOk());
+ EXPECT_FALSE(fetcher->has_pending_request());
+ EXPECT_TRUE(info.is_direct());
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698