Index: chrome/browser/prefs/pref_notifier_impl_unittest.cc |
diff --git a/chrome/browser/prefs/pref_notifier_impl_unittest.cc b/chrome/browser/prefs/pref_notifier_impl_unittest.cc |
index 8f3be3c33c0e852d739e477d0d9ce95510d2a11a..bc3450a9ea69af1807cca1325f3274a6dbc09636 100644 |
--- a/chrome/browser/prefs/pref_notifier_impl_unittest.cc |
+++ b/chrome/browser/prefs/pref_notifier_impl_unittest.cc |
@@ -60,32 +60,33 @@ class MockPrefNotifier : public PrefNotifierImpl { |
class PrefNotifierTest : public testing::Test { |
protected: |
virtual void SetUp() { |
- pref_service_.RegisterBooleanPref(kChangedPref, true); |
- pref_service_.RegisterBooleanPref(kUnchangedPref, true); |
+ pref_service_.reset(TestingPrefService::CreateTestingPrefService()); |
+ pref_service_->RegisterBooleanPref(kChangedPref, true); |
+ pref_service_->RegisterBooleanPref(kUnchangedPref, true); |
} |
- TestingPrefService pref_service_; |
+ scoped_ptr<TestingPrefService> pref_service_; |
PrefObserverMock obs1_; |
PrefObserverMock obs2_; |
}; |
TEST_F(PrefNotifierTest, OnPreferenceChanged) { |
- MockPrefNotifier notifier(&pref_service_); |
+ MockPrefNotifier notifier(pref_service_.get()); |
EXPECT_CALL(notifier, FireObservers(kChangedPref)).Times(1); |
notifier.OnPreferenceChanged(kChangedPref); |
} |
TEST_F(PrefNotifierTest, OnInitializationCompleted) { |
- MockPrefNotifier notifier(&pref_service_); |
+ MockPrefNotifier notifier(pref_service_.get()); |
NotificationObserverMock observer; |
NotificationRegistrar registrar; |
registrar.Add(&observer, NotificationType::PREF_INITIALIZATION_COMPLETED, |
- Source<PrefService>(&pref_service_)); |
+ Source<PrefService>(pref_service_.get())); |
EXPECT_CALL(observer, Observe( |
Field(&NotificationType::value, |
NotificationType::PREF_INITIALIZATION_COMPLETED), |
- Source<PrefService>(&pref_service_), |
+ Source<PrefService>(pref_service_.get()), |
NotificationService::NoDetails())); |
notifier.OnInitializationCompleted(); |
} |
@@ -94,7 +95,7 @@ TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) { |
const char pref_name[] = "homepage"; |
const char pref_name2[] = "proxy"; |
- MockPrefNotifier notifier(&pref_service_); |
+ MockPrefNotifier notifier(pref_service_.get()); |
notifier.AddPrefObserver(pref_name, &obs1_); |
ASSERT_EQ(1u, notifier.CountObserver(pref_name, &obs1_)); |
ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); |
@@ -155,11 +156,11 @@ TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) { |
TEST_F(PrefNotifierTest, FireObservers) { |
FundamentalValue value_true(true); |
- PrefNotifierImpl notifier(&pref_service_); |
+ PrefNotifierImpl notifier(pref_service_.get()); |
notifier.AddPrefObserver(kChangedPref, &obs1_); |
notifier.AddPrefObserver(kUnchangedPref, &obs1_); |
- obs1_.Expect(&pref_service_, kChangedPref, &value_true); |
+ obs1_.Expect(pref_service_.get(), kChangedPref, &value_true); |
EXPECT_CALL(obs2_, Observe(_, _, _)).Times(0); |
notifier.OnPreferenceChanged(kChangedPref); |
Mock::VerifyAndClearExpectations(&obs1_); |
@@ -168,8 +169,8 @@ TEST_F(PrefNotifierTest, FireObservers) { |
notifier.AddPrefObserver(kChangedPref, &obs2_); |
notifier.AddPrefObserver(kUnchangedPref, &obs2_); |
- obs1_.Expect(&pref_service_, kChangedPref, &value_true); |
- obs2_.Expect(&pref_service_, kChangedPref, &value_true); |
+ obs1_.Expect(pref_service_.get(), kChangedPref, &value_true); |
+ obs2_.Expect(pref_service_.get(), kChangedPref, &value_true); |
notifier.OnPreferenceChanged(kChangedPref); |
Mock::VerifyAndClearExpectations(&obs1_); |
Mock::VerifyAndClearExpectations(&obs2_); |
@@ -178,7 +179,7 @@ TEST_F(PrefNotifierTest, FireObservers) { |
notifier.RemovePrefObserver(kChangedPref, &obs1_); |
EXPECT_CALL(obs1_, Observe(_, _, _)).Times(0); |
- obs2_.Expect(&pref_service_, kChangedPref, &value_true); |
+ obs2_.Expect(pref_service_.get(), kChangedPref, &value_true); |
notifier.OnPreferenceChanged(kChangedPref); |
Mock::VerifyAndClearExpectations(&obs1_); |
Mock::VerifyAndClearExpectations(&obs2_); |
@@ -187,7 +188,7 @@ TEST_F(PrefNotifierTest, FireObservers) { |
notifier.RemovePrefObserver(kUnchangedPref, &obs1_); |
EXPECT_CALL(obs1_, Observe(_, _, _)).Times(0); |
- obs2_.Expect(&pref_service_, kChangedPref, &value_true); |
+ obs2_.Expect(pref_service_.get(), kChangedPref, &value_true); |
notifier.OnPreferenceChanged(kChangedPref); |
Mock::VerifyAndClearExpectations(&obs1_); |
Mock::VerifyAndClearExpectations(&obs2_); |