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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/ref_counted.h" |
6 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 7 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
7 #include "chrome/browser/policy/policy_map.h" | 8 #include "chrome/browser/policy/policy_map.h" |
8 #include "chrome/browser/policy/policy_service_impl.h" | 9 #include "chrome/browser/policy/policy_service_impl.h" |
9 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_registry_syncable.h" |
11 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 12 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 13 #include "chrome/browser/prefs/pref_service_syncable.h" |
12 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 14 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
13 #include "chrome/browser/prefs/proxy_prefs.h" | 15 #include "chrome/browser/prefs/proxy_prefs.h" |
14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
16 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 using ::testing::Return; | 21 using ::testing::Return; |
20 using ::testing::_; | 22 using ::testing::_; |
21 | 23 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 92 |
91 virtual void TearDown() OVERRIDE { | 93 virtual void TearDown() OVERRIDE { |
92 provider_.Shutdown(); | 94 provider_.Shutdown(); |
93 } | 95 } |
94 | 96 |
95 PrefService* CreatePrefService(bool with_managed_policies) { | 97 PrefService* CreatePrefService(bool with_managed_policies) { |
96 PrefServiceMockBuilder builder; | 98 PrefServiceMockBuilder builder; |
97 builder.WithCommandLine(&command_line_); | 99 builder.WithCommandLine(&command_line_); |
98 if (with_managed_policies) | 100 if (with_managed_policies) |
99 builder.WithManagedPolicies(policy_service_.get()); | 101 builder.WithManagedPolicies(policy_service_.get()); |
100 PrefServiceSyncable* prefs = builder.CreateSyncable(); | 102 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable); |
101 chrome::RegisterUserPrefs(prefs); | 103 PrefServiceSyncable* prefs = builder.CreateSyncable(registry); |
| 104 chrome::RegisterUserPrefs(prefs, registry); |
102 return prefs; | 105 return prefs; |
103 } | 106 } |
104 | 107 |
105 CommandLine command_line_; | 108 CommandLine command_line_; |
106 MockConfigurationPolicyProvider provider_; | 109 MockConfigurationPolicyProvider provider_; |
107 scoped_ptr<PolicyServiceImpl> policy_service_; | 110 scoped_ptr<PolicyServiceImpl> policy_service_; |
108 }; | 111 }; |
109 | 112 |
110 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) { | 113 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) { |
111 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); | 114 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 212 |
210 // Try a second time time with the managed PrefStore in place, the | 213 // Try a second time time with the managed PrefStore in place, the |
211 // auto-detect should be overridden. The default pref store must be | 214 // auto-detect should be overridden. The default pref store must be |
212 // in place with the appropriate default value for this to work. | 215 // in place with the appropriate default value for this to work. |
213 prefs.reset(CreatePrefService(true)); | 216 prefs.reset(CreatePrefService(true)); |
214 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); | 217 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); |
215 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); | 218 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); |
216 } | 219 } |
217 | 220 |
218 } // namespace policy | 221 } // namespace policy |
OLD | NEW |