| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
| 11 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 11 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
| 12 #include "chrome/browser/prefs/pref_service_syncable.h" | 12 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 14 #include "chrome/browser/prefs/proxy_prefs.h" | 14 #include "chrome/browser/prefs/proxy_prefs.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/policy/core/common/external_data_fetcher.h" | 17 #include "components/policy/core/common/external_data_fetcher.h" |
| 18 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 18 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 19 #include "components/policy/core/common/policy_map.h" | 19 #include "components/policy/core/common/policy_map.h" |
| 20 #include "components/policy/core/common/policy_service_impl.h" | 20 #include "components/policy/core/common/policy_service_impl.h" |
| 21 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "policy/policy_constants.h" | 23 #include "policy/policy_constants.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 using ::testing::Return; | 26 using ::testing::Return; |
| 26 using ::testing::_; | 27 using ::testing::_; |
| 27 | 28 |
| 28 namespace policy { | 29 namespace policy { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (with_managed_policies) | 102 if (with_managed_policies) |
| 102 factory.SetManagedPolicies(policy_service_.get()); | 103 factory.SetManagedPolicies(policy_service_.get()); |
| 103 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 104 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 104 new user_prefs::PrefRegistrySyncable); | 105 new user_prefs::PrefRegistrySyncable); |
| 105 scoped_ptr<PrefServiceSyncable> prefs = | 106 scoped_ptr<PrefServiceSyncable> prefs = |
| 106 factory.CreateSyncable(registry.get()); | 107 factory.CreateSyncable(registry.get()); |
| 107 chrome::RegisterUserProfilePrefs(registry.get()); | 108 chrome::RegisterUserProfilePrefs(registry.get()); |
| 108 return prefs.Pass(); | 109 return prefs.Pass(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 base::MessageLoop loop_; | 112 content::TestBrowserThreadBundle thread_bundle_; |
| 112 base::CommandLine command_line_; | 113 base::CommandLine command_line_; |
| 113 MockConfigurationPolicyProvider provider_; | 114 MockConfigurationPolicyProvider provider_; |
| 114 scoped_ptr<PolicyServiceImpl> policy_service_; | 115 scoped_ptr<PolicyServiceImpl> policy_service_; |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) { | 118 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) { |
| 118 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); | 119 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); |
| 119 command_line_.AppendSwitchASCII(switches::kProxyServer, "789"); | 120 command_line_.AppendSwitchASCII(switches::kProxyServer, "789"); |
| 120 base::Value* mode_name = | 121 base::Value* mode_name = |
| 121 new base::StringValue(ProxyPrefs::kFixedServersProxyModeName); | 122 new base::StringValue(ProxyPrefs::kFixedServersProxyModeName); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 223 |
| 223 // Try a second time time with the managed PrefStore in place, the | 224 // Try a second time time with the managed PrefStore in place, the |
| 224 // auto-detect should be overridden. The default pref store must be | 225 // auto-detect should be overridden. The default pref store must be |
| 225 // in place with the appropriate default value for this to work. | 226 // in place with the appropriate default value for this to work. |
| 226 prefs = CreatePrefService(true); | 227 prefs = CreatePrefService(true); |
| 227 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); | 228 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); |
| 228 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); | 229 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace policy | 232 } // namespace policy |
| OLD | NEW |