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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool allow_deleting_browser_history = true; | 105 bool allow_deleting_browser_history = true; |
106 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( | 106 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( |
107 prefs::kAllowDeletingBrowserHistory, &allow_deleting_browser_history)); | 107 prefs::kAllowDeletingBrowserHistory, &allow_deleting_browser_history)); |
108 EXPECT_FALSE(allow_deleting_browser_history); | 108 EXPECT_FALSE(allow_deleting_browser_history); |
109 | 109 |
110 // kSupervisedModeManualHosts does not have a hardcoded value. | 110 // kSupervisedModeManualHosts does not have a hardcoded value. |
111 base::DictionaryValue* manual_hosts = NULL; | 111 base::DictionaryValue* manual_hosts = NULL; |
112 EXPECT_FALSE(fixture.changed_prefs()->GetDictionary( | 112 EXPECT_FALSE(fixture.changed_prefs()->GetDictionary( |
113 prefs::kSupervisedUserManualHosts, &manual_hosts)); | 113 prefs::kSupervisedUserManualHosts, &manual_hosts)); |
114 | 114 |
115 // kForceSafeSearch defaults to true for supervised users. | 115 // kForceGoogleSafeSearch and kForceYouTubeSafetyMode default to true for |
116 bool force_safesearch = false; | 116 // supervised users. |
117 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch, | 117 bool force_google_safesearch = false; |
118 &force_safesearch)); | 118 bool force_youtube_safety_mode = false; |
119 EXPECT_TRUE(force_safesearch); | 119 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceGoogleSafeSearch, |
| 120 &force_google_safesearch)); |
| 121 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( |
| 122 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); |
| 123 EXPECT_TRUE(force_google_safesearch); |
| 124 EXPECT_TRUE(force_youtube_safety_mode); |
120 | 125 |
121 // Activating the service again should not change anything. | 126 // Activating the service again should not change anything. |
122 fixture.changed_prefs()->Clear(); | 127 fixture.changed_prefs()->Clear(); |
123 service_.SetActive(true); | 128 service_.SetActive(true); |
124 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 129 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
125 | 130 |
126 // kSupervisedModeManualHosts can be configured by the custodian. | 131 // kSupervisedModeManualHosts can be configured by the custodian. |
127 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 132 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
128 dict->SetBoolean("example.com", true); | 133 dict->SetBoolean("example.com", true); |
129 dict->SetBoolean("moose.org", false); | 134 dict->SetBoolean("moose.org", false); |
130 service_.SetLocalSetting( | 135 service_.SetLocalSetting( |
131 supervised_users::kContentPackManualBehaviorHosts, | 136 supervised_users::kContentPackManualBehaviorHosts, |
132 scoped_ptr<base::Value>(dict->DeepCopy())); | 137 scoped_ptr<base::Value>(dict->DeepCopy())); |
133 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 138 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
134 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( | 139 ASSERT_TRUE(fixture.changed_prefs()->GetDictionary( |
135 prefs::kSupervisedUserManualHosts, &manual_hosts)); | 140 prefs::kSupervisedUserManualHosts, &manual_hosts)); |
136 EXPECT_TRUE(manual_hosts->Equals(dict.get())); | 141 EXPECT_TRUE(manual_hosts->Equals(dict.get())); |
137 | 142 |
138 // kForceSafeSearch can be configured by the custodian, overriding the | 143 // kForceGoogleSafeSearch and kForceYouTubeSafetyMode can be configured by the |
139 // hardcoded default. | 144 // custodian, overriding the hardcoded default. |
140 fixture.changed_prefs()->Clear(); | 145 fixture.changed_prefs()->Clear(); |
141 service_.SetLocalSetting( | 146 service_.SetLocalSetting( |
142 supervised_users::kForceSafeSearch, | 147 supervised_users::kForceSafeSearch, |
143 scoped_ptr<base::Value>(new base::FundamentalValue(false))); | 148 scoped_ptr<base::Value>(new base::FundamentalValue(false))); |
144 EXPECT_EQ(1u, fixture.changed_prefs()->size()); | 149 EXPECT_EQ(1u, fixture.changed_prefs()->size()); |
145 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch, | 150 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceGoogleSafeSearch, |
146 &force_safesearch)); | 151 &force_google_safesearch)); |
147 EXPECT_FALSE(force_safesearch); | 152 EXPECT_TRUE(fixture.changed_prefs()->GetBoolean( |
| 153 prefs::kForceYouTubeSafetyMode, &force_youtube_safety_mode)); |
| 154 EXPECT_FALSE(force_youtube_safety_mode); |
| 155 EXPECT_FALSE(force_google_safesearch); |
148 } | 156 } |
149 | 157 |
150 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { | 158 TEST_F(SupervisedUserPrefStoreTest, ActivateSettingsBeforeInitialization) { |
151 SupervisedUserPrefStoreFixture fixture(&service_); | 159 SupervisedUserPrefStoreFixture fixture(&service_); |
152 EXPECT_FALSE(fixture.initialization_completed()); | 160 EXPECT_FALSE(fixture.initialization_completed()); |
153 | 161 |
154 service_.SetActive(true); | 162 service_.SetActive(true); |
155 EXPECT_FALSE(fixture.initialization_completed()); | 163 EXPECT_FALSE(fixture.initialization_completed()); |
156 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 164 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
157 | 165 |
158 pref_store_->SetInitializationCompleted(); | 166 pref_store_->SetInitializationCompleted(); |
159 EXPECT_TRUE(fixture.initialization_completed()); | 167 EXPECT_TRUE(fixture.initialization_completed()); |
160 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 168 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
161 } | 169 } |
162 | 170 |
163 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { | 171 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { |
164 pref_store_->SetInitializationCompleted(); | 172 pref_store_->SetInitializationCompleted(); |
165 service_.SetActive(true); | 173 service_.SetActive(true); |
166 | 174 |
167 SupervisedUserPrefStoreFixture fixture(&service_); | 175 SupervisedUserPrefStoreFixture fixture(&service_); |
168 EXPECT_TRUE(fixture.initialization_completed()); | 176 EXPECT_TRUE(fixture.initialization_completed()); |
169 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 177 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
170 } | 178 } |
171 | 179 |
OLD | NEW |