OLD | NEW |
1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 20 matching lines...) Expand all Loading... |
32 if (!actual_value) | 32 if (!actual_value) |
33 return value == NULL; | 33 return value == NULL; |
34 if (!value) | 34 if (!value) |
35 return actual_value == NULL; | 35 return actual_value == NULL; |
36 return value->Equals(actual_value); | 36 return value->Equals(actual_value); |
37 } | 37 } |
38 | 38 |
39 // A mock for testing preference notifications and easy setup of expectations. | 39 // A mock for testing preference notifications and easy setup of expectations. |
40 class PrefObserverMock : public NotificationObserver { | 40 class PrefObserverMock : public NotificationObserver { |
41 public: | 41 public: |
42 PrefObserverMock() {} | 42 PrefObserverMock(); |
43 virtual ~PrefObserverMock() {} | 43 virtual ~PrefObserverMock(); |
44 | 44 |
45 MOCK_METHOD3(Observe, void(NotificationType type, | 45 MOCK_METHOD3(Observe, void(NotificationType type, |
46 const NotificationSource& source, | 46 const NotificationSource& source, |
47 const NotificationDetails& details)); | 47 const NotificationDetails& details)); |
48 | 48 |
49 void Expect(const PrefService* prefs, | 49 void Expect(const PrefService* prefs, |
50 const std::string& pref_name, | 50 const std::string& pref_name, |
51 const Value* value) { | 51 const Value* value); |
52 EXPECT_CALL(*this, Observe(NotificationType(NotificationType::PREF_CHANGED), | |
53 Source<PrefService>(prefs), | |
54 Property(&Details<std::string>::ptr, | |
55 Pointee(pref_name)))) | |
56 .With(PrefValueMatches(prefs, pref_name, value)); | |
57 } | |
58 }; | 52 }; |
59 | 53 |
60 #endif // CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ | 54 #endif // CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ |
OLD | NEW |