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 "ui/message_center/notification_list.h" | 5 #include "ui/message_center/notification_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 AddNotification(); | 155 AddNotification(); |
156 EXPECT_EQ(2u, notification_list()->NotificationCount(blockers())); | 156 EXPECT_EQ(2u, notification_list()->NotificationCount(blockers())); |
157 } | 157 } |
158 | 158 |
159 TEST_F(NotificationListTest, MessageCenterVisible) { | 159 TEST_F(NotificationListTest, MessageCenterVisible) { |
160 AddNotification(); | 160 AddNotification(); |
161 EXPECT_EQ(1u, notification_list()->NotificationCount(blockers())); | 161 EXPECT_EQ(1u, notification_list()->NotificationCount(blockers())); |
162 ASSERT_EQ(1u, notification_list()->UnreadCount(blockers())); | 162 ASSERT_EQ(1u, notification_list()->UnreadCount(blockers())); |
163 ASSERT_EQ(1u, GetPopupCounts()); | 163 ASSERT_EQ(1u, GetPopupCounts()); |
164 | 164 |
165 // Make the message center visible. It resets the unread count and popup | 165 // Resets the unread count and popup counts. |
166 // counts. | 166 notification_list()->SetNotificationsShown(blockers(), NULL); |
167 notification_list()->SetMessageCenterVisible(true, NULL); | |
168 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); | 167 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); |
169 ASSERT_EQ(0u, GetPopupCounts()); | 168 ASSERT_EQ(0u, GetPopupCounts()); |
170 } | 169 } |
171 | 170 |
172 TEST_F(NotificationListTest, UnreadCount) { | 171 TEST_F(NotificationListTest, UnreadCount) { |
173 std::string id0 = AddNotification(); | 172 std::string id0 = AddNotification(); |
174 std::string id1 = AddNotification(); | 173 std::string id1 = AddNotification(); |
175 ASSERT_EQ(2u, notification_list()->UnreadCount(blockers())); | 174 ASSERT_EQ(2u, notification_list()->UnreadCount(blockers())); |
176 | 175 |
177 notification_list()->MarkSinglePopupAsDisplayed(id0); | 176 notification_list()->MarkSinglePopupAsDisplayed(id0); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); | 301 ASSERT_EQ(0u, notification_list()->UnreadCount(blockers())); |
303 | 302 |
304 // Default priority has the limit on the number of the popups. | 303 // Default priority has the limit on the number of the popups. |
305 for (size_t i = 0; i <= kMaxVisiblePopupNotifications; ++i) | 304 for (size_t i = 0; i <= kMaxVisiblePopupNotifications; ++i) |
306 AddNotification(); | 305 AddNotification(); |
307 EXPECT_EQ(kMaxVisiblePopupNotifications + 1, | 306 EXPECT_EQ(kMaxVisiblePopupNotifications + 1, |
308 notification_list()->NotificationCount(blockers())); | 307 notification_list()->NotificationCount(blockers())); |
309 EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts()); | 308 EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts()); |
310 | 309 |
311 // Low priority: not visible to popups. | 310 // Low priority: not visible to popups. |
312 notification_list()->SetMessageCenterVisible(true, NULL); | 311 notification_list()->SetNotificationsShown(blockers(), NULL); |
313 notification_list()->SetMessageCenterVisible(false, NULL); | |
314 EXPECT_EQ(0u, notification_list()->UnreadCount(blockers())); | 312 EXPECT_EQ(0u, notification_list()->UnreadCount(blockers())); |
315 AddPriorityNotification(LOW_PRIORITY); | 313 AddPriorityNotification(LOW_PRIORITY); |
316 EXPECT_EQ(kMaxVisiblePopupNotifications + 2, | 314 EXPECT_EQ(kMaxVisiblePopupNotifications + 2, |
317 notification_list()->NotificationCount(blockers())); | 315 notification_list()->NotificationCount(blockers())); |
318 EXPECT_EQ(1u, notification_list()->UnreadCount(blockers())); | 316 EXPECT_EQ(1u, notification_list()->UnreadCount(blockers())); |
319 EXPECT_EQ(0u, GetPopupCounts()); | 317 EXPECT_EQ(0u, GetPopupCounts()); |
320 | 318 |
321 // Minimum priority: doesn't update the unread count. | 319 // Minimum priority: doesn't update the unread count. |
322 AddPriorityNotification(MIN_PRIORITY); | 320 AddPriorityNotification(MIN_PRIORITY); |
323 EXPECT_EQ(kMaxVisiblePopupNotifications + 3, | 321 EXPECT_EQ(kMaxVisiblePopupNotifications + 3, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 GetNotification(system_id)->SetSystemPriority(); | 359 GetNotification(system_id)->SetSystemPriority(); |
362 | 360 |
363 EXPECT_EQ(2u, GetPopupCounts()); | 361 EXPECT_EQ(2u, GetPopupCounts()); |
364 | 362 |
365 notification_list()->MarkSinglePopupAsDisplayed(normal_id); | 363 notification_list()->MarkSinglePopupAsDisplayed(normal_id); |
366 notification_list()->MarkSinglePopupAsDisplayed(system_id); | 364 notification_list()->MarkSinglePopupAsDisplayed(system_id); |
367 | 365 |
368 notification_list()->MarkSinglePopupAsShown(normal_id, false); | 366 notification_list()->MarkSinglePopupAsShown(normal_id, false); |
369 notification_list()->MarkSinglePopupAsShown(system_id, false); | 367 notification_list()->MarkSinglePopupAsShown(system_id, false); |
370 | 368 |
371 notification_list()->SetMessageCenterVisible(true, NULL); | 369 notification_list()->SetNotificationsShown(blockers(), NULL); |
372 notification_list()->SetMessageCenterVisible(false, NULL); | |
373 EXPECT_EQ(1u, GetPopupCounts()); | 370 EXPECT_EQ(1u, GetPopupCounts()); |
374 | 371 |
375 // Mark as read -- emulation of mouse click. | 372 // Mark as read -- emulation of mouse click. |
376 notification_list()->MarkSinglePopupAsShown(system_id, true); | 373 notification_list()->MarkSinglePopupAsShown(system_id, true); |
377 EXPECT_EQ(0u, GetPopupCounts()); | 374 EXPECT_EQ(0u, GetPopupCounts()); |
378 } | 375 } |
379 | 376 |
380 TEST_F(NotificationListTest, PriorityPromotion) { | 377 TEST_F(NotificationListTest, PriorityPromotion) { |
381 std::string id0 = AddPriorityNotification(LOW_PRIORITY); | 378 std::string id0 = AddPriorityNotification(LOW_PRIORITY); |
382 std::string replaced = id0 + "_replaced"; | 379 std::string replaced = id0 + "_replaced"; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 NotifierId(), RichNotificationData(), NULL)); | 659 NotifierId(), RichNotificationData(), NULL)); |
663 notification_list()->AddNotification(std::move(updated_notification)); | 660 notification_list()->AddNotification(std::move(updated_notification)); |
664 | 661 |
665 EXPECT_FALSE(notification_list()->HasNotificationOfType( | 662 EXPECT_FALSE(notification_list()->HasNotificationOfType( |
666 id, message_center::NOTIFICATION_TYPE_SIMPLE)); | 663 id, message_center::NOTIFICATION_TYPE_SIMPLE)); |
667 EXPECT_TRUE(notification_list()->HasNotificationOfType( | 664 EXPECT_TRUE(notification_list()->HasNotificationOfType( |
668 id, message_center::NOTIFICATION_TYPE_PROGRESS)); | 665 id, message_center::NOTIFICATION_TYPE_PROGRESS)); |
669 } | 666 } |
670 | 667 |
671 } // namespace message_center | 668 } // namespace message_center |
OLD | NEW |