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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_EQ(0u, notification_list()->unread_count()); | 129 EXPECT_EQ(0u, notification_list()->unread_count()); |
130 } | 130 } |
131 | 131 |
132 TEST_F(NotificationListTest, MessageCenterVisible) { | 132 TEST_F(NotificationListTest, MessageCenterVisible) { |
133 AddNotification(NULL); | 133 AddNotification(NULL); |
134 EXPECT_EQ(1u, notification_list()->NotificationCount()); | 134 EXPECT_EQ(1u, notification_list()->NotificationCount()); |
135 ASSERT_EQ(1u, notification_list()->unread_count()); | 135 ASSERT_EQ(1u, notification_list()->unread_count()); |
136 | 136 |
137 // Toggle the message center visibility. It resets the unread count when | 137 // Toggle the message center visibility. It resets the unread count when |
138 // hidden. | 138 // hidden. |
139 notification_list()->SetMessageCenterVisible(true); | 139 notification_list()->SetMessageCenterVisible(true, NULL); |
140 ASSERT_EQ(1u, notification_list()->unread_count()); | 140 ASSERT_EQ(1u, notification_list()->unread_count()); |
141 notification_list()->SetMessageCenterVisible(false); | 141 notification_list()->SetMessageCenterVisible(false, NULL); |
142 ASSERT_EQ(0u, notification_list()->unread_count()); | 142 ASSERT_EQ(0u, notification_list()->unread_count()); |
143 } | 143 } |
144 | 144 |
145 TEST_F(NotificationListTest, UpdateNotification) { | 145 TEST_F(NotificationListTest, UpdateNotification) { |
146 std::string id0 = AddNotification(NULL); | 146 std::string id0 = AddNotification(NULL); |
147 std::string replaced = id0 + "_replaced"; | 147 std::string replaced = id0 + "_replaced"; |
148 EXPECT_EQ(1u, notification_list()->NotificationCount()); | 148 EXPECT_EQ(1u, notification_list()->NotificationCount()); |
149 notification_list()->UpdateNotificationMessage( | 149 notification_list()->UpdateNotificationMessage( |
150 id0, replaced, UTF8ToUTF16("newtitle"), UTF8ToUTF16("newbody"), NULL); | 150 id0, replaced, UTF8ToUTF16("newtitle"), UTF8ToUTF16("newbody"), NULL); |
151 EXPECT_EQ(1u, notification_list()->NotificationCount()); | 151 EXPECT_EQ(1u, notification_list()->NotificationCount()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // Default priority has the limit on the number of the popups. | 219 // Default priority has the limit on the number of the popups. |
220 for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications; | 220 for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications; |
221 ++i) { | 221 ++i) { |
222 AddNotification(NULL); | 222 AddNotification(NULL); |
223 } | 223 } |
224 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 1, | 224 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 1, |
225 notification_list()->NotificationCount()); | 225 notification_list()->NotificationCount()); |
226 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, GetPopupCounts()); | 226 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, GetPopupCounts()); |
227 | 227 |
228 // Low priority: not visible to popups. | 228 // Low priority: not visible to popups. |
229 notification_list()->SetMessageCenterVisible(true); | 229 notification_list()->SetMessageCenterVisible(true, NULL); |
230 notification_list()->SetMessageCenterVisible(false); | 230 notification_list()->SetMessageCenterVisible(false, NULL); |
231 EXPECT_EQ(0u, notification_list()->unread_count()); | 231 EXPECT_EQ(0u, notification_list()->unread_count()); |
232 AddPriorityNotification(-1); | 232 AddPriorityNotification(-1); |
233 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 2, | 233 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 2, |
234 notification_list()->NotificationCount()); | 234 notification_list()->NotificationCount()); |
235 EXPECT_EQ(1u, notification_list()->unread_count()); | 235 EXPECT_EQ(1u, notification_list()->unread_count()); |
236 EXPECT_EQ(0u, GetPopupCounts()); | 236 EXPECT_EQ(0u, GetPopupCounts()); |
237 | 237 |
238 // Minimum priority: doesn't update the unread count. | 238 // Minimum priority: doesn't update the unread count. |
239 AddPriorityNotification(-2); | 239 AddPriorityNotification(-2); |
240 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 3, | 240 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 3, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 notification_list()->SetQuietMode(false); | 433 notification_list()->SetQuietMode(false); |
434 AddNotification(NULL); | 434 AddNotification(NULL); |
435 EXPECT_EQ(4u, notification_list()->NotificationCount()); | 435 EXPECT_EQ(4u, notification_list()->NotificationCount()); |
436 EXPECT_EQ(1u, GetPopupCounts()); | 436 EXPECT_EQ(1u, GetPopupCounts()); |
437 | 437 |
438 // TODO(mukai): Add test of quiet mode with expiration. | 438 // TODO(mukai): Add test of quiet mode with expiration. |
439 } | 439 } |
440 | 440 |
441 } // namespace test | 441 } // namespace test |
442 } // namespace message_center | 442 } // namespace message_center |
OLD | NEW |