| 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/test/testing_pref_service.h" | 9 #include "chrome/test/testing_pref_service.h" |
| 10 #include "content/common/notification_observer_mock.h" | 10 #include "content/common/notification_observer_mock.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 TEST_F(PrefNotifierTest, OnInitializationCompleted) { | 75 TEST_F(PrefNotifierTest, OnInitializationCompleted) { |
| 76 MockPrefNotifier notifier(&pref_service_); | 76 MockPrefNotifier notifier(&pref_service_); |
| 77 NotificationObserverMock observer; | 77 NotificationObserverMock observer; |
| 78 NotificationRegistrar registrar; | 78 NotificationRegistrar registrar; |
| 79 registrar.Add(&observer, NotificationType::PREF_INITIALIZATION_COMPLETED, | 79 registrar.Add(&observer, NotificationType::PREF_INITIALIZATION_COMPLETED, |
| 80 Source<PrefService>(&pref_service_)); | 80 Source<PrefService>(&pref_service_)); |
| 81 EXPECT_CALL(observer, Observe( | 81 EXPECT_CALL(observer, Observe( |
| 82 Field(&NotificationType::value, | 82 Field(&NotificationType::value, |
| 83 NotificationType::PREF_INITIALIZATION_COMPLETED), | 83 NotificationType::PREF_INITIALIZATION_COMPLETED), |
| 84 Source<PrefService>(&pref_service_), | 84 Source<PrefService>(&pref_service_), |
| 85 NotificationService::NoDetails())); | 85 Details<PrefService>(&pref_service_))); |
| 86 notifier.OnInitializationCompleted(); | 86 notifier.OnInitializationCompleted(true); |
| 87 } | 87 } |
| 88 | 88 |
| 89 TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) { | 89 TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) { |
| 90 const char pref_name[] = "homepage"; | 90 const char pref_name[] = "homepage"; |
| 91 const char pref_name2[] = "proxy"; | 91 const char pref_name2[] = "proxy"; |
| 92 | 92 |
| 93 MockPrefNotifier notifier(&pref_service_); | 93 MockPrefNotifier notifier(&pref_service_); |
| 94 notifier.AddPrefObserver(pref_name, &obs1_); | 94 notifier.AddPrefObserver(pref_name, &obs1_); |
| 95 ASSERT_EQ(1u, notifier.CountObserver(pref_name, &obs1_)); | 95 ASSERT_EQ(1u, notifier.CountObserver(pref_name, &obs1_)); |
| 96 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); | 96 ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 obs2_.Expect(&pref_service_, kChangedPref, &value_true); | 186 obs2_.Expect(&pref_service_, kChangedPref, &value_true); |
| 187 notifier.OnPreferenceChanged(kChangedPref); | 187 notifier.OnPreferenceChanged(kChangedPref); |
| 188 Mock::VerifyAndClearExpectations(&obs1_); | 188 Mock::VerifyAndClearExpectations(&obs1_); |
| 189 Mock::VerifyAndClearExpectations(&obs2_); | 189 Mock::VerifyAndClearExpectations(&obs2_); |
| 190 | 190 |
| 191 notifier.RemovePrefObserver(kChangedPref, &obs2_); | 191 notifier.RemovePrefObserver(kChangedPref, &obs2_); |
| 192 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); | 192 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace | 195 } // namespace |
| OLD | NEW |