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

Unified Diff: chrome/browser/prefs/pref_change_registrar_unittest.cc

Issue 10857031: Move PrefMember and PrefChangeRegistrar to api directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to parent Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/pref_change_registrar.cc ('k') | chrome/browser/prefs/pref_member.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_change_registrar_unittest.cc
diff --git a/chrome/browser/prefs/pref_change_registrar_unittest.cc b/chrome/browser/prefs/pref_change_registrar_unittest.cc
deleted file mode 100644
index 2c0dfd2485b4ced1ec6d5861791b20fec204c90d..0000000000000000000000000000000000000000
--- a/chrome/browser/prefs/pref_change_registrar_unittest.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/prefs/pref_change_registrar.h"
-#include "chrome/test/base/testing_pref_service.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
-#include "content/public/test/mock_notification_observer.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using testing::Mock;
-using testing::Eq;
-
-namespace {
-
-// A mock provider that allows us to capture pref observer changes.
-class MockPrefService : public TestingPrefService {
- public:
- MockPrefService() {}
- virtual ~MockPrefService() {}
-
- MOCK_METHOD2(AddPrefObserver,
- void(const char*, content::NotificationObserver*));
- MOCK_METHOD2(RemovePrefObserver,
- void(const char*, content::NotificationObserver*));
-};
-
-} // namespace
-
-class PrefChangeRegistrarTest : public testing::Test {
- public:
- PrefChangeRegistrarTest() {}
- virtual ~PrefChangeRegistrarTest() {}
-
- protected:
- virtual void SetUp();
-
- content::NotificationObserver* observer() const { return observer_.get(); }
- MockPrefService* service() const { return service_.get(); }
-
- private:
- scoped_ptr<MockPrefService> service_;
- scoped_ptr<content::MockNotificationObserver> observer_;
-};
-
-void PrefChangeRegistrarTest::SetUp() {
- service_.reset(new MockPrefService());
- observer_.reset(new content::MockNotificationObserver());
-}
-
-TEST_F(PrefChangeRegistrarTest, AddAndRemove) {
- PrefChangeRegistrar registrar;
- registrar.Init(service());
-
- // Test adding.
- EXPECT_CALL(*service(),
- AddPrefObserver(Eq(std::string("test.pref.1")), observer()));
- EXPECT_CALL(*service(),
- AddPrefObserver(Eq(std::string("test.pref.2")), observer()));
- registrar.Add("test.pref.1", observer());
- registrar.Add("test.pref.2", observer());
- EXPECT_FALSE(registrar.IsEmpty());
-
- // Test removing.
- Mock::VerifyAndClearExpectations(service());
- EXPECT_CALL(*service(),
- RemovePrefObserver(Eq(std::string("test.pref.1")), observer()));
- EXPECT_CALL(*service(),
- RemovePrefObserver(Eq(std::string("test.pref.2")), observer()));
- registrar.Remove("test.pref.1", observer());
- registrar.Remove("test.pref.2", observer());
- EXPECT_TRUE(registrar.IsEmpty());
-
- // Explicitly check the expectations now to make sure that the Removes
- // worked (rather than the registrar destructor doing the work).
- Mock::VerifyAndClearExpectations(service());
-}
-
-TEST_F(PrefChangeRegistrarTest, AutoRemove) {
- PrefChangeRegistrar registrar;
- registrar.Init(service());
-
- // Setup of auto-remove.
- EXPECT_CALL(*service(),
- AddPrefObserver(Eq(std::string("test.pref.1")), observer()));
- registrar.Add("test.pref.1", observer());
- Mock::VerifyAndClearExpectations(service());
- EXPECT_FALSE(registrar.IsEmpty());
-
- // Test auto-removing.
- EXPECT_CALL(*service(),
- RemovePrefObserver(Eq(std::string("test.pref.1")), observer()));
-}
-
-TEST_F(PrefChangeRegistrarTest, RemoveAll) {
- PrefChangeRegistrar registrar;
- registrar.Init(service());
-
- EXPECT_CALL(*service(),
- AddPrefObserver(Eq(std::string("test.pref.1")), observer()));
- EXPECT_CALL(*service(),
- AddPrefObserver(Eq(std::string("test.pref.2")), observer()));
- registrar.Add("test.pref.1", observer());
- registrar.Add("test.pref.2", observer());
- Mock::VerifyAndClearExpectations(service());
-
- EXPECT_CALL(*service(),
- RemovePrefObserver(Eq(std::string("test.pref.1")), observer()));
- EXPECT_CALL(*service(),
- RemovePrefObserver(Eq(std::string("test.pref.2")), observer()));
- registrar.RemoveAll();
- EXPECT_TRUE(registrar.IsEmpty());
-
- // Explicitly check the expectations now to make sure that the RemoveAll
- // worked (rather than the registrar destructor doing the work).
- Mock::VerifyAndClearExpectations(service());
-}
« no previous file with comments | « chrome/browser/prefs/pref_change_registrar.cc ('k') | chrome/browser/prefs/pref_member.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698