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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 notification_list()->GetNotifications(¬ifications); | 310 notification_list()->GetNotifications(¬ifications); |
311 EXPECT_EQ(3u, notifications.size()); | 311 EXPECT_EQ(3u, notifications.size()); |
312 iter = notifications.begin(); | 312 iter = notifications.begin(); |
313 EXPECT_EQ(max_id, iter->id); | 313 EXPECT_EQ(max_id, iter->id); |
314 iter++; | 314 iter++; |
315 EXPECT_EQ(high_id, iter->id); | 315 EXPECT_EQ(high_id, iter->id); |
316 iter++; | 316 iter++; |
317 EXPECT_EQ(default_id, iter->id); | 317 EXPECT_EQ(default_id, iter->id); |
318 } | 318 } |
319 | 319 |
| 320 TEST_F(NotificationListTest, MarkSinglePopupAsShown) { |
| 321 std::string id1 = AddNotification(NULL); |
| 322 std::string id2 = AddNotification(NULL); |
| 323 ASSERT_EQ(2u, notification_list()->NotificationCount()); |
| 324 ASSERT_EQ(2u, GetPopupCounts()); |
| 325 |
| 326 notification_list()->MarkSinglePopupAsShown(id2); |
| 327 EXPECT_EQ(2u, notification_list()->NotificationCount()); |
| 328 EXPECT_EQ(1u, GetPopupCounts()); |
| 329 NotificationList::Notifications popups; |
| 330 notification_list()->GetPopupNotifications(&popups); |
| 331 EXPECT_EQ(id1, popups.begin()->id); |
| 332 |
| 333 // Reorder happens -- popup-notifications should be at the beginning of the |
| 334 // list. |
| 335 // TODO(mukai): confirm this behavior is expected. |
| 336 NotificationList::Notifications notifications; |
| 337 notification_list()->GetNotifications(¬ifications); |
| 338 NotificationList::Notifications::const_iterator iter = notifications.begin(); |
| 339 EXPECT_EQ(id1, iter->id); |
| 340 iter++; |
| 341 EXPECT_EQ(id2, iter->id); |
| 342 |
| 343 // Trickier scenario. |
| 344 notification_list()->MarkPopupsAsShown(ui::notifications::DEFAULT_PRIORITY); |
| 345 std::string id3 = AddNotification(NULL); |
| 346 std::string id4 = AddNotification(NULL); |
| 347 std::string id5 = AddNotification(NULL); |
| 348 notification_list()->MarkSinglePopupAsShown(id4); |
| 349 popups.clear(); |
| 350 notifications.clear(); |
| 351 notification_list()->GetPopupNotifications(&popups); |
| 352 notification_list()->GetNotifications(¬ifications); |
| 353 EXPECT_EQ(2u, popups.size()); |
| 354 iter = popups.begin(); |
| 355 EXPECT_EQ(id5, iter->id); |
| 356 iter++; |
| 357 EXPECT_EQ(id3, iter->id); |
| 358 EXPECT_EQ(5u, notifications.size()); |
| 359 iter = notifications.begin(); |
| 360 EXPECT_EQ(id5, iter->id); |
| 361 iter++; |
| 362 EXPECT_EQ(id3, iter->id); |
| 363 iter++; |
| 364 EXPECT_EQ(id4, iter->id); |
| 365 iter++; |
| 366 EXPECT_EQ(id1, iter->id); |
| 367 iter++; |
| 368 EXPECT_EQ(id2, iter->id); |
| 369 } |
| 370 |
320 TEST_F(NotificationListTest, QuietMode) { | 371 TEST_F(NotificationListTest, QuietMode) { |
321 notification_list()->SetQuietMode(true); | 372 notification_list()->SetQuietMode(true); |
322 AddNotification(NULL); | 373 AddNotification(NULL); |
323 AddPriorityNotification(1); | 374 AddPriorityNotification(1); |
324 AddPriorityNotification(2); | 375 AddPriorityNotification(2); |
325 EXPECT_EQ(3u, notification_list()->NotificationCount()); | 376 EXPECT_EQ(3u, notification_list()->NotificationCount()); |
326 EXPECT_EQ(0u, GetPopupCounts()); | 377 EXPECT_EQ(0u, GetPopupCounts()); |
327 // TODO(mukai): fix here when notification_list distinguish dismiss by quiet | 378 // TODO(mukai): fix here when notification_list distinguish dismiss by quiet |
328 // mode and by user operation. | 379 // mode and by user operation. |
329 EXPECT_EQ(0u, notification_list()->unread_count()); | 380 EXPECT_EQ(0u, notification_list()->unread_count()); |
330 | 381 |
331 notification_list()->SetQuietMode(false); | 382 notification_list()->SetQuietMode(false); |
332 AddNotification(NULL); | 383 AddNotification(NULL); |
333 EXPECT_EQ(4u, notification_list()->NotificationCount()); | 384 EXPECT_EQ(4u, notification_list()->NotificationCount()); |
334 EXPECT_EQ(1u, GetPopupCounts()); | 385 EXPECT_EQ(1u, GetPopupCounts()); |
335 | 386 |
336 // TODO(mukai): Add test of quiet mode with expiration. | 387 // TODO(mukai): Add test of quiet mode with expiration. |
337 } | 388 } |
338 | 389 |
339 } // namespace message_center | 390 } // namespace message_center |
OLD | NEW |