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" |
11 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 11 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
12 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 12 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
13 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 13 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using base::DictionaryValue; | 17 using base::DictionaryValue; |
18 using base::Value; | 18 using base::Value; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 class SupervisedUserPrefStoreFixture : public PrefStore::Observer { | 22 class SupervisedUserPrefStoreFixture : public PrefStore::Observer { |
23 public: | 23 public: |
24 explicit SupervisedUserPrefStoreFixture( | 24 explicit SupervisedUserPrefStoreFixture( |
25 SupervisedUserSettingsService* settings_service); | 25 SupervisedUserSettingsService* settings_service); |
26 virtual ~SupervisedUserPrefStoreFixture(); | 26 ~SupervisedUserPrefStoreFixture() override; |
27 | 27 |
28 base::DictionaryValue* changed_prefs() { | 28 base::DictionaryValue* changed_prefs() { |
29 return &changed_prefs_; | 29 return &changed_prefs_; |
30 } | 30 } |
31 | 31 |
32 bool initialization_completed() const { | 32 bool initialization_completed() const { |
33 return initialization_completed_; | 33 return initialization_completed_; |
34 } | 34 } |
35 | 35 |
36 // PrefStore::Observer implementation: | 36 // PrefStore::Observer implementation: |
37 virtual void OnPrefValueChanged(const std::string& key) override; | 37 void OnPrefValueChanged(const std::string& key) override; |
38 virtual void OnInitializationCompleted(bool succeeded) override; | 38 void OnInitializationCompleted(bool succeeded) override; |
39 | 39 |
40 private: | 40 private: |
41 scoped_refptr<SupervisedUserPrefStore> pref_store_; | 41 scoped_refptr<SupervisedUserPrefStore> pref_store_; |
42 base::DictionaryValue changed_prefs_; | 42 base::DictionaryValue changed_prefs_; |
43 bool initialization_completed_; | 43 bool initialization_completed_; |
44 }; | 44 }; |
45 | 45 |
46 SupervisedUserPrefStoreFixture::SupervisedUserPrefStoreFixture( | 46 SupervisedUserPrefStoreFixture::SupervisedUserPrefStoreFixture( |
47 SupervisedUserSettingsService* settings_service) | 47 SupervisedUserSettingsService* settings_service) |
48 : pref_store_(new SupervisedUserPrefStore(settings_service)), | 48 : pref_store_(new SupervisedUserPrefStore(settings_service)), |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |