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

Side by Side Diff: chrome/browser/notifications/notification_test_util.h

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/notifications/notification.h" 11 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/notifications/notification_object_proxy.h" 12 #include "chrome/browser/notifications/notification_object_proxy.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h" 13 #include "chrome/browser/notifications/notification_ui_manager.h"
14 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 14 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 17
18 // NotificationDelegate which does nothing, useful for testing when 18 // NotificationDelegate which does nothing, useful for testing when
19 // the notification events are not important. 19 // the notification events are not important.
20 class MockNotificationDelegate : public NotificationDelegate { 20 class MockNotificationDelegate : public NotificationDelegate {
21 public: 21 public:
22 explicit MockNotificationDelegate(const std::string& id); 22 explicit MockNotificationDelegate(const std::string& id);
23 23
24 // NotificationDelegate interface. 24 // NotificationDelegate interface.
25 virtual void Display() OVERRIDE {} 25 virtual void Display() override {}
26 virtual void Error() OVERRIDE {} 26 virtual void Error() override {}
27 virtual void Close(bool by_user) OVERRIDE {} 27 virtual void Close(bool by_user) override {}
28 virtual void Click() OVERRIDE {} 28 virtual void Click() override {}
29 virtual std::string id() const OVERRIDE; 29 virtual std::string id() const override;
30 virtual content::WebContents* GetWebContents() const OVERRIDE; 30 virtual content::WebContents* GetWebContents() const override;
31 31
32 private: 32 private:
33 virtual ~MockNotificationDelegate(); 33 virtual ~MockNotificationDelegate();
34 34
35 std::string id_; 35 std::string id_;
36 36
37 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate); 37 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate);
38 }; 38 };
39 39
40 // Mock implementation of Javascript object proxy which logs events that 40 // Mock implementation of Javascript object proxy which logs events that
41 // would have been fired on it. Useful for tests where the sequence of 41 // would have been fired on it. Useful for tests where the sequence of
42 // notification events needs to be verified. 42 // notification events needs to be verified.
43 // 43 //
44 // |Logger| class provided in template must implement method 44 // |Logger| class provided in template must implement method
45 // static void log(string); 45 // static void log(string);
46 template<class Logger> 46 template<class Logger>
47 class LoggingNotificationDelegate : public NotificationDelegate { 47 class LoggingNotificationDelegate : public NotificationDelegate {
48 public: 48 public:
49 explicit LoggingNotificationDelegate(std::string id) : notification_id_(id) {} 49 explicit LoggingNotificationDelegate(std::string id) : notification_id_(id) {}
50 50
51 // NotificationObjectProxy override 51 // NotificationObjectProxy override
52 virtual void Display() OVERRIDE { 52 virtual void Display() override {
53 Logger::log("notification displayed\n"); 53 Logger::log("notification displayed\n");
54 } 54 }
55 virtual void Error() OVERRIDE { 55 virtual void Error() override {
56 Logger::log("notification error\n"); 56 Logger::log("notification error\n");
57 } 57 }
58 virtual void Click() OVERRIDE { 58 virtual void Click() override {
59 Logger::log("notification clicked\n"); 59 Logger::log("notification clicked\n");
60 } 60 }
61 virtual void ButtonClick(int index) OVERRIDE { 61 virtual void ButtonClick(int index) override {
62 Logger::log("notification button clicked\n"); 62 Logger::log("notification button clicked\n");
63 } 63 }
64 virtual void Close(bool by_user) OVERRIDE { 64 virtual void Close(bool by_user) override {
65 if (by_user) 65 if (by_user)
66 Logger::log("notification closed by user\n"); 66 Logger::log("notification closed by user\n");
67 else 67 else
68 Logger::log("notification closed by script\n"); 68 Logger::log("notification closed by script\n");
69 } 69 }
70 virtual std::string id() const OVERRIDE { 70 virtual std::string id() const override {
71 return notification_id_; 71 return notification_id_;
72 } 72 }
73 virtual content::WebContents* GetWebContents() const OVERRIDE { 73 virtual content::WebContents* GetWebContents() const override {
74 return NULL; 74 return NULL;
75 } 75 }
76 76
77 private: 77 private:
78 std::string notification_id_; 78 std::string notification_id_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate); 80 DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate);
81 }; 81 };
82 82
83 class StubNotificationUIManager : public NotificationUIManager { 83 class StubNotificationUIManager : public NotificationUIManager {
84 public: 84 public:
85 explicit StubNotificationUIManager(const GURL& welcome_origin); 85 explicit StubNotificationUIManager(const GURL& welcome_origin);
86 virtual ~StubNotificationUIManager(); 86 virtual ~StubNotificationUIManager();
87 87
88 // Adds a notification to be displayed. Virtual for unit test override. 88 // Adds a notification to be displayed. Virtual for unit test override.
89 virtual void Add(const Notification& notification, Profile* profile) OVERRIDE; 89 virtual void Add(const Notification& notification, Profile* profile) override;
90 virtual bool Update(const Notification& notification, 90 virtual bool Update(const Notification& notification,
91 Profile* profile) OVERRIDE; 91 Profile* profile) override;
92 92
93 // Returns NULL if no notifications match the supplied ID, either currently 93 // Returns NULL if no notifications match the supplied ID, either currently
94 // displayed or in the queue. 94 // displayed or in the queue.
95 virtual const Notification* FindById(const std::string& delegate_id, 95 virtual const Notification* FindById(const std::string& delegate_id,
96 ProfileID profile_id) const OVERRIDE; 96 ProfileID profile_id) const override;
97 97
98 // Removes any notifications matching the supplied ID, either currently 98 // Removes any notifications matching the supplied ID, either currently
99 // displayed or in the queue. Returns true if anything was removed. 99 // displayed or in the queue. Returns true if anything was removed.
100 virtual bool CancelById(const std::string& delegate_id, 100 virtual bool CancelById(const std::string& delegate_id,
101 ProfileID profile_id) OVERRIDE; 101 ProfileID profile_id) override;
102 102
103 // Adds the delegate_id for each outstanding notification to the set 103 // Adds the delegate_id for each outstanding notification to the set
104 // |delegate_ids| (must not be NULL). 104 // |delegate_ids| (must not be NULL).
105 virtual std::set<std::string> GetAllIdsByProfileAndSourceOrigin( 105 virtual std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
106 Profile* profile, 106 Profile* profile,
107 const GURL& source) OVERRIDE; 107 const GURL& source) override;
108 108
109 // Removes notifications matching the |source_origin| (which could be an 109 // Removes notifications matching the |source_origin| (which could be an
110 // extension ID). Returns true if anything was removed. 110 // extension ID). Returns true if anything was removed.
111 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE; 111 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) override;
112 112
113 // Removes notifications matching |profile|. Returns true if any were removed. 113 // Removes notifications matching |profile|. Returns true if any were removed.
114 virtual bool CancelAllByProfile(ProfileID profile_id) OVERRIDE; 114 virtual bool CancelAllByProfile(ProfileID profile_id) override;
115 115
116 // Cancels all pending notifications and closes anything currently showing. 116 // Cancels all pending notifications and closes anything currently showing.
117 // Used when the app is terminating. 117 // Used when the app is terminating.
118 virtual void CancelAll() OVERRIDE; 118 virtual void CancelAll() override;
119 119
120 // Test hook to get the notification so we can check it 120 // Test hook to get the notification so we can check it
121 const Notification& notification() const { return notification_; } 121 const Notification& notification() const { return notification_; }
122 122
123 // Test hook to check the ID of the last notification cancelled. 123 // Test hook to check the ID of the last notification cancelled.
124 std::string& dismissed_id() { return dismissed_id_; } 124 std::string& dismissed_id() { return dismissed_id_; }
125 125
126 size_t added_notifications() const { return added_notifications_; } 126 size_t added_notifications() const { return added_notifications_; }
127 bool welcomed() const { return welcomed_; } 127 bool welcomed() const { return welcomed_; }
128 128
129 private: 129 private:
130 DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager); 130 DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager);
131 Notification notification_; 131 Notification notification_;
132 Profile* profile_; 132 Profile* profile_;
133 std::string dismissed_id_; 133 std::string dismissed_id_;
134 GURL welcome_origin_; 134 GURL welcome_origin_;
135 bool welcomed_; 135 bool welcomed_;
136 size_t added_notifications_; 136 size_t added_notifications_;
137 }; 137 };
138 138
139 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 139 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698