| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "net/proxy/proxy_config.h" | 12 #include "net/proxy/proxy_config.h" |
| 13 #include "net/proxy/proxy_config_service_android.h" | 13 #include "net/proxy/proxy_config_service_android.h" |
| 14 #include "net/proxy/proxy_info.h" | 14 #include "net/proxy/proxy_info.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class TestObserver : public ProxyConfigService::Observer { | 21 class TestObserver : public ProxyConfigService::Observer { |
| 22 public: | 22 public: |
| 23 TestObserver() : availability_(ProxyConfigService::CONFIG_UNSET) {} | 23 TestObserver() : availability_(ProxyConfigService::CONFIG_UNSET) {} |
| 24 | 24 |
| 25 // ProxyConfigService::Observer: | 25 // ProxyConfigService::Observer: |
| 26 virtual void OnProxyConfigChanged( | 26 virtual void OnProxyConfigChanged( |
| 27 const ProxyConfig& config, | 27 const ProxyConfig& config, |
| 28 ProxyConfigService::ConfigAvailability availability) OVERRIDE { | 28 ProxyConfigService::ConfigAvailability availability) override { |
| 29 config_ = config; | 29 config_ = config; |
| 30 availability_ = availability; | 30 availability_ = availability; |
| 31 } | 31 } |
| 32 | 32 |
| 33 ProxyConfigService::ConfigAvailability availability() const { | 33 ProxyConfigService::ConfigAvailability availability() const { |
| 34 return availability_; | 34 return availability_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 const ProxyConfig& config() const { | 37 const ProxyConfig& config() const { |
| 38 return config_; | 38 return config_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 : configuration_(initial_configuration), | 55 : configuration_(initial_configuration), |
| 56 message_loop_(base::MessageLoop::current()), | 56 message_loop_(base::MessageLoop::current()), |
| 57 service_(message_loop_->message_loop_proxy(), | 57 service_(message_loop_->message_loop_proxy(), |
| 58 message_loop_->message_loop_proxy(), | 58 message_loop_->message_loop_proxy(), |
| 59 base::Bind(&ProxyConfigServiceAndroidTestBase::GetProperty, | 59 base::Bind(&ProxyConfigServiceAndroidTestBase::GetProperty, |
| 60 base::Unretained(this))) {} | 60 base::Unretained(this))) {} |
| 61 | 61 |
| 62 virtual ~ProxyConfigServiceAndroidTestBase() {} | 62 virtual ~ProxyConfigServiceAndroidTestBase() {} |
| 63 | 63 |
| 64 // testing::Test: | 64 // testing::Test: |
| 65 virtual void SetUp() OVERRIDE { | 65 virtual void SetUp() override { |
| 66 message_loop_->RunUntilIdle(); | 66 message_loop_->RunUntilIdle(); |
| 67 service_.AddObserver(&observer_); | 67 service_.AddObserver(&observer_); |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void TearDown() OVERRIDE { | 70 virtual void TearDown() override { |
| 71 service_.RemoveObserver(&observer_); | 71 service_.RemoveObserver(&observer_); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ClearConfiguration() { | 74 void ClearConfiguration() { |
| 75 configuration_.clear(); | 75 configuration_.clear(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void AddProperty(const std::string& key, const std::string& value) { | 78 void AddProperty(const std::string& key, const std::string& value) { |
| 79 configuration_[key] = value; | 79 configuration_[key] = value; |
| 80 } | 80 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 TEST_F(ProxyConfigServiceAndroidTest, HttpProxySupercedesSocks) { | 343 TEST_F(ProxyConfigServiceAndroidTest, HttpProxySupercedesSocks) { |
| 344 // SOCKS proxy is ignored if default HTTP proxy defined. | 344 // SOCKS proxy is ignored if default HTTP proxy defined. |
| 345 AddProperty("proxyHost", "defaultproxy.com"); | 345 AddProperty("proxyHost", "defaultproxy.com"); |
| 346 AddProperty("socksProxyHost", "socksproxy.com"); | 346 AddProperty("socksProxyHost", "socksproxy.com"); |
| 347 AddProperty("socksProxyPort", "9000"); | 347 AddProperty("socksProxyPort", "9000"); |
| 348 ProxySettingsChanged(); | 348 ProxySettingsChanged(); |
| 349 TestMapping("http://example.com/", "PROXY defaultproxy.com:80"); | 349 TestMapping("http://example.com/", "PROXY defaultproxy.com:80"); |
| 350 } | 350 } |
| 351 | 351 |
| 352 } // namespace net | 352 } // namespace net |
| OLD | NEW |