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