| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/prefs/pref_observer.h" | 7 #include "base/prefs/pref_observer.h" |
| 8 #include "base/prefs/public/pref_change_registrar.h" | 8 #include "base/prefs/public/pref_change_registrar.h" |
| 9 #include "chrome/test/base/testing_pref_service.h" | 9 #include "chrome/test/base/testing_pref_service.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 // Explicitly check the expectations now to make sure that the RemoveAll | 122 // Explicitly check the expectations now to make sure that the RemoveAll |
| 123 // worked (rather than the registrar destructor doing the work). | 123 // worked (rather than the registrar destructor doing the work). |
| 124 Mock::VerifyAndClearExpectations(service()); | 124 Mock::VerifyAndClearExpectations(service()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 class ObserveSetOfPreferencesTest : public testing::Test { | 127 class ObserveSetOfPreferencesTest : public testing::Test { |
| 128 public: | 128 public: |
| 129 virtual void SetUp() { | 129 virtual void SetUp() { |
| 130 pref_service_.reset(new TestingPrefServiceSimple); | 130 pref_service_.reset(new TestingPrefServiceSimple); |
| 131 pref_service_->RegisterStringPref(kHomePage, "http://google.com"); | 131 PrefRegistrarSimple* registrar = pref_service_->registrar(); |
| 132 pref_service_->RegisterBooleanPref(kHomePageIsNewTabPage, false); | 132 registrar->RegisterStringPref(kHomePage, "http://google.com"); |
| 133 pref_service_->RegisterStringPref(kApplicationLocale, ""); | 133 registrar->RegisterBooleanPref(kHomePageIsNewTabPage, false); |
| 134 registrar->RegisterStringPref(kApplicationLocale, ""); |
| 134 } | 135 } |
| 135 | 136 |
| 136 PrefChangeRegistrar* CreatePrefChangeRegistrar() { | 137 PrefChangeRegistrar* CreatePrefChangeRegistrar() { |
| 137 PrefChangeRegistrar* pref_set = new PrefChangeRegistrar(); | 138 PrefChangeRegistrar* pref_set = new PrefChangeRegistrar(); |
| 138 base::Closure callback = base::Bind(&base::DoNothing); | 139 base::Closure callback = base::Bind(&base::DoNothing); |
| 139 pref_set->Init(pref_service_.get()); | 140 pref_set->Init(pref_service_.get()); |
| 140 pref_set->Add(kHomePage, callback); | 141 pref_set->Add(kHomePage, callback); |
| 141 pref_set->Add(kHomePageIsNewTabPage, callback); | 142 pref_set->Add(kHomePageIsNewTabPage, callback); |
| 142 return pref_set; | 143 return pref_set; |
| 143 } | 144 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 pref_service_->SetUserPref(kHomePageIsNewTabPage, | 190 pref_service_->SetUserPref(kHomePageIsNewTabPage, |
| 190 new FundamentalValue(true)); | 191 new FundamentalValue(true)); |
| 191 Mock::VerifyAndClearExpectations(this); | 192 Mock::VerifyAndClearExpectations(this); |
| 192 | 193 |
| 193 EXPECT_CALL(*this, OnPreferenceChanged(_)).Times(0); | 194 EXPECT_CALL(*this, OnPreferenceChanged(_)).Times(0); |
| 194 pref_service_->SetUserPref(kApplicationLocale, new StringValue("en_US.utf8")); | 195 pref_service_->SetUserPref(kApplicationLocale, new StringValue("en_US.utf8")); |
| 195 Mock::VerifyAndClearExpectations(this); | 196 Mock::VerifyAndClearExpectations(this); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace base | 199 } // namespace base |
| OLD | NEW |