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