| 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/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 10 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); | 123 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); |
| 124 EXPECT_TRUE(force_google_safesearch); | 124 EXPECT_TRUE(force_google_safesearch); |
| 125 EXPECT_TRUE(force_youtube_safety_mode); | 125 EXPECT_TRUE(force_youtube_safety_mode); |
| 126 | 126 |
| 127 // Activating the service again should not change anything. | 127 // Activating the service again should not change anything. |
| 128 fixture.changed_prefs()->Clear(); | 128 fixture.changed_prefs()->Clear(); |
| 129 service_.SetActive(true); | 129 service_.SetActive(true); |
| 130 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 130 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
| 131 | 131 |
| 132 // kSupervisedModeManualHosts can be configured by the custodian. | 132 // kSupervisedModeManualHosts can be configured by the custodian. |
| 133 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 133 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 134 dict->SetBoolean("example.com", true); | 134 dict->SetBoolean("example.com", true); |
| 135 dict->SetBoolean("moose.org", false); | 135 dict->SetBoolean("moose.org", false); |
| 136 service_.SetLocalSetting( | 136 service_.SetLocalSetting(supervised_users::kContentPackManualBehaviorHosts, |
| 137 supervised_users::kContentPackManualBehaviorHosts, | 137 std::unique_ptr<base::Value>(dict->DeepCopy())); |
| 138 scoped_ptr<base::Value>(dict->DeepCopy())); | |
| 139 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 138 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
| 140 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( | 139 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( |
| 141 prefs::kSupervisedUserManualHosts, &manual_hosts)); | 140 prefs::kSupervisedUserManualHosts, &manual_hosts)); |
| 142 EXPECT_TRUE(manual_hosts->Equals(dict.get())); | 141 EXPECT_TRUE(manual_hosts->Equals(dict.get())); |
| 143 | 142 |
| 144 // kForceGoogleSafeSearch and kForceYouTubeSafetyMode can be configured by the | 143 // kForceGoogleSafeSearch and kForceYouTubeSafetyMode can be configured by the |
| 145 // custodian, overriding the hardcoded default. | 144 // custodian, overriding the hardcoded default. |
| 146 fixture.changed_prefs()->Clear(); | 145 fixture.changed_prefs()->Clear(); |
| 147 service_.SetLocalSetting( | 146 service_.SetLocalSetting( |
| 148 supervised_users::kForceSafeSearch, | 147 supervised_users::kForceSafeSearch, |
| 149 scoped_ptr<base::Value>(new base::FundamentalValue(false))); | 148 std::unique_ptr<base::Value>(new base::FundamentalValue(false))); |
| 150 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 149 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
| 151 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceGoogleSafeSearch, | 150 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceGoogleSafeSearch, |
| 152 &force_google_safesearch)); | 151 &force_google_safesearch)); |
| 153 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( | 152 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( |
| 154 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); | 153 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); |
| 155 EXPECT_FALSE(force_youtube_safety_mode); | 154 EXPECT_FALSE(force_youtube_safety_mode); |
| 156 EXPECT_FALSE(force_google_safesearch); | 155 EXPECT_FALSE(force_google_safesearch); |
| 157 } | 156 } |
| 158 | 157 |
| 159 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { | 158 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 171 | 170 |
| 172 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { | 171 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { |
| 173 pref_store_->SetInitializationCompleted(); | 172 pref_store_->SetInitializationCompleted(); |
| 174 service_.SetActive(true); | 173 service_.SetActive(true); |
| 175 | 174 |
| 176 SupervisedUserPrefStoreFixture fixture(&service_); | 175 SupervisedUserPrefStoreFixture fixture(&service_); |
| 177 EXPECT_TRUE(fixture.initialization_completed()); | 176 EXPECT_TRUE(fixture.initialization_completed()); |
| 178 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 177 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
| 179 } | 178 } |
| 180 | 179 |
| OLD | NEW |