| 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 "chromeos/dbus/services/proxy_resolution_service_provider.h" | 5 #include "chromeos/dbus/services/proxy_resolution_service_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/test/thread_test_helper.h" | 14 #include "base/test/thread_test_helper.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "chromeos/dbus/services/service_provider_test_helper.h" | 18 #include "chromeos/dbus/services/service_provider_test_helper.h" |
| 19 #include "dbus/message.h" | 19 #include "dbus/message.h" |
| 20 #include "dbus/object_path.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/proxy/mock_proxy_resolver.h" | 22 #include "net/proxy/mock_proxy_resolver.h" |
| 22 #include "net/proxy/proxy_config_service_fixed.h" | 23 #include "net/proxy/proxy_config_service_fixed.h" |
| 23 #include "net/proxy/proxy_info.h" | 24 #include "net/proxy/proxy_info.h" |
| 24 #include "net/proxy/proxy_resolver.h" | 25 #include "net/proxy/proxy_resolver.h" |
| 25 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 26 #include "net/url_request/url_request_test_util.h" | 27 #include "net/url_request/url_request_test_util.h" |
| 27 #include "third_party/cros_system_api/dbus/service_constants.h" | 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 28 | 29 |
| 29 namespace chromeos { | 30 namespace chromeos { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 class ProxyResolutionServiceProviderTest : public testing::Test { | 191 class ProxyResolutionServiceProviderTest : public testing::Test { |
| 191 public: | 192 public: |
| 192 ProxyResolutionServiceProviderTest() : network_thread_("NetworkThread") { | 193 ProxyResolutionServiceProviderTest() : network_thread_("NetworkThread") { |
| 193 CHECK(network_thread_.Start()); | 194 CHECK(network_thread_.Start()); |
| 194 | 195 |
| 195 proxy_resolver_ = | 196 proxy_resolver_ = |
| 196 base::MakeUnique<TestProxyResolver>(network_thread_.task_runner()); | 197 base::MakeUnique<TestProxyResolver>(network_thread_.task_runner()); |
| 197 service_provider_ = base::MakeUnique<ProxyResolutionServiceProvider>( | 198 service_provider_ = base::MakeUnique<ProxyResolutionServiceProvider>( |
| 198 base::MakeUnique<TestDelegate>(network_thread_.task_runner(), | 199 base::MakeUnique<TestDelegate>(network_thread_.task_runner(), |
| 199 proxy_resolver_.get())); | 200 proxy_resolver_.get())); |
| 200 test_helper_.SetUp(kResolveNetworkProxy, service_provider_.get()); | 201 test_helper_.SetUp(kLibCrosServiceName, |
| 202 dbus::ObjectPath(kLibCrosServicePath), |
| 203 kLibCrosServiceInterface, kResolveNetworkProxy, |
| 204 service_provider_.get()); |
| 201 } | 205 } |
| 202 | 206 |
| 203 ~ProxyResolutionServiceProviderTest() override { | 207 ~ProxyResolutionServiceProviderTest() override { |
| 204 test_helper_.TearDown(); | 208 test_helper_.TearDown(); |
| 205 | 209 |
| 206 // URLRequestContextGetter posts a task to delete itself to its task runner, | 210 // URLRequestContextGetter posts a task to delete itself to its task runner, |
| 207 // so give it a chance to do that. | 211 // so give it a chance to do that. |
| 208 service_provider_.reset(); | 212 service_provider_.reset(); |
| 209 RunPendingTasks(network_thread_.task_runner()); | 213 RunPendingTasks(network_thread_.task_runner()); |
| 210 | 214 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 EXPECT_TRUE(reader.PopString(&error)); | 409 EXPECT_TRUE(reader.PopString(&error)); |
| 406 EXPECT_EQ("DIRECT", proxy_info); | 410 EXPECT_EQ("DIRECT", proxy_info); |
| 407 EXPECT_EQ(net::ErrorToString(net::ERR_MANDATORY_PROXY_CONFIGURATION_FAILED), | 411 EXPECT_EQ(net::ErrorToString(net::ERR_MANDATORY_PROXY_CONFIGURATION_FAILED), |
| 408 error); | 412 error); |
| 409 | 413 |
| 410 // No signal should've been emitted. | 414 // No signal should've been emitted. |
| 411 EXPECT_FALSE(signal); | 415 EXPECT_FALSE(signal); |
| 412 } | 416 } |
| 413 | 417 |
| 414 } // namespace chromeos | 418 } // namespace chromeos |
| OLD | NEW |