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

Unified Diff: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc

Issue 2845643003: Allow ProxyService to share URLRequestContext with everything else. (Closed)
Patch Set: Fix fetcher shutdown with no active request, add test, add comment 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
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win.cc ('k') | net/proxy/mock_proxy_script_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index 3c5c4f0584f4fce3c20ec7b36d5982d8689809c1..03ed2c9d118d24ea57037006b4b0c097175f2130 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -392,6 +392,15 @@ class FetcherClient {
ASSERT_THAT(result, IsError(ERR_IO_PENDING));
}
+ int RunTestThatMayFailSync() {
+ int result = fetcher_.Fetch(
+ &pac_text_,
+ base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)));
+ if (result != ERR_IO_PENDING)
+ result_ = result;
+ return result;
+ }
+
void RunMessageLoopUntilComplete() {
while (!finished_) {
base::RunLoop().RunUntilIdle();
@@ -650,6 +659,24 @@ TEST(DhcpProxyScriptFetcherWin, ReuseFetcher) {
(*test_functions.begin())(&client);
}
+TEST(DhcpProxyScriptFetcherWin, OnShutdown) {
+ FetcherClient client;
+ TestURLRequestContext context;
+ std::unique_ptr<DummyDhcpProxyScriptAdapterFetcher> adapter_fetcher(
+ new DummyDhcpProxyScriptAdapterFetcher(&context, client.GetTaskRunner()));
+ adapter_fetcher->Configure(true, OK, L"bingo", 1);
+ client.fetcher_.PushBackAdapter("a", adapter_fetcher.release());
+ client.RunTest();
+
+ client.fetcher_.OnShutdown();
+ EXPECT_TRUE(client.finished_);
+ EXPECT_THAT(client.result_, IsError(ERR_CONTEXT_SHUT_DOWN));
+
+ client.ResetTestState();
+ EXPECT_THAT(client.RunTestThatMayFailSync(), IsError(ERR_CONTEXT_SHUT_DOWN));
+ EXPECT_EQ(0u, context.url_requests().size());
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win.cc ('k') | net/proxy/mock_proxy_script_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698