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 "chrome/browser/prefs/pref_notifier_impl.h" | 5 #include "chrome/browser/prefs/pref_notifier_impl.h" |
6 #include "chrome/browser/prefs/pref_observer_mock.h" | 6 #include "chrome/browser/prefs/pref_observer_mock.h" |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/prefs/pref_value_store.h" | 8 #include "chrome/browser/prefs/pref_value_store.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/test/base/testing_browser_process_test.h" | 10 #include "chrome/test/base/testing_browser_process_test.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_)); | 148 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_)); |
149 | 149 |
150 notifier.RemovePrefObserver(pref_name2, &obs1_); | 150 notifier.RemovePrefObserver(pref_name2, &obs1_); |
151 ASSERT_EQ(0u, notifier.CountObserver(pref_name, &obs1_)); | 151 ASSERT_EQ(0u, notifier.CountObserver(pref_name, &obs1_)); |
152 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); | 152 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); |
153 ASSERT_EQ(0u, notifier.CountObserver(pref_name, &obs2_)); | 153 ASSERT_EQ(0u, notifier.CountObserver(pref_name, &obs2_)); |
154 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_)); | 154 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_)); |
155 } | 155 } |
156 | 156 |
157 TEST_F(PrefNotifierTest, FireObservers) { | 157 TEST_F(PrefNotifierTest, FireObservers) { |
158 base::FundamentalValue value_true(true); | 158 base::BooleanValue value_true(true); |
159 PrefNotifierImpl notifier(&pref_service_); | 159 PrefNotifierImpl notifier(&pref_service_); |
160 notifier.AddPrefObserver(kChangedPref, &obs1_); | 160 notifier.AddPrefObserver(kChangedPref, &obs1_); |
161 notifier.AddPrefObserver(kUnchangedPref, &obs1_); | 161 notifier.AddPrefObserver(kUnchangedPref, &obs1_); |
162 | 162 |
163 obs1_.Expect(&pref_service_, kChangedPref, &value_true); | 163 obs1_.Expect(&pref_service_, kChangedPref, &value_true); |
164 EXPECT_CALL(obs2_, Observe(_, _, _)).Times(0); | 164 EXPECT_CALL(obs2_, Observe(_, _, _)).Times(0); |
165 notifier.OnPreferenceChanged(kChangedPref); | 165 notifier.OnPreferenceChanged(kChangedPref); |
166 Mock::VerifyAndClearExpectations(&obs1_); | 166 Mock::VerifyAndClearExpectations(&obs1_); |
167 Mock::VerifyAndClearExpectations(&obs2_); | 167 Mock::VerifyAndClearExpectations(&obs2_); |
168 | 168 |
(...skipping 22 matching lines...) Expand all Loading... |
191 obs2_.Expect(&pref_service_, kChangedPref, &value_true); | 191 obs2_.Expect(&pref_service_, kChangedPref, &value_true); |
192 notifier.OnPreferenceChanged(kChangedPref); | 192 notifier.OnPreferenceChanged(kChangedPref); |
193 Mock::VerifyAndClearExpectations(&obs1_); | 193 Mock::VerifyAndClearExpectations(&obs1_); |
194 Mock::VerifyAndClearExpectations(&obs2_); | 194 Mock::VerifyAndClearExpectations(&obs2_); |
195 | 195 |
196 notifier.RemovePrefObserver(kChangedPref, &obs2_); | 196 notifier.RemovePrefObserver(kChangedPref, &obs2_); |
197 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); | 197 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); |
198 } | 198 } |
199 | 199 |
200 } // namespace | 200 } // namespace |
OLD | NEW |