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

Side by Side Diff: chrome/browser/prefs/pref_set_observer_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) 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_set_observer.h" 5 #include "chrome/browser/prefs/pref_set_observer.h"
6 #include "chrome/common/chrome_notification_types.h" 6 #include "chrome/common/chrome_notification_types.h"
7 #include "chrome/common/pref_names.h" 7 #include "chrome/common/pref_names.h"
8 #include "chrome/test/base/testing_pref_service.h" 8 #include "chrome/test/base/testing_pref_service.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_source.h" 10 #include "content/public/browser/notification_source.h"
11 #include "content/test/notification_observer_mock.h" 11 #include "content/public/test/mock_notification_observer.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 // Unit tests for PrefSetObserver. 15 // Unit tests for PrefSetObserver.
16 class PrefSetObserverTest : public testing::Test { 16 class PrefSetObserverTest : public testing::Test {
17 public: 17 public:
18 virtual void SetUp() { 18 virtual void SetUp() {
19 pref_service_.reset(new TestingPrefService); 19 pref_service_.reset(new TestingPrefService);
20 pref_service_->RegisterStringPref(prefs::kHomePage, 20 pref_service_->RegisterStringPref(prefs::kHomePage,
21 "http://google.com", 21 "http://google.com",
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MATCHER_P(PrefNameDetails, name, "details references named preference") { 65 MATCHER_P(PrefNameDetails, name, "details references named preference") {
66 std::string* pstr = 66 std::string* pstr =
67 reinterpret_cast<const content::Details<std::string>&>(arg).ptr(); 67 reinterpret_cast<const content::Details<std::string>&>(arg).ptr();
68 return pstr && *pstr == name; 68 return pstr && *pstr == name;
69 } 69 }
70 70
71 TEST_F(PrefSetObserverTest, Observe) { 71 TEST_F(PrefSetObserverTest, Observe) {
72 using testing::_; 72 using testing::_;
73 using testing::Mock; 73 using testing::Mock;
74 74
75 content::NotificationObserverMock observer; 75 content::MockNotificationObserver observer;
76 scoped_ptr<PrefSetObserver> pref_set(CreatePrefSetObserver(&observer)); 76 scoped_ptr<PrefSetObserver> pref_set(CreatePrefSetObserver(&observer));
77 77
78 EXPECT_CALL(observer, 78 EXPECT_CALL(observer,
79 Observe(int(chrome::NOTIFICATION_PREF_CHANGED), 79 Observe(int(chrome::NOTIFICATION_PREF_CHANGED),
80 content::Source<PrefService>(pref_service_.get()), 80 content::Source<PrefService>(pref_service_.get()),
81 PrefNameDetails(prefs::kHomePage))); 81 PrefNameDetails(prefs::kHomePage)));
82 pref_service_->SetUserPref(prefs::kHomePage, 82 pref_service_->SetUserPref(prefs::kHomePage,
83 Value::CreateStringValue("http://crbug.com")); 83 Value::CreateStringValue("http://crbug.com"));
84 Mock::VerifyAndClearExpectations(&observer); 84 Mock::VerifyAndClearExpectations(&observer);
85 85
86 EXPECT_CALL(observer, 86 EXPECT_CALL(observer,
87 Observe(int(chrome::NOTIFICATION_PREF_CHANGED), 87 Observe(int(chrome::NOTIFICATION_PREF_CHANGED),
88 content::Source<PrefService>(pref_service_.get()), 88 content::Source<PrefService>(pref_service_.get()),
89 PrefNameDetails(prefs::kHomePageIsNewTabPage))); 89 PrefNameDetails(prefs::kHomePageIsNewTabPage)));
90 pref_service_->SetUserPref(prefs::kHomePageIsNewTabPage, 90 pref_service_->SetUserPref(prefs::kHomePageIsNewTabPage,
91 Value::CreateBooleanValue(true)); 91 Value::CreateBooleanValue(true));
92 Mock::VerifyAndClearExpectations(&observer); 92 Mock::VerifyAndClearExpectations(&observer);
93 93
94 EXPECT_CALL(observer, Observe(_, _, _)).Times(0); 94 EXPECT_CALL(observer, Observe(_, _, _)).Times(0);
95 pref_service_->SetUserPref(prefs::kApplicationLocale, 95 pref_service_->SetUserPref(prefs::kApplicationLocale,
96 Value::CreateStringValue("en_US.utf8")); 96 Value::CreateStringValue("en_US.utf8"));
97 Mock::VerifyAndClearExpectations(&observer); 97 Mock::VerifyAndClearExpectations(&observer);
98 } 98 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_notifier_impl_unittest.cc ('k') | chrome/browser/sync/glue/data_type_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698