Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / base / prefs / pref_value_store_unittest.cc
blobcb047ba226983cff16c5dc8782a3a4bce5673468
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <string>
7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_notifier.h"
11 #include "base/prefs/pref_value_store.h"
12 #include "base/prefs/testing_pref_store.h"
13 #include "base/values.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 using testing::Mock;
18 using testing::_;
20 namespace {
22 // Allows to capture pref notifications through gmock.
23 class MockPrefNotifier : public PrefNotifier {
24 public:
25 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
26 MOCK_METHOD1(OnInitializationCompleted, void(bool));
29 // Allows to capture sync model associator interaction.
30 class MockPrefModelAssociator {
31 public:
32 MOCK_METHOD1(ProcessPrefChange, void(const std::string&));
35 } // namespace
37 // Names of the preferences used in this test.
38 namespace prefs {
39 const char kManagedPref[] = "this.pref.managed";
40 const char kCommandLinePref[] = "this.pref.command_line";
41 const char kExtensionPref[] = "this.pref.extension";
42 const char kUserPref[] = "this.pref.user";
43 const char kRecommendedPref[] = "this.pref.recommended";
44 const char kDefaultPref[] = "this.pref.default";
45 const char kMissingPref[] = "this.pref.does_not_exist";
48 // Potentially expected values of all preferences used in this test program.
49 namespace managed_pref {
50 const char kManagedValue[] = "managed:managed";
53 namespace extension_pref {
54 const char kManagedValue[] = "extension:managed";
55 const char kExtensionValue[] = "extension:extension";
58 namespace command_line_pref {
59 const char kManagedValue[] = "command_line:managed";
60 const char kExtensionValue[] = "command_line:extension";
61 const char kCommandLineValue[] = "command_line:command_line";
64 namespace user_pref {
65 const char kManagedValue[] = "user:managed";
66 const char kExtensionValue[] = "user:extension";
67 const char kCommandLineValue[] = "user:command_line";
68 const char kUserValue[] = "user:user";
71 namespace recommended_pref {
72 const char kManagedValue[] = "recommended:managed";
73 const char kExtensionValue[] = "recommended:extension";
74 const char kCommandLineValue[] = "recommended:command_line";
75 const char kUserValue[] = "recommended:user";
76 const char kRecommendedValue[] = "recommended:recommended";
79 namespace default_pref {
80 const char kManagedValue[] = "default:managed";
81 const char kExtensionValue[] = "default:extension";
82 const char kCommandLineValue[] = "default:command_line";
83 const char kUserValue[] = "default:user";
84 const char kRecommendedValue[] = "default:recommended";
85 const char kDefaultValue[] = "default:default";
88 class PrefValueStoreTest : public testing::Test {
89 protected:
90 virtual void SetUp() {
91 // Create TestingPrefStores.
92 CreateManagedPrefs();
93 CreateExtensionPrefs();
94 CreateCommandLinePrefs();
95 CreateUserPrefs();
96 CreateRecommendedPrefs();
97 CreateDefaultPrefs();
98 sync_associator_.reset(new MockPrefModelAssociator());
100 // Create a fresh PrefValueStore.
101 pref_value_store_.reset(new PrefValueStore(
102 managed_pref_store_,
103 extension_pref_store_,
104 command_line_pref_store_,
105 user_pref_store_,
106 recommended_pref_store_,
107 default_pref_store_,
108 &pref_notifier_));
110 pref_value_store_->set_callback(
111 base::Bind(&MockPrefModelAssociator::ProcessPrefChange,
112 base::Unretained(sync_associator_.get())));
115 void CreateManagedPrefs() {
116 managed_pref_store_ = new TestingPrefStore;
117 managed_pref_store_->SetString(
118 prefs::kManagedPref,
119 managed_pref::kManagedValue);
122 void CreateExtensionPrefs() {
123 extension_pref_store_ = new TestingPrefStore;
124 extension_pref_store_->SetString(
125 prefs::kManagedPref,
126 extension_pref::kManagedValue);
127 extension_pref_store_->SetString(
128 prefs::kExtensionPref,
129 extension_pref::kExtensionValue);
132 void CreateCommandLinePrefs() {
133 command_line_pref_store_ = new TestingPrefStore;
134 command_line_pref_store_->SetString(
135 prefs::kManagedPref,
136 command_line_pref::kManagedValue);
137 command_line_pref_store_->SetString(
138 prefs::kExtensionPref,
139 command_line_pref::kExtensionValue);
140 command_line_pref_store_->SetString(
141 prefs::kCommandLinePref,
142 command_line_pref::kCommandLineValue);
145 void CreateUserPrefs() {
146 user_pref_store_ = new TestingPrefStore;
147 user_pref_store_->SetString(
148 prefs::kManagedPref,
149 user_pref::kManagedValue);
150 user_pref_store_->SetString(
151 prefs::kCommandLinePref,
152 user_pref::kCommandLineValue);
153 user_pref_store_->SetString(
154 prefs::kExtensionPref,
155 user_pref::kExtensionValue);
156 user_pref_store_->SetString(
157 prefs::kUserPref,
158 user_pref::kUserValue);
161 void CreateRecommendedPrefs() {
162 recommended_pref_store_ = new TestingPrefStore;
163 recommended_pref_store_->SetString(
164 prefs::kManagedPref,
165 recommended_pref::kManagedValue);
166 recommended_pref_store_->SetString(
167 prefs::kCommandLinePref,
168 recommended_pref::kCommandLineValue);
169 recommended_pref_store_->SetString(
170 prefs::kExtensionPref,
171 recommended_pref::kExtensionValue);
172 recommended_pref_store_->SetString(
173 prefs::kUserPref,
174 recommended_pref::kUserValue);
175 recommended_pref_store_->SetString(
176 prefs::kRecommendedPref,
177 recommended_pref::kRecommendedValue);
180 void CreateDefaultPrefs() {
181 default_pref_store_ = new TestingPrefStore;
182 default_pref_store_->SetString(
183 prefs::kManagedPref,
184 default_pref::kManagedValue);
185 default_pref_store_->SetString(
186 prefs::kCommandLinePref,
187 default_pref::kCommandLineValue);
188 default_pref_store_->SetString(
189 prefs::kExtensionPref,
190 default_pref::kExtensionValue);
191 default_pref_store_->SetString(
192 prefs::kUserPref,
193 default_pref::kUserValue);
194 default_pref_store_->SetString(
195 prefs::kRecommendedPref,
196 default_pref::kRecommendedValue);
197 default_pref_store_->SetString(
198 prefs::kDefaultPref,
199 default_pref::kDefaultValue);
202 void ExpectValueChangeNotifications(const char* name) {
203 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(name));
204 EXPECT_CALL(*sync_associator_, ProcessPrefChange(name));
207 void CheckAndClearValueChangeNotifications() {
208 Mock::VerifyAndClearExpectations(&pref_notifier_);
209 Mock::VerifyAndClearExpectations(sync_associator_.get());
212 MockPrefNotifier pref_notifier_;
213 scoped_ptr<MockPrefModelAssociator> sync_associator_;
214 scoped_ptr<PrefValueStore> pref_value_store_;
216 scoped_refptr<TestingPrefStore> managed_pref_store_;
217 scoped_refptr<TestingPrefStore> extension_pref_store_;
218 scoped_refptr<TestingPrefStore> command_line_pref_store_;
219 scoped_refptr<TestingPrefStore> user_pref_store_;
220 scoped_refptr<TestingPrefStore> recommended_pref_store_;
221 scoped_refptr<TestingPrefStore> default_pref_store_;
224 TEST_F(PrefValueStoreTest, GetValue) {
225 const Value* value;
227 // The following tests read a value from the PrefService. The preferences are
228 // set in a way such that all lower-priority stores have a value and we can
229 // test whether overrides work correctly.
231 // Test getting a managed value.
232 value = NULL;
233 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kManagedPref,
234 Value::TYPE_STRING, &value));
235 std::string actual_str_value;
236 EXPECT_TRUE(value->GetAsString(&actual_str_value));
237 EXPECT_EQ(managed_pref::kManagedValue, actual_str_value);
239 // Test getting an extension value.
240 value = NULL;
241 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kExtensionPref,
242 Value::TYPE_STRING, &value));
243 EXPECT_TRUE(value->GetAsString(&actual_str_value));
244 EXPECT_EQ(extension_pref::kExtensionValue, actual_str_value);
246 // Test getting a command-line value.
247 value = NULL;
248 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kCommandLinePref,
249 Value::TYPE_STRING, &value));
250 EXPECT_TRUE(value->GetAsString(&actual_str_value));
251 EXPECT_EQ(command_line_pref::kCommandLineValue, actual_str_value);
253 // Test getting a user-set value.
254 value = NULL;
255 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kUserPref,
256 Value::TYPE_STRING, &value));
257 EXPECT_TRUE(value->GetAsString(&actual_str_value));
258 EXPECT_EQ(user_pref::kUserValue, actual_str_value);
260 // Test getting a user set value overwriting a recommended value.
261 value = NULL;
262 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kRecommendedPref,
263 Value::TYPE_STRING, &value));
264 EXPECT_TRUE(value->GetAsString(&actual_str_value));
265 EXPECT_EQ(recommended_pref::kRecommendedValue,
266 actual_str_value);
268 // Test getting a default value.
269 value = NULL;
270 ASSERT_TRUE(pref_value_store_->GetValue(prefs::kDefaultPref,
271 Value::TYPE_STRING, &value));
272 EXPECT_TRUE(value->GetAsString(&actual_str_value));
273 EXPECT_EQ(default_pref::kDefaultValue, actual_str_value);
275 // Test getting a preference value that the |PrefValueStore|
276 // does not contain.
277 base::FundamentalValue tmp_dummy_value(true);
278 value = &tmp_dummy_value;
279 ASSERT_FALSE(pref_value_store_->GetValue(prefs::kMissingPref,
280 Value::TYPE_STRING, &value));
281 ASSERT_FALSE(value);
284 TEST_F(PrefValueStoreTest, GetRecommendedValue) {
285 const Value* value;
287 // The following tests read a value from the PrefService. The preferences are
288 // set in a way such that all lower-priority stores have a value and we can
289 // test whether overrides do not clutter the recommended value.
291 // Test getting recommended value when a managed value is present.
292 value = NULL;
293 ASSERT_TRUE(pref_value_store_->GetRecommendedValue(
294 prefs::kManagedPref,
295 Value::TYPE_STRING, &value));
296 std::string actual_str_value;
297 EXPECT_TRUE(value->GetAsString(&actual_str_value));
298 EXPECT_EQ(recommended_pref::kManagedValue, actual_str_value);
300 // Test getting recommended value when an extension value is present.
301 value = NULL;
302 ASSERT_TRUE(pref_value_store_->GetRecommendedValue(
303 prefs::kExtensionPref,
304 Value::TYPE_STRING, &value));
305 EXPECT_TRUE(value->GetAsString(&actual_str_value));
306 EXPECT_EQ(recommended_pref::kExtensionValue, actual_str_value);
308 // Test getting recommended value when a command-line value is present.
309 value = NULL;
310 ASSERT_TRUE(pref_value_store_->GetRecommendedValue(
311 prefs::kCommandLinePref,
312 Value::TYPE_STRING, &value));
313 EXPECT_TRUE(value->GetAsString(&actual_str_value));
314 EXPECT_EQ(recommended_pref::kCommandLineValue, actual_str_value);
316 // Test getting recommended value when a user-set value is present.
317 value = NULL;
318 ASSERT_TRUE(pref_value_store_->GetRecommendedValue(
319 prefs::kUserPref,
320 Value::TYPE_STRING, &value));
321 EXPECT_TRUE(value->GetAsString(&actual_str_value));
322 EXPECT_EQ(recommended_pref::kUserValue, actual_str_value);
324 // Test getting recommended value when no higher-priority value is present.
325 value = NULL;
326 ASSERT_TRUE(pref_value_store_->GetRecommendedValue(
327 prefs::kRecommendedPref,
328 Value::TYPE_STRING, &value));
329 EXPECT_TRUE(value->GetAsString(&actual_str_value));
330 EXPECT_EQ(recommended_pref::kRecommendedValue,
331 actual_str_value);
333 // Test getting recommended value when no recommended value is present.
334 base::FundamentalValue tmp_dummy_value(true);
335 value = &tmp_dummy_value;
336 ASSERT_FALSE(pref_value_store_->GetRecommendedValue(
337 prefs::kDefaultPref,
338 Value::TYPE_STRING, &value));
339 ASSERT_FALSE(value);
341 // Test getting a preference value that the |PrefValueStore|
342 // does not contain.
343 value = &tmp_dummy_value;
344 ASSERT_FALSE(pref_value_store_->GetRecommendedValue(
345 prefs::kMissingPref,
346 Value::TYPE_STRING, &value));
347 ASSERT_FALSE(value);
350 TEST_F(PrefValueStoreTest, PrefChanges) {
351 // Check pref controlled by highest-priority store.
352 ExpectValueChangeNotifications(prefs::kManagedPref);
353 managed_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
354 CheckAndClearValueChangeNotifications();
356 ExpectValueChangeNotifications(prefs::kManagedPref);
357 extension_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
358 CheckAndClearValueChangeNotifications();
360 ExpectValueChangeNotifications(prefs::kManagedPref);
361 command_line_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
362 CheckAndClearValueChangeNotifications();
364 ExpectValueChangeNotifications(prefs::kManagedPref);
365 user_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
366 CheckAndClearValueChangeNotifications();
368 ExpectValueChangeNotifications(prefs::kManagedPref);
369 recommended_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
370 CheckAndClearValueChangeNotifications();
372 ExpectValueChangeNotifications(prefs::kManagedPref);
373 default_pref_store_->NotifyPrefValueChanged(prefs::kManagedPref);
374 CheckAndClearValueChangeNotifications();
376 // Check pref controlled by user store.
377 ExpectValueChangeNotifications(prefs::kUserPref);
378 managed_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
379 CheckAndClearValueChangeNotifications();
381 ExpectValueChangeNotifications(prefs::kUserPref);
382 extension_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
383 CheckAndClearValueChangeNotifications();
385 ExpectValueChangeNotifications(prefs::kUserPref);
386 command_line_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
387 CheckAndClearValueChangeNotifications();
389 ExpectValueChangeNotifications(prefs::kUserPref);
390 user_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
391 CheckAndClearValueChangeNotifications();
393 ExpectValueChangeNotifications(prefs::kUserPref);
394 recommended_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
395 CheckAndClearValueChangeNotifications();
397 ExpectValueChangeNotifications(prefs::kUserPref);
398 default_pref_store_->NotifyPrefValueChanged(prefs::kUserPref);
399 CheckAndClearValueChangeNotifications();
401 // Check pref controlled by default-pref store.
402 ExpectValueChangeNotifications(prefs::kDefaultPref);
403 managed_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
404 CheckAndClearValueChangeNotifications();
406 ExpectValueChangeNotifications(prefs::kDefaultPref);
407 extension_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
408 CheckAndClearValueChangeNotifications();
410 ExpectValueChangeNotifications(prefs::kDefaultPref);
411 command_line_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
412 CheckAndClearValueChangeNotifications();
414 ExpectValueChangeNotifications(prefs::kDefaultPref);
415 user_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
416 CheckAndClearValueChangeNotifications();
418 ExpectValueChangeNotifications(prefs::kDefaultPref);
419 recommended_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
420 CheckAndClearValueChangeNotifications();
422 ExpectValueChangeNotifications(prefs::kDefaultPref);
423 default_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
424 CheckAndClearValueChangeNotifications();
427 TEST_F(PrefValueStoreTest, OnInitializationCompleted) {
428 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(0);
429 managed_pref_store_->SetInitializationCompleted();
430 extension_pref_store_->SetInitializationCompleted();
431 command_line_pref_store_->SetInitializationCompleted();
432 recommended_pref_store_->SetInitializationCompleted();
433 default_pref_store_->SetInitializationCompleted();
434 Mock::VerifyAndClearExpectations(&pref_notifier_);
436 // The notification should only be triggered after the last store is done.
437 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(1);
438 user_pref_store_->SetInitializationCompleted();
439 Mock::VerifyAndClearExpectations(&pref_notifier_);
442 TEST_F(PrefValueStoreTest, PrefValueInManagedStore) {
443 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(
444 prefs::kManagedPref));
445 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
446 prefs::kExtensionPref));
447 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
448 prefs::kCommandLinePref));
449 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
450 prefs::kUserPref));
451 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
452 prefs::kRecommendedPref));
453 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
454 prefs::kDefaultPref));
455 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
456 prefs::kMissingPref));
459 TEST_F(PrefValueStoreTest, PrefValueInExtensionStore) {
460 EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore(
461 prefs::kManagedPref));
462 EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore(
463 prefs::kExtensionPref));
464 EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
465 prefs::kCommandLinePref));
466 EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
467 prefs::kUserPref));
468 EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
469 prefs::kRecommendedPref));
470 EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
471 prefs::kDefaultPref));
472 EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
473 prefs::kMissingPref));
476 TEST_F(PrefValueStoreTest, PrefValueInUserStore) {
477 EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
478 prefs::kManagedPref));
479 EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
480 prefs::kExtensionPref));
481 EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
482 prefs::kCommandLinePref));
483 EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
484 prefs::kUserPref));
485 EXPECT_FALSE(pref_value_store_->PrefValueInUserStore(
486 prefs::kRecommendedPref));
487 EXPECT_FALSE(pref_value_store_->PrefValueInUserStore(
488 prefs::kDefaultPref));
489 EXPECT_FALSE(pref_value_store_->PrefValueInUserStore(
490 prefs::kMissingPref));
493 TEST_F(PrefValueStoreTest, PrefValueFromExtensionStore) {
494 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
495 prefs::kManagedPref));
496 EXPECT_TRUE(pref_value_store_->PrefValueFromExtensionStore(
497 prefs::kExtensionPref));
498 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
499 prefs::kCommandLinePref));
500 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
501 prefs::kUserPref));
502 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
503 prefs::kRecommendedPref));
504 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
505 prefs::kDefaultPref));
506 EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
507 prefs::kMissingPref));
510 TEST_F(PrefValueStoreTest, PrefValueFromUserStore) {
511 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
512 prefs::kManagedPref));
513 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
514 prefs::kExtensionPref));
515 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
516 prefs::kCommandLinePref));
517 EXPECT_TRUE(pref_value_store_->PrefValueFromUserStore(
518 prefs::kUserPref));
519 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
520 prefs::kRecommendedPref));
521 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
522 prefs::kDefaultPref));
523 EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
524 prefs::kMissingPref));
527 TEST_F(PrefValueStoreTest, PrefValueFromRecommendedStore) {
528 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
529 prefs::kManagedPref));
530 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
531 prefs::kExtensionPref));
532 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
533 prefs::kCommandLinePref));
534 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
535 prefs::kUserPref));
536 EXPECT_TRUE(pref_value_store_->PrefValueFromRecommendedStore(
537 prefs::kRecommendedPref));
538 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
539 prefs::kDefaultPref));
540 EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
541 prefs::kMissingPref));
544 TEST_F(PrefValueStoreTest, PrefValueFromDefaultStore) {
545 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
546 prefs::kManagedPref));
547 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
548 prefs::kExtensionPref));
549 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
550 prefs::kCommandLinePref));
551 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
552 prefs::kUserPref));
553 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
554 prefs::kRecommendedPref));
555 EXPECT_TRUE(pref_value_store_->PrefValueFromDefaultStore(
556 prefs::kDefaultPref));
557 EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
558 prefs::kMissingPref));
561 TEST_F(PrefValueStoreTest, PrefValueUserModifiable) {
562 EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
563 prefs::kManagedPref));
564 EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
565 prefs::kExtensionPref));
566 EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
567 prefs::kCommandLinePref));
568 EXPECT_TRUE(pref_value_store_->PrefValueUserModifiable(
569 prefs::kUserPref));
570 EXPECT_TRUE(pref_value_store_->PrefValueUserModifiable(
571 prefs::kRecommendedPref));
572 EXPECT_TRUE(pref_value_store_->PrefValueUserModifiable(
573 prefs::kDefaultPref));
574 EXPECT_TRUE(pref_value_store_->PrefValueUserModifiable(
575 prefs::kMissingPref));
578 TEST_F(PrefValueStoreTest, PrefValueExtensionModifiable) {
579 EXPECT_FALSE(pref_value_store_->PrefValueExtensionModifiable(
580 prefs::kManagedPref));
581 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
582 prefs::kExtensionPref));
583 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
584 prefs::kCommandLinePref));
585 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
586 prefs::kUserPref));
587 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
588 prefs::kRecommendedPref));
589 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
590 prefs::kDefaultPref));
591 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
592 prefs::kMissingPref));