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/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
14 #include "net/proxy/mock_proxy_script_fetcher.h" | 14 #include "net/proxy/mock_proxy_script_fetcher.h" |
15 #include "net/proxy/proxy_script_fetcher_impl.h" | 15 #include "net/proxy/proxy_script_fetcher_impl.h" |
16 #include "net/test/spawned_test_server/spawned_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
17 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kPacUrl[] = "http://pacserver/script.pac"; | 24 const char kPacUrl[] = "http://pacserver/script.pac"; |
25 | 25 |
26 // In net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc there are a few | 26 // In net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc there are a few |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ProxyScriptFetcher* ImplCreateScriptFetcher() override { | 276 ProxyScriptFetcher* ImplCreateScriptFetcher() override { |
277 ProxyScriptFetcher* fetcher = | 277 ProxyScriptFetcher* fetcher = |
278 new ProxyScriptFetcherImpl(url_request_context_); | 278 new ProxyScriptFetcherImpl(url_request_context_); |
279 return fetcher; | 279 return fetcher; |
280 } | 280 } |
281 | 281 |
282 URLRequestContext* url_request_context_; | 282 URLRequestContext* url_request_context_; |
283 }; | 283 }; |
284 | 284 |
285 TEST(DhcpProxyScriptAdapterFetcher, MockDhcpRealFetch) { | 285 TEST(DhcpProxyScriptAdapterFetcher, MockDhcpRealFetch) { |
286 SpawnedTestServer test_server( | 286 EmbeddedTestServer test_server; |
287 SpawnedTestServer::TYPE_HTTP, | 287 test_server.ServeFilesFromSourceDirectory( |
288 SpawnedTestServer::kLocalhost, | 288 "net/data/proxy_script_fetcher_unittest"); |
289 base::FilePath( | |
290 FILE_PATH_LITERAL("net/data/proxy_script_fetcher_unittest"))); | |
291 ASSERT_TRUE(test_server.Start()); | 289 ASSERT_TRUE(test_server.Start()); |
292 | 290 |
293 GURL configured_url = test_server.GetURL("files/downloadable.pac"); | 291 GURL configured_url = test_server.GetURL("/downloadable.pac"); |
294 | 292 |
295 FetcherClient client; | 293 FetcherClient client; |
296 TestURLRequestContext url_request_context; | 294 TestURLRequestContext url_request_context; |
297 scoped_refptr<base::TaskRunner> runner = | 295 scoped_refptr<base::TaskRunner> runner = |
298 client.worker_pool_->GetTaskRunnerWithShutdownBehavior( | 296 client.worker_pool_->GetTaskRunnerWithShutdownBehavior( |
299 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 297 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
300 client.fetcher_.reset( | 298 client.fetcher_.reset( |
301 new MockDhcpRealFetchProxyScriptAdapterFetcher( | 299 new MockDhcpRealFetchProxyScriptAdapterFetcher( |
302 &url_request_context, runner)); | 300 &url_request_context, runner)); |
303 client.fetcher_->configured_url_ = configured_url.spec(); | 301 client.fetcher_->configured_url_ = configured_url.spec(); |
(...skipping 26 matching lines...) Expand all Loading... |
330 EXPECT_EQ(BASE_URL, | 328 EXPECT_EQ(BASE_URL, |
331 DhcpProxyScriptAdapterFetcher::SanitizeDhcpApiString( | 329 DhcpProxyScriptAdapterFetcher::SanitizeDhcpApiString( |
332 BASE_URL "\0foo\0blat", kBaseUrlLen + 9)); | 330 BASE_URL "\0foo\0blat", kBaseUrlLen + 9)); |
333 } | 331 } |
334 | 332 |
335 #undef BASE_URL | 333 #undef BASE_URL |
336 | 334 |
337 } // namespace | 335 } // namespace |
338 | 336 |
339 } // namespace net | 337 } // namespace net |
OLD | NEW |