| 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/ptr_util.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "chrome/browser/net/safe_search_util.h" | 11 #include "chrome/browser/net/safe_search_util.h" |
| 11 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 12 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 12 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 13 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
| 13 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 14 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "components/prefs/testing_pref_store.h" | 16 #include "components/prefs/testing_pref_store.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 53 } |
| 53 | 54 |
| 54 SupervisedUserPrefStoreFixture::~SupervisedUserPrefStoreFixture() { | 55 SupervisedUserPrefStoreFixture::~SupervisedUserPrefStoreFixture() { |
| 55 pref_store_->RemoveObserver(this); | 56 pref_store_->RemoveObserver(this); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void SupervisedUserPrefStoreFixture::OnPrefValueChanged( | 59 void SupervisedUserPrefStoreFixture::OnPrefValueChanged( |
| 59 const std::string& key) { | 60 const std::string& key) { |
| 60 const base::Value* value = NULL; | 61 const base::Value* value = NULL; |
| 61 ASSERT_TRUE(pref_store_->GetValue(key, &value)); | 62 ASSERT_TRUE(pref_store_->GetValue(key, &value)); |
| 62 changed_prefs_.Set(key, value->DeepCopy()); | 63 changed_prefs_.Set(key, base::MakeUnique<base::Value>(*value)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void SupervisedUserPrefStoreFixture::OnInitializationCompleted(bool succeeded) { | 66 void SupervisedUserPrefStoreFixture::OnInitializationCompleted(bool succeeded) { |
| 66 EXPECT_FALSE(initialization_completed_); | 67 EXPECT_FALSE(initialization_completed_); |
| 67 EXPECT_TRUE(succeeded); | 68 EXPECT_TRUE(succeeded); |
| 68 EXPECT_TRUE(pref_store_->IsInitializationComplete()); | 69 EXPECT_TRUE(pref_store_->IsInitializationComplete()); |
| 69 initialization_completed_ = true; | 70 initialization_completed_ = true; |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace | 73 } // namespace |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { | 174 TEST_F(SupervisedUserPrefStoreTest, CreatePrefStoreAfterInitialization) { |
| 174 pref_store_->SetInitializationCompleted(); | 175 pref_store_->SetInitializationCompleted(); |
| 175 service_.SetActive(true); | 176 service_.SetActive(true); |
| 176 | 177 |
| 177 SupervisedUserPrefStoreFixture fixture(&service_); | 178 SupervisedUserPrefStoreFixture fixture(&service_); |
| 178 EXPECT_TRUE(fixture.initialization_completed()); | 179 EXPECT_TRUE(fixture.initialization_completed()); |
| 179 EXPECT_EQ(0u, fixture.changed_prefs()->size()); | 180 EXPECT_EQ(0u, fixture.changed_prefs()->size()); |
| 180 } | 181 } |
| 181 | 182 |
| OLD | NEW |