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/dhcp_proxy_script_adapter_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" |
6 | 6 |
7 #include "base/perftimer.h" | 7 #include "base/perftimer.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void RunTest() { | 143 void RunTest() { |
144 fetcher_->Fetch("adapter name", callback_.callback()); | 144 fetcher_->Fetch("adapter name", callback_.callback()); |
145 } | 145 } |
146 | 146 |
147 void FinishTestAllowCleanup() { | 147 void FinishTestAllowCleanup() { |
148 fetcher_->FinishTest(); | 148 fetcher_->FinishTest(); |
149 MessageLoop::current()->RunAllPending(); | 149 MessageLoop::current()->RunAllPending(); |
150 } | 150 } |
151 | 151 |
152 TestCompletionCallback callback_; | 152 TestCompletionCallback callback_; |
153 scoped_refptr<URLRequestContext> url_request_context_; | 153 scoped_ptr<URLRequestContext> url_request_context_; |
154 scoped_ptr<MockDhcpProxyScriptAdapterFetcher> fetcher_; | 154 scoped_ptr<MockDhcpProxyScriptAdapterFetcher> fetcher_; |
155 string16 pac_text_; | 155 string16 pac_text_; |
156 }; | 156 }; |
157 | 157 |
158 TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLNotInDhcp) { | 158 TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLNotInDhcp) { |
159 FetcherClient client; | 159 FetcherClient client; |
160 client.fetcher_->configured_url_ = ""; | 160 client.fetcher_->configured_url_ = ""; |
161 client.RunTest(); | 161 client.RunTest(); |
162 client.WaitForResult(ERR_PAC_NOT_IN_DHCP); | 162 client.WaitForResult(ERR_PAC_NOT_IN_DHCP); |
163 ASSERT_TRUE(client.fetcher_->DidFinish()); | 163 ASSERT_TRUE(client.fetcher_->DidFinish()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 TEST(DhcpProxyScriptAdapterFetcher, MockDhcpRealFetch) { | 271 TEST(DhcpProxyScriptAdapterFetcher, MockDhcpRealFetch) { |
272 TestServer test_server( | 272 TestServer test_server( |
273 TestServer::TYPE_HTTP, | 273 TestServer::TYPE_HTTP, |
274 net::TestServer::kLocalhost, | 274 net::TestServer::kLocalhost, |
275 FilePath(FILE_PATH_LITERAL("net/data/proxy_script_fetcher_unittest"))); | 275 FilePath(FILE_PATH_LITERAL("net/data/proxy_script_fetcher_unittest"))); |
276 ASSERT_TRUE(test_server.Start()); | 276 ASSERT_TRUE(test_server.Start()); |
277 | 277 |
278 GURL configured_url = test_server.GetURL("files/downloadable.pac"); | 278 GURL configured_url = test_server.GetURL("files/downloadable.pac"); |
279 | 279 |
280 FetcherClient client; | 280 FetcherClient client; |
281 scoped_refptr<URLRequestContext> url_request_context( | 281 TestURLRequestContext url_request_context; |
282 new TestURLRequestContext()); | |
283 client.fetcher_.reset( | 282 client.fetcher_.reset( |
284 new MockDhcpRealFetchProxyScriptAdapterFetcher( | 283 new MockDhcpRealFetchProxyScriptAdapterFetcher( |
285 url_request_context.get())); | 284 &url_request_context)); |
286 client.fetcher_->configured_url_ = configured_url.spec(); | 285 client.fetcher_->configured_url_ = configured_url.spec(); |
287 client.RunTest(); | 286 client.RunTest(); |
288 client.WaitForResult(OK); | 287 client.WaitForResult(OK); |
289 ASSERT_TRUE(client.fetcher_->DidFinish()); | 288 ASSERT_TRUE(client.fetcher_->DidFinish()); |
290 EXPECT_EQ(OK, client.fetcher_->GetResult()); | 289 EXPECT_EQ(OK, client.fetcher_->GetResult()); |
291 EXPECT_EQ(string16(L"-downloadable.pac-\n"), client.fetcher_->GetPacScript()); | 290 EXPECT_EQ(string16(L"-downloadable.pac-\n"), client.fetcher_->GetPacScript()); |
292 EXPECT_EQ(configured_url, | 291 EXPECT_EQ(configured_url, |
293 client.fetcher_->GetPacURL()); | 292 client.fetcher_->GetPacURL()); |
294 } | 293 } |
295 | 294 |
296 } // namespace | 295 } // namespace |
297 | 296 |
298 } // namespace net | 297 } // namespace net |
OLD | NEW |