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 #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/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 EXPECT_TRUE(tray->IsPopupVisible()); | 181 EXPECT_TRUE(tray->IsPopupVisible()); |
182 | 182 |
183 // Removing the visible notification should hide the popup bubble. | 183 // Removing the visible notification should hide the popup bubble. |
184 delegate->RemoveNotification(tray, "test_id3"); | 184 delegate->RemoveNotification(tray, "test_id3"); |
185 EXPECT_FALSE(tray->IsPopupVisible()); | 185 EXPECT_FALSE(tray->IsPopupVisible()); |
186 } | 186 } |
187 | 187 |
188 using message_center::NotificationList; | 188 using message_center::NotificationList; |
189 | 189 |
190 | 190 |
191 TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) { | 191 // Flakily fails. http://crbug.com/229791 |
| 192 TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { |
192 WebNotificationTray* tray = GetWebNotificationTray(); | 193 WebNotificationTray* tray = GetWebNotificationTray(); |
193 scoped_ptr<TestDelegate> delegate(new TestDelegate(get_message_center())); | 194 scoped_ptr<TestDelegate> delegate(new TestDelegate(get_message_center())); |
194 | 195 |
195 // Add the max visible notifications +1, ensure the correct visible number. | 196 // Add the max visible notifications +1, ensure the correct visible number. |
196 size_t notifications_to_add = | 197 size_t notifications_to_add = |
197 NotificationList::kMaxVisibleMessageCenterNotifications + 1; | 198 NotificationList::kMaxVisibleMessageCenterNotifications + 1; |
198 for (size_t i = 0; i < notifications_to_add; ++i) { | 199 for (size_t i = 0; i < notifications_to_add; ++i) { |
199 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 200 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
200 delegate->AddNotification(tray, id); | 201 delegate->AddNotification(tray, id); |
201 } | 202 } |
202 bool shown = tray->message_center_tray_->ShowMessageCenterBubble(); | 203 bool shown = tray->message_center_tray_->ShowMessageCenterBubble(); |
203 EXPECT_TRUE(shown); | 204 EXPECT_TRUE(shown); |
204 RunAllPendingInMessageLoop(); | 205 RunAllPendingInMessageLoop(); |
205 EXPECT_TRUE(tray->message_center_bubble() != NULL); | 206 EXPECT_TRUE(tray->message_center_bubble() != NULL); |
206 EXPECT_EQ(notifications_to_add, | 207 EXPECT_EQ(notifications_to_add, |
207 get_message_center()->NotificationCount()); | 208 get_message_center()->NotificationCount()); |
208 EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, | 209 EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, |
209 tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); | 210 tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); |
210 } | 211 } |
211 | 212 |
212 TEST_F(WebNotificationTrayTest, ManyPopupNotifications) { | 213 // Flakily times out. http://crbug.com/229792 |
| 214 TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { |
213 WebNotificationTray* tray = GetWebNotificationTray(); | 215 WebNotificationTray* tray = GetWebNotificationTray(); |
214 scoped_ptr<TestDelegate> delegate(new TestDelegate(get_message_center())); | 216 scoped_ptr<TestDelegate> delegate(new TestDelegate(get_message_center())); |
215 | 217 |
216 // Add the max visible popup notifications +1, ensure the correct num visible. | 218 // Add the max visible popup notifications +1, ensure the correct num visible. |
217 size_t notifications_to_add = | 219 size_t notifications_to_add = |
218 NotificationList::kMaxVisiblePopupNotifications + 1; | 220 NotificationList::kMaxVisiblePopupNotifications + 1; |
219 for (size_t i = 0; i < notifications_to_add; ++i) { | 221 for (size_t i = 0; i < notifications_to_add; ++i) { |
220 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 222 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
221 delegate->AddNotification(tray, id); | 223 delegate->AddNotification(tray, id); |
222 } | 224 } |
223 // Hide and reshow the bubble so that it is updated immediately, not delayed. | 225 // Hide and reshow the bubble so that it is updated immediately, not delayed. |
224 tray->SetHidePopupBubble(true); | 226 tray->SetHidePopupBubble(true); |
225 tray->SetHidePopupBubble(false); | 227 tray->SetHidePopupBubble(false); |
226 EXPECT_TRUE(tray->IsPopupVisible()); | 228 EXPECT_TRUE(tray->IsPopupVisible()); |
227 EXPECT_EQ(notifications_to_add, | 229 EXPECT_EQ(notifications_to_add, |
228 get_message_center()->NotificationCount()); | 230 get_message_center()->NotificationCount()); |
229 if (message_center::IsRichNotificationEnabled()) { | 231 if (message_center::IsRichNotificationEnabled()) { |
230 NotificationList::PopupNotifications popups = | 232 NotificationList::PopupNotifications popups = |
231 get_message_center()->notification_list()->GetPopupNotifications(); | 233 get_message_center()->notification_list()->GetPopupNotifications(); |
232 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); | 234 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); |
233 } else { | 235 } else { |
234 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, | 236 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, |
235 tray->GetPopupBubbleForTest()->NumMessageViewsForTest()); | 237 tray->GetPopupBubbleForTest()->NumMessageViewsForTest()); |
236 } | 238 } |
237 get_message_center()->SetDelegate(NULL); | 239 get_message_center()->SetDelegate(NULL); |
238 get_message_center()->notification_list()->RemoveAllNotifications(); | 240 get_message_center()->notification_list()->RemoveAllNotifications(); |
239 } | 241 } |
240 | 242 |
241 } // namespace ash | 243 } // namespace ash |
OLD | NEW |