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

Side by Side Diff: chrome/browser/prefs/pref_observer_mock.h

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 #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"
12 #include "content/common/content_notification_types.h"
12 #include "content/common/notification_details.h" 13 #include "content/common/notification_details.h"
13 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
14 #include "content/common/notification_source.h" 15 #include "content/common/notification_source.h"
15 #include "content/common/notification_type.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 17
18 using testing::Pointee; 18 using testing::Pointee;
19 using testing::Property; 19 using testing::Property;
20 using testing::Truly; 20 using testing::Truly;
21 21
22 // Matcher that checks whether the current value of the preference named 22 // Matcher that checks whether the current value of the preference named
23 // |pref_name| in |prefs| matches |value|. If |value| is NULL, the matcher 23 // |pref_name| in |prefs| matches |value|. If |value| is NULL, the matcher
24 // checks that the value is not set. 24 // checks that the value is not set.
25 MATCHER_P3(PrefValueMatches, prefs, pref_name, value, "") { 25 MATCHER_P3(PrefValueMatches, prefs, pref_name, value, "") {
26 const PrefService::Preference* pref = 26 const PrefService::Preference* pref =
27 prefs->FindPreference(pref_name.c_str()); 27 prefs->FindPreference(pref_name.c_str());
28 if (!pref) 28 if (!pref)
29 return false; 29 return false;
30 30
31 const Value* actual_value = pref->GetValue(); 31 const Value* actual_value = pref->GetValue();
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(int 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 }; 52 };
53 53
54 #endif // CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ 54 #endif // CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_notifier_impl_unittest.cc ('k') | chrome/browser/prefs/pref_observer_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698