OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 6 #include "base/callback.h" |
7 #include "base/prefs/pref_observer.h" | 7 #include "base/prefs/pref_observer.h" |
8 #include "chrome/browser/prefs/mock_pref_change_callback.h" | 8 #include "chrome/browser/prefs/mock_pref_change_callback.h" |
9 #include "chrome/browser/prefs/pref_notifier_impl.h" | 9 #include "chrome/browser/prefs/pref_notifier_impl.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 EXPECT_CALL(*this, OnPreferenceChanged(prefs, pref_name)) | 87 EXPECT_CALL(*this, OnPreferenceChanged(prefs, pref_name)) |
88 .With(PrefValueMatches(prefs, pref_name, value)); | 88 .With(PrefValueMatches(prefs, pref_name, value)); |
89 } | 89 } |
90 }; | 90 }; |
91 | 91 |
92 // Test fixture class. | 92 // Test fixture class. |
93 class PrefNotifierTest : public testing::Test { | 93 class PrefNotifierTest : public testing::Test { |
94 protected: | 94 protected: |
95 virtual void SetUp() { | 95 virtual void SetUp() { |
96 pref_service_.RegisterBooleanPref(kChangedPref, | 96 pref_service_.RegisterBooleanPref(kChangedPref, |
97 true, | 97 true); |
98 PrefService::UNSYNCABLE_PREF); | |
99 pref_service_.RegisterBooleanPref(kUnchangedPref, | 98 pref_service_.RegisterBooleanPref(kUnchangedPref, |
100 true, | 99 true); |
101 PrefService::UNSYNCABLE_PREF); | |
102 } | 100 } |
103 | 101 |
104 TestingPrefService pref_service_; | 102 TestingPrefServiceSimple pref_service_; |
105 | 103 |
106 PrefObserverMock obs1_; | 104 PrefObserverMock obs1_; |
107 PrefObserverMock obs2_; | 105 PrefObserverMock obs2_; |
108 }; | 106 }; |
109 | 107 |
110 TEST_F(PrefNotifierTest, OnPreferenceChanged) { | 108 TEST_F(PrefNotifierTest, OnPreferenceChanged) { |
111 MockPrefNotifier notifier(&pref_service_); | 109 MockPrefNotifier notifier(&pref_service_); |
112 EXPECT_CALL(notifier, FireObservers(kChangedPref)).Times(1); | 110 EXPECT_CALL(notifier, FireObservers(kChangedPref)).Times(1); |
113 notifier.OnPreferenceChanged(kChangedPref); | 111 notifier.OnPreferenceChanged(kChangedPref); |
114 } | 112 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXPECT_CALL(obs2_, OnPreferenceChanged(&pref_service_, kChangedPref)); | 220 EXPECT_CALL(obs2_, OnPreferenceChanged(&pref_service_, kChangedPref)); |
223 notifier.OnPreferenceChanged(kChangedPref); | 221 notifier.OnPreferenceChanged(kChangedPref); |
224 Mock::VerifyAndClearExpectations(&obs1_); | 222 Mock::VerifyAndClearExpectations(&obs1_); |
225 Mock::VerifyAndClearExpectations(&obs2_); | 223 Mock::VerifyAndClearExpectations(&obs2_); |
226 | 224 |
227 notifier.RemovePrefObserver(kChangedPref, &obs2_); | 225 notifier.RemovePrefObserver(kChangedPref, &obs2_); |
228 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); | 226 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); |
229 } | 227 } |
230 | 228 |
231 } // namespace | 229 } // namespace |
OLD | NEW |