| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/prefs/testing_pref_store.h" | 9 #include "base/prefs/testing_pref_store.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 // Activating the service again should not change anything. | 121 // Activating the service again should not change anything. |
| 122 fixture.changed_prefs()->Clear(); | 122 fixture.changed_prefs()->Clear(); |
| 123 service_.SetActive(true); | 123 service_.SetActive(true); |
| 124 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 124 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
| 125 | 125 |
| 126 // kSupervisedModeManualHosts can be configured by the custodian. | 126 // kSupervisedModeManualHosts can be configured by the custodian. |
| 127 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 127 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 128 dict->SetBoolean("example.com", true); | 128 dict->SetBoolean("example.com", true); |
| 129 dict->SetBoolean("moose.org", false); | 129 dict->SetBoolean("moose.org", false); |
| 130 service_.SetLocalSettingForTesting( | 130 service_.SetLocalSetting( |
| 131 supervised_users::kContentPackManualBehaviorHosts, | 131 supervised_users::kContentPackManualBehaviorHosts, |
| 132 scoped_ptr<base::Value>(dict->DeepCopy())); | 132 scoped_ptr<base::Value>(dict->DeepCopy())); |
| 133 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 133 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
| 134 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( | 134 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( |
| 135 prefs::kSupervisedUserManualHosts, &manual_hosts)); | 135 prefs::kSupervisedUserManualHosts, &manual_hosts)); |
| 136 EXPECT_TRUE(manual_hosts->Equals(dict.get())); | 136 EXPECT_TRUE(manual_hosts->Equals(dict.get())); |
| 137 | 137 |
| 138 // kForceSafeSearch can be configured by the custodian, overriding the | 138 // kForceSafeSearch can be configured by the custodian, overriding the |
| 139 // hardcoded default. | 139 // hardcoded default. |
| 140 fixture.changed_prefs()->Clear(); | 140 fixture.changed_prefs()->Clear(); |
| 141 service_.SetLocalSettingForTesting( | 141 service_.SetLocalSetting( |
| 142 supervised_users::kForceSafeSearch, | 142 supervised_users::kForceSafeSearch, |
| 143 scoped_ptr<base::Value>(new base::FundamentalValue(false))); | 143 scoped_ptr<base::Value>(new base::FundamentalValue(false))); |
| 144 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 144 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
| 145 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch, | 145 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch, |
| 146 &force_safesearch)); | 146 &force_safesearch)); |
| 147 EXPECT_FALSE(force_safesearch); | 147 EXPECT_FALSE(force_safesearch); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { | 150 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { |
| 151 SupervisedUserPrefStoreFixture fixture(&service_); | 151 SupervisedUserPrefStoreFixture fixture(&service_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 162 | 162 |
| 163 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { | 163 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { |
| 164 pref_store_->SetInitializationCompleted(); | 164 pref_store_->SetInitializationCompleted(); |
| 165 service_.SetActive(true); | 165 service_.SetActive(true); |
| 166 | 166 |
| 167 SupervisedUserPrefStoreFixture fixture(&service_); | 167 SupervisedUserPrefStoreFixture fixture(&service_); |
| 168 EXPECT_TRUE(fixture.initialization_completed()); | 168 EXPECT_TRUE(fixture.initialization_completed()); |
| 169 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 169 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
| 170 } | 170 } |
| 171 | 171 |
| OLD | NEW |