OLD | NEW |
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/extensions/extension_pref_store.h" |
5 #include "chrome/browser/prefs/pref_change_registrar.h" | 6 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 7 #include "chrome/browser/prefs/testing_pref_store.h" |
6 #include "chrome/common/notification_details.h" | 8 #include "chrome/common/notification_details.h" |
7 #include "chrome/common/notification_observer_mock.h" | 9 #include "chrome/common/notification_observer_mock.h" |
8 #include "chrome/common/notification_source.h" | 10 #include "chrome/common/notification_source.h" |
9 #include "chrome/common/notification_type.h" | 11 #include "chrome/common/notification_type.h" |
10 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/testing_pref_service.h" | 13 #include "chrome/test/testing_pref_service.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 using testing::Mock; | 17 using testing::Mock; |
16 using testing::Eq; | 18 using testing::Eq; |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 // A mock provider that allows us to capture pref observer changes. | 22 // A mock provider that allows us to capture pref observer changes. |
21 class MockPrefService : public TestingPrefService { | 23 class MockPrefService : public TestingPrefService { |
22 public: | 24 public: |
23 MockPrefService() {} | 25 MockPrefService() |
| 26 : TestingPrefService(new TestingPrefStore(), |
| 27 new TestingPrefStore(), |
| 28 new ExtensionPrefStore(), |
| 29 new TestingPrefStore()) { |
| 30 } |
24 virtual ~MockPrefService() {}; | 31 virtual ~MockPrefService() {}; |
25 | 32 |
26 MOCK_METHOD2(AddPrefObserver, void(const char*, NotificationObserver*)); | 33 MOCK_METHOD2(AddPrefObserver, void(const char*, NotificationObserver*)); |
27 MOCK_METHOD2(RemovePrefObserver, void(const char*, NotificationObserver*)); | 34 MOCK_METHOD2(RemovePrefObserver, void(const char*, NotificationObserver*)); |
28 }; | 35 }; |
29 | 36 |
30 } // namespace | 37 } // namespace |
31 | 38 |
32 class PrefChangeRegistrarTest : public testing::Test { | 39 class PrefChangeRegistrarTest : public testing::Test { |
33 public: | 40 public: |
(...skipping 76 matching lines...) Loading... |
110 RemovePrefObserver(Eq(std::string("test.pref.1")), observer())); | 117 RemovePrefObserver(Eq(std::string("test.pref.1")), observer())); |
111 EXPECT_CALL(*service(), | 118 EXPECT_CALL(*service(), |
112 RemovePrefObserver(Eq(std::string("test.pref.2")), observer())); | 119 RemovePrefObserver(Eq(std::string("test.pref.2")), observer())); |
113 registrar.RemoveAll(); | 120 registrar.RemoveAll(); |
114 EXPECT_TRUE(registrar.IsEmpty()); | 121 EXPECT_TRUE(registrar.IsEmpty()); |
115 | 122 |
116 // Explicitly check the expectations now to make sure that the RemoveAll | 123 // Explicitly check the expectations now to make sure that the RemoveAll |
117 // worked (rather than the registrar destructor doing the work). | 124 // worked (rather than the registrar destructor doing the work). |
118 Mock::VerifyAndClearExpectations(service()); | 125 Mock::VerifyAndClearExpectations(service()); |
119 } | 126 } |
OLD | NEW |