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_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/notifications/balloon_collection_impl.h" | 14 #include "chrome/browser/notifications/balloon_collection_impl.h" |
15 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
17 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
19 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 19 #include "chrome/browser/notifications/notifications_prefs_cache.h" |
| 20 #include "chrome/test/testing_pref_service.h" |
20 #include "chrome/test/testing_profile.h" | 21 #include "chrome/test/testing_profile.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 class DesktopNotificationsTest; | 24 class DesktopNotificationsTest; |
24 typedef LoggingNotificationDelegate<DesktopNotificationsTest> | 25 typedef LoggingNotificationDelegate<DesktopNotificationsTest> |
25 LoggingNotificationProxy; | 26 LoggingNotificationProxy; |
26 | 27 |
27 // Test version of the balloon collection which counts the number | 28 // Test version of the balloon collection which counts the number |
28 // of notifications that are added to it. | 29 // of notifications that are added to it. |
29 class MockBalloonCollection : public BalloonCollectionImpl { | 30 class MockBalloonCollection : public BalloonCollectionImpl { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 96 } |
96 | 97 |
97 // Constructs a notification parameter structure for use in tests. | 98 // Constructs a notification parameter structure for use in tests. |
98 ViewHostMsg_ShowNotification_Params StandardTestNotification(); | 99 ViewHostMsg_ShowNotification_Params StandardTestNotification(); |
99 | 100 |
100 // Create a message loop to allow notifications code to post tasks, | 101 // Create a message loop to allow notifications code to post tasks, |
101 // and a thread so that notifications code runs on the expected thread. | 102 // and a thread so that notifications code runs on the expected thread. |
102 MessageLoopForUI message_loop_; | 103 MessageLoopForUI message_loop_; |
103 BrowserThread ui_thread_; | 104 BrowserThread ui_thread_; |
104 | 105 |
| 106 // Local state mock. |
| 107 TestingPrefService local_state_; |
| 108 |
105 // Test profile. | 109 // Test profile. |
106 scoped_ptr<TestingProfile> profile_; | 110 scoped_ptr<TestingProfile> profile_; |
107 | 111 |
108 // Mock balloon collection -- owned by the NotificationUIManager | 112 // Mock balloon collection -- owned by the NotificationUIManager |
109 MockBalloonCollection* balloon_collection_; | 113 MockBalloonCollection* balloon_collection_; |
110 | 114 |
111 // Real UI manager. | 115 // Real UI manager. |
112 scoped_ptr<NotificationUIManager> ui_manager_; | 116 scoped_ptr<NotificationUIManager> ui_manager_; |
113 | 117 |
114 // Real DesktopNotificationService | 118 // Real DesktopNotificationService |
115 scoped_ptr<DesktopNotificationService> service_; | 119 scoped_ptr<DesktopNotificationService> service_; |
116 | 120 |
117 // Contains the cumulative output of the unit test. | 121 // Contains the cumulative output of the unit test. |
118 static std::string log_output_; | 122 static std::string log_output_; |
119 }; | 123 }; |
120 | 124 |
121 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 125 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ |
OLD | NEW |