OLD | NEW |
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; | |
31 | 30 |
32 private: | 31 private: |
33 virtual ~MockNotificationDelegate(); | 32 virtual ~MockNotificationDelegate(); |
34 | 33 |
35 std::string id_; | 34 std::string id_; |
36 | 35 |
37 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate); | 36 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate); |
38 }; | 37 }; |
39 | 38 |
40 // Mock implementation of Javascript object proxy which logs events that | 39 // Mock implementation of Javascript object proxy which logs events that |
(...skipping 24 matching lines...) Expand all Loading... |
65 } | 64 } |
66 virtual void Close(bool by_user) OVERRIDE { | 65 virtual void Close(bool by_user) OVERRIDE { |
67 if (by_user) | 66 if (by_user) |
68 Logger::log("notification closed by user\n"); | 67 Logger::log("notification closed by user\n"); |
69 else | 68 else |
70 Logger::log("notification closed by script\n"); | 69 Logger::log("notification closed by script\n"); |
71 } | 70 } |
72 virtual std::string id() const OVERRIDE { | 71 virtual std::string id() const OVERRIDE { |
73 return notification_id_; | 72 return notification_id_; |
74 } | 73 } |
75 virtual content::WebContents* GetWebContents() const OVERRIDE { | |
76 return NULL; | |
77 } | |
78 | 74 |
79 private: | 75 private: |
80 std::string notification_id_; | 76 std::string notification_id_; |
81 | 77 |
82 DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate); | 78 DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate); |
83 }; | 79 }; |
84 | 80 |
85 class StubNotificationUIManager : public NotificationUIManager { | 81 class StubNotificationUIManager : public NotificationUIManager { |
86 public: | 82 public: |
87 explicit StubNotificationUIManager(const GURL& welcome_origin); | 83 explicit StubNotificationUIManager(const GURL& welcome_origin); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager); | 126 DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager); |
131 Notification notification_; | 127 Notification notification_; |
132 Profile* profile_; | 128 Profile* profile_; |
133 std::string dismissed_id_; | 129 std::string dismissed_id_; |
134 GURL welcome_origin_; | 130 GURL welcome_origin_; |
135 bool welcomed_; | 131 bool welcomed_; |
136 size_t added_notifications_; | 132 size_t added_notifications_; |
137 }; | 133 }; |
138 | 134 |
139 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ | 135 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ |
OLD | NEW |