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

Side by Side Diff: ash/system/web_notification/web_notification_tray_unittest.cc

Issue 11229022: Move ash/system/web_notification message_center to ui/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again. Created 8 years, 1 month 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) 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 #include "ash/system/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/system/status_area_widget.h" 10 #include "ash/system/status_area_widget.h"
11 #include "ash/system/tray/system_tray_item.h" 11 #include "ash/system/tray/system_tray_item.h"
12 #include "ash/system/web_notification/message_center_bubble.h" 12 #include "ui/message_center/message_center_bubble.h"
13 #include "ash/system/web_notification/popup_bubble.h" 13 #include "ui/message_center/message_popup_bubble.h"
14 #include "ash/system/web_notification/web_notification_list.h" 14 #include "ui/message_center/notification_list.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "ui/views/controls/label.h" 18 #include "ui/views/controls/label.h"
19 #include "ui/views/layout/fill_layout.h" 19 #include "ui/views/layout/fill_layout.h"
20 #include "ui/views/view.h" 20 #include "ui/views/view.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Removing the first notification should not hide the popup bubble. 150 // Removing the first notification should not hide the popup bubble.
151 delegate->RemoveNotification(tray, "test_id1"); 151 delegate->RemoveNotification(tray, "test_id1");
152 EXPECT_TRUE(tray->popup_bubble() != NULL); 152 EXPECT_TRUE(tray->popup_bubble() != NULL);
153 153
154 // Removing the visible notification should hide the popup bubble. 154 // Removing the visible notification should hide the popup bubble.
155 delegate->RemoveNotification(tray, "test_id3"); 155 delegate->RemoveNotification(tray, "test_id3");
156 EXPECT_TRUE(tray->popup_bubble() == NULL); 156 EXPECT_TRUE(tray->popup_bubble() == NULL);
157 } 157 }
158 158
159 using message_center::WebNotificationList; 159 using message_center::NotificationList;
160 160
161 TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) { 161 TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
162 WebNotificationTray* tray = GetWebNotificationTray(); 162 WebNotificationTray* tray = GetWebNotificationTray();
163 scoped_ptr<TestDelegate> delegate(new TestDelegate); 163 scoped_ptr<TestDelegate> delegate(new TestDelegate);
164 tray->message_center()->SetDelegate(delegate.get()); 164 tray->message_center()->SetDelegate(delegate.get());
165 165
166 // Add the max visible notifications +1, ensure the correct visible number. 166 // Add the max visible notifications +1, ensure the correct visible number.
167 size_t notifications_to_add = 167 size_t notifications_to_add =
168 WebNotificationList::kMaxVisibleMessageCenterNotifications + 1; 168 NotificationList::kMaxVisibleMessageCenterNotifications + 1;
169 for (size_t i = 0; i < notifications_to_add; ++i) { 169 for (size_t i = 0; i < notifications_to_add; ++i) {
170 std::string id = StringPrintf("test_id%d", static_cast<int>(i)); 170 std::string id = StringPrintf("test_id%d", static_cast<int>(i));
171 delegate->AddNotification(tray, id); 171 delegate->AddNotification(tray, id);
172 } 172 }
173 tray->ShowMessageCenterBubble(); 173 tray->ShowMessageCenterBubble();
174 RunAllPendingInMessageLoop(); 174 RunAllPendingInMessageLoop();
175 EXPECT_TRUE(tray->message_center_bubble() != NULL); 175 EXPECT_TRUE(tray->message_center_bubble() != NULL);
176 EXPECT_EQ(notifications_to_add, 176 EXPECT_EQ(notifications_to_add,
177 tray->message_center()->NotificationCount()); 177 tray->message_center()->NotificationCount());
178 EXPECT_EQ(WebNotificationList::kMaxVisibleMessageCenterNotifications, 178 EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications,
179 tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); 179 tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest());
180 } 180 }
181 181
182 TEST_F(WebNotificationTrayTest, ManyPopupNotifications) { 182 TEST_F(WebNotificationTrayTest, ManyPopupNotifications) {
183 WebNotificationTray* tray = GetWebNotificationTray(); 183 WebNotificationTray* tray = GetWebNotificationTray();
184 scoped_ptr<TestDelegate> delegate(new TestDelegate); 184 scoped_ptr<TestDelegate> delegate(new TestDelegate);
185 tray->message_center()->SetDelegate(delegate.get()); 185 tray->message_center()->SetDelegate(delegate.get());
186 186
187 // Add the max visible popup notifications +1, ensure the correct num visible. 187 // Add the max visible popup notifications +1, ensure the correct num visible.
188 size_t notifications_to_add = 188 size_t notifications_to_add =
189 WebNotificationList::kMaxVisiblePopupNotifications + 1; 189 NotificationList::kMaxVisiblePopupNotifications + 1;
190 for (size_t i = 0; i < notifications_to_add; ++i) { 190 for (size_t i = 0; i < notifications_to_add; ++i) {
191 std::string id = StringPrintf("test_id%d", static_cast<int>(i)); 191 std::string id = StringPrintf("test_id%d", static_cast<int>(i));
192 delegate->AddNotification(tray, id); 192 delegate->AddNotification(tray, id);
193 } 193 }
194 // Hide and reshow the bubble so that it is updated immediately, not delayed. 194 // Hide and reshow the bubble so that it is updated immediately, not delayed.
195 tray->HidePopupBubble(); 195 tray->HidePopupBubble();
196 tray->ShowPopupBubble(); 196 tray->ShowPopupBubble();
197 EXPECT_TRUE(tray->popup_bubble() != NULL); 197 EXPECT_TRUE(tray->popup_bubble() != NULL);
198 EXPECT_EQ(notifications_to_add, 198 EXPECT_EQ(notifications_to_add,
199 tray->message_center()->NotificationCount()); 199 tray->message_center()->NotificationCount());
200 EXPECT_EQ(WebNotificationList::kMaxVisiblePopupNotifications, 200 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications,
201 tray->GetPopupBubbleForTest()->NumMessageViewsForTest()); 201 tray->GetPopupBubbleForTest()->NumMessageViewsForTest());
202 } 202 }
203 203
204 } // namespace ash 204 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | ash/system/web_notification/web_notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698