Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/prefs/pref_notifier_impl_unittest.cc

Issue 11316163: Remove the last usages of PrefObserver outside of Prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win and CrOS build. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/public/pref_observer.h" 7 #include "base/prefs/public/pref_observer.h"
8 #include "chrome/browser/prefs/mock_pref_change_callback.h"
8 #include "chrome/browser/prefs/pref_notifier_impl.h" 9 #include "chrome/browser/prefs/pref_notifier_impl.h"
9 #include "chrome/browser/prefs/pref_observer_mock.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/prefs/pref_value_store.h" 11 #include "chrome/browser/prefs/pref_value_store.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/test/base/testing_pref_service.h" 13 #include "chrome/test/base/testing_pref_service.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using testing::_; 17 using testing::_;
18 using testing::Field; 18 using testing::Field;
19 using testing::Invoke; 19 using testing::Invoke;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 return count; 67 return count;
68 } 68 }
69 69
70 // Make public for tests below. 70 // Make public for tests below.
71 using PrefNotifierImpl::OnPreferenceChanged; 71 using PrefNotifierImpl::OnPreferenceChanged;
72 using PrefNotifierImpl::OnInitializationCompleted; 72 using PrefNotifierImpl::OnInitializationCompleted;
73 }; 73 };
74 74
75 class PrefObserverMock : public PrefObserver {
76 public:
77 PrefObserverMock() {}
78 virtual ~PrefObserverMock() {}
79
80 MOCK_METHOD2(OnPreferenceChanged, void(PrefServiceBase*, const std::string&));
Mattias Nissler (ping if slow) 2012/12/04 10:10:34 same comment regarding moving the mock declaration
Jói 2012/12/04 10:55:57 In this case it needs to derive from PrefObserver,
Mattias Nissler (ping if slow) 2012/12/04 11:18:33 Yes, you are right, I had missed that this version
81
82 void Expect(PrefServiceBase* prefs,
83 const std::string& pref_name,
84 const Value* value) {
85 EXPECT_CALL(*this, OnPreferenceChanged(prefs, pref_name))
86 .With(PrefValueMatches(prefs, pref_name, value));
87 }
88 };
89
75 // Test fixture class. 90 // Test fixture class.
76 class PrefNotifierTest : public testing::Test { 91 class PrefNotifierTest : public testing::Test {
77 protected: 92 protected:
78 virtual void SetUp() { 93 virtual void SetUp() {
79 pref_service_.RegisterBooleanPref(kChangedPref, 94 pref_service_.RegisterBooleanPref(kChangedPref,
80 true, 95 true,
81 PrefService::UNSYNCABLE_PREF); 96 PrefService::UNSYNCABLE_PREF);
82 pref_service_.RegisterBooleanPref(kUnchangedPref, 97 pref_service_.RegisterBooleanPref(kUnchangedPref,
83 true, 98 true,
84 PrefService::UNSYNCABLE_PREF); 99 PrefService::UNSYNCABLE_PREF);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 EXPECT_CALL(obs2_, OnPreferenceChanged(&pref_service_, kChangedPref)); 220 EXPECT_CALL(obs2_, OnPreferenceChanged(&pref_service_, kChangedPref));
206 notifier.OnPreferenceChanged(kChangedPref); 221 notifier.OnPreferenceChanged(kChangedPref);
207 Mock::VerifyAndClearExpectations(&obs1_); 222 Mock::VerifyAndClearExpectations(&obs1_);
208 Mock::VerifyAndClearExpectations(&obs2_); 223 Mock::VerifyAndClearExpectations(&obs2_);
209 224
210 notifier.RemovePrefObserver(kChangedPref, &obs2_); 225 notifier.RemovePrefObserver(kChangedPref, &obs2_);
211 notifier.RemovePrefObserver(kUnchangedPref, &obs2_); 226 notifier.RemovePrefObserver(kUnchangedPref, &obs2_);
212 } 227 }
213 228
214 } // namespace 229 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698