OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "sync/api/sync_error_factory.h" | 21 #include "sync/api/sync_error_factory.h" |
22 #include "sync/api/sync_error_factory_mock.h" | 22 #include "sync/api/sync_error_factory_mock.h" |
23 #include "sync/api/syncable_service.h" | 23 #include "sync/api/syncable_service.h" |
24 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" | 24 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" |
25 #include "sync/protocol/sync.pb.h" | 25 #include "sync/protocol/sync.pb.h" |
26 | 26 |
27 #if defined(ENABLE_CONFIGURATION_POLICY) | 27 #if defined(ENABLE_CONFIGURATION_POLICY) |
28 #include "components/policy/core/browser/browser_policy_connector.h" | 28 #include "components/policy/core/browser/browser_policy_connector.h" |
29 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 29 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
30 #include "components/policy/core/common/policy_map.h" | 30 #include "components/policy/core/common/policy_map.h" |
| 31 #include "components/policy/core/common/policy_types.h" |
31 #include "policy/policy_constants.h" | 32 #include "policy/policy_constants.h" |
32 #endif | 33 #endif |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 using testing::Return; | 37 using testing::Return; |
37 using testing::_; | 38 using testing::_; |
38 | 39 |
39 class SyncedPrefChangeRegistrarTest : public InProcessBrowserTest { | 40 class SyncedPrefChangeRegistrarTest : public InProcessBrowserTest { |
40 public: | 41 public: |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 IN_PROC_BROWSER_TEST_F(SyncedPrefChangeRegistrarTest, | 184 IN_PROC_BROWSER_TEST_F(SyncedPrefChangeRegistrarTest, |
184 IgnoreLocalChangesToManagedPrefs) { | 185 IgnoreLocalChangesToManagedPrefs) { |
185 TestSyncedPrefObserver observer = {}; | 186 TestSyncedPrefObserver observer = {}; |
186 registrar()->Add(prefs::kShowHomeButton, | 187 registrar()->Add(prefs::kShowHomeButton, |
187 base::Bind(&TestPrefChangeCallback, prefs(), &observer)); | 188 base::Bind(&TestPrefChangeCallback, prefs(), &observer)); |
188 | 189 |
189 policy::PolicyMap policies; | 190 policy::PolicyMap policies; |
190 policies.Set(policy::key::kShowHomeButton, | 191 policies.Set(policy::key::kShowHomeButton, |
191 policy::POLICY_LEVEL_MANDATORY, | 192 policy::POLICY_LEVEL_MANDATORY, |
192 policy::POLICY_SCOPE_USER, | 193 policy::POLICY_SCOPE_USER, |
| 194 policy::POLICY_SOURCE_CLOUD, |
193 new base::FundamentalValue(true), | 195 new base::FundamentalValue(true), |
194 NULL); | 196 NULL); |
195 UpdateChromePolicy(policies); | 197 UpdateChromePolicy(policies); |
196 | 198 |
197 EXPECT_TRUE(prefs()->IsManagedPreference(prefs::kShowHomeButton)); | 199 EXPECT_TRUE(prefs()->IsManagedPreference(prefs::kShowHomeButton)); |
198 | 200 |
199 SetBooleanPrefValueFromLocal(prefs::kShowHomeButton, false); | 201 SetBooleanPrefValueFromLocal(prefs::kShowHomeButton, false); |
200 EXPECT_FALSE(observer.has_been_notified); | 202 EXPECT_FALSE(observer.has_been_notified); |
201 EXPECT_TRUE(GetBooleanPrefValue(prefs::kShowHomeButton)); | 203 EXPECT_TRUE(GetBooleanPrefValue(prefs::kShowHomeButton)); |
202 } | 204 } |
203 | 205 |
204 IN_PROC_BROWSER_TEST_F(SyncedPrefChangeRegistrarTest, | 206 IN_PROC_BROWSER_TEST_F(SyncedPrefChangeRegistrarTest, |
205 IgnoreSyncChangesToManagedPrefs) { | 207 IgnoreSyncChangesToManagedPrefs) { |
206 TestSyncedPrefObserver observer = {}; | 208 TestSyncedPrefObserver observer = {}; |
207 registrar()->Add(prefs::kShowHomeButton, | 209 registrar()->Add(prefs::kShowHomeButton, |
208 base::Bind(&TestPrefChangeCallback, prefs(), &observer)); | 210 base::Bind(&TestPrefChangeCallback, prefs(), &observer)); |
209 | 211 |
210 policy::PolicyMap policies; | 212 policy::PolicyMap policies; |
211 policies.Set(policy::key::kShowHomeButton, | 213 policies.Set(policy::key::kShowHomeButton, |
212 policy::POLICY_LEVEL_MANDATORY, | 214 policy::POLICY_LEVEL_MANDATORY, |
213 policy::POLICY_SCOPE_USER, | 215 policy::POLICY_SCOPE_USER, |
| 216 policy::POLICY_SOURCE_CLOUD, |
214 new base::FundamentalValue(true), | 217 new base::FundamentalValue(true), |
215 NULL); | 218 NULL); |
216 UpdateChromePolicy(policies); | 219 UpdateChromePolicy(policies); |
217 | 220 |
218 EXPECT_TRUE(prefs()->IsManagedPreference(prefs::kShowHomeButton)); | 221 EXPECT_TRUE(prefs()->IsManagedPreference(prefs::kShowHomeButton)); |
219 SetBooleanPrefValueFromSync(prefs::kShowHomeButton, false); | 222 SetBooleanPrefValueFromSync(prefs::kShowHomeButton, false); |
220 EXPECT_FALSE(observer.has_been_notified); | 223 EXPECT_FALSE(observer.has_been_notified); |
221 EXPECT_TRUE(GetBooleanPrefValue(prefs::kShowHomeButton)); | 224 EXPECT_TRUE(GetBooleanPrefValue(prefs::kShowHomeButton)); |
222 } | 225 } |
223 #endif | 226 #endif |
OLD | NEW |