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

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

Issue 10494012: Move mock notification observer header from content\test to content\public\test. This way we can en… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_change_registrar.h" 5 #include "chrome/browser/prefs/pref_change_registrar.h"
6 #include "chrome/test/base/testing_pref_service.h" 6 #include "chrome/test/base/testing_pref_service.h"
7 #include "content/public/browser/notification_details.h" 7 #include "content/public/browser/notification_details.h"
8 #include "content/public/browser/notification_source.h" 8 #include "content/public/browser/notification_source.h"
9 #include "content/public/browser/notification_types.h" 9 #include "content/public/browser/notification_types.h"
10 #include "content/test/notification_observer_mock.h" 10 #include "content/public/test/mock_notification_observer.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 using testing::Mock; 14 using testing::Mock;
15 using testing::Eq; 15 using testing::Eq;
16 16
17 namespace { 17 namespace {
18 18
19 // A mock provider that allows us to capture pref observer changes. 19 // A mock provider that allows us to capture pref observer changes.
20 class MockPrefService : public TestingPrefService { 20 class MockPrefService : public TestingPrefService {
(...skipping 15 matching lines...) Expand all
36 virtual ~PrefChangeRegistrarTest() {} 36 virtual ~PrefChangeRegistrarTest() {}
37 37
38 protected: 38 protected:
39 virtual void SetUp(); 39 virtual void SetUp();
40 40
41 content::NotificationObserver* observer() const { return observer_.get(); } 41 content::NotificationObserver* observer() const { return observer_.get(); }
42 MockPrefService* service() const { return service_.get(); } 42 MockPrefService* service() const { return service_.get(); }
43 43
44 private: 44 private:
45 scoped_ptr<MockPrefService> service_; 45 scoped_ptr<MockPrefService> service_;
46 scoped_ptr<content::NotificationObserverMock> observer_; 46 scoped_ptr<content::MockNotificationObserver> observer_;
47 }; 47 };
48 48
49 void PrefChangeRegistrarTest::SetUp() { 49 void PrefChangeRegistrarTest::SetUp() {
50 service_.reset(new MockPrefService()); 50 service_.reset(new MockPrefService());
51 observer_.reset(new content::NotificationObserverMock()); 51 observer_.reset(new content::MockNotificationObserver());
52 } 52 }
53 53
54 TEST_F(PrefChangeRegistrarTest, AddAndRemove) { 54 TEST_F(PrefChangeRegistrarTest, AddAndRemove) {
55 PrefChangeRegistrar registrar; 55 PrefChangeRegistrar registrar;
56 registrar.Init(service()); 56 registrar.Init(service());
57 57
58 // Test adding. 58 // Test adding.
59 EXPECT_CALL(*service(), 59 EXPECT_CALL(*service(),
60 AddPrefObserver(Eq(std::string("test.pref.1")), observer())); 60 AddPrefObserver(Eq(std::string("test.pref.1")), observer()));
61 EXPECT_CALL(*service(), 61 EXPECT_CALL(*service(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 RemovePrefObserver(Eq(std::string("test.pref.1")), observer())); 111 RemovePrefObserver(Eq(std::string("test.pref.1")), observer()));
112 EXPECT_CALL(*service(), 112 EXPECT_CALL(*service(),
113 RemovePrefObserver(Eq(std::string("test.pref.2")), observer())); 113 RemovePrefObserver(Eq(std::string("test.pref.2")), observer()));
114 registrar.RemoveAll(); 114 registrar.RemoveAll();
115 EXPECT_TRUE(registrar.IsEmpty()); 115 EXPECT_TRUE(registrar.IsEmpty());
116 116
117 // Explicitly check the expectations now to make sure that the RemoveAll 117 // Explicitly check the expectations now to make sure that the RemoveAll
118 // worked (rather than the registrar destructor doing the work). 118 // worked (rather than the registrar destructor doing the work).
119 Mock::VerifyAndClearExpectations(service()); 119 Mock::VerifyAndClearExpectations(service());
120 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x_unittest.cc ('k') | chrome/browser/prefs/pref_notifier_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698