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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 gfx::Image(), | 521 gfx::Image(), |
522 UTF8ToUTF16(kDisplaySource), | 522 UTF8ToUTF16(kDisplaySource), |
523 NotifierId(NotifierId::APPLICATION, | 523 NotifierId(NotifierId::APPLICATION, |
524 kExtensionId), | 524 kExtensionId), |
525 priority, | 525 priority, |
526 NULL)); | 526 NULL)); |
527 notification_list()->UpdateNotificationMessage(id1, notification.Pass()); | 527 notification_list()->UpdateNotificationMessage(id1, notification.Pass()); |
528 EXPECT_EQ(0u, GetPopupCounts()); | 528 EXPECT_EQ(0u, GetPopupCounts()); |
529 } | 529 } |
530 | 530 |
| 531 TEST_F(NotificationListTest, WebNotificationUpdatePromotion) { |
| 532 std::string notification_id = "replaced-web-notification"; |
| 533 scoped_ptr<Notification> original_notification( |
| 534 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 535 notification_id, |
| 536 UTF8ToUTF16("Web Notification"), |
| 537 UTF8ToUTF16("Notification contents"), |
| 538 gfx::Image(), |
| 539 UTF8ToUTF16(kDisplaySource), |
| 540 NotifierId(GURL("https://example.com/")), |
| 541 message_center::RichNotificationData(), |
| 542 NULL)); |
| 543 |
| 544 EXPECT_EQ(0u, GetPopupCounts()); |
| 545 notification_list()->AddNotification(original_notification.Pass()); |
| 546 EXPECT_EQ(1u, GetPopupCounts()); |
| 547 |
| 548 notification_list()->MarkSinglePopupAsShown(notification_id, true); |
| 549 EXPECT_EQ(0u, GetPopupCounts()); |
| 550 |
| 551 scoped_ptr<Notification> replaced_notification( |
| 552 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 553 notification_id, |
| 554 UTF8ToUTF16("Web Notification Replacement"), |
| 555 UTF8ToUTF16("New notification contents"), |
| 556 gfx::Image(), |
| 557 UTF8ToUTF16(kDisplaySource), |
| 558 NotifierId(GURL("https://example.com/")), |
| 559 message_center::RichNotificationData(), |
| 560 NULL)); |
| 561 |
| 562 // Web Notifications will be re-shown as popups even if their priority didn't |
| 563 // change, to match the behavior of the Web Notification API. |
| 564 notification_list()->UpdateNotificationMessage(notification_id, |
| 565 replaced_notification.Pass()); |
| 566 EXPECT_EQ(1u, GetPopupCounts()); |
| 567 } |
| 568 |
531 TEST_F(NotificationListTest, NotificationOrderAndPriority) { | 569 TEST_F(NotificationListTest, NotificationOrderAndPriority) { |
532 base::Time now = base::Time::Now(); | 570 base::Time now = base::Time::Now(); |
533 message_center::RichNotificationData optional; | 571 message_center::RichNotificationData optional; |
534 optional.timestamp = now; | 572 optional.timestamp = now; |
535 optional.priority = 2; | 573 optional.priority = 2; |
536 std::string max_id = AddNotification(optional); | 574 std::string max_id = AddNotification(optional); |
537 | 575 |
538 now += base::TimeDelta::FromSeconds(1); | 576 now += base::TimeDelta::FromSeconds(1); |
539 optional.timestamp = now; | 577 optional.timestamp = now; |
540 optional.priority = 1; | 578 optional.priority = 1; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 NULL)); | 751 NULL)); |
714 notification_list()->AddNotification(updated_notification.Pass()); | 752 notification_list()->AddNotification(updated_notification.Pass()); |
715 | 753 |
716 EXPECT_FALSE(notification_list()->HasNotificationOfType( | 754 EXPECT_FALSE(notification_list()->HasNotificationOfType( |
717 id, message_center::NOTIFICATION_TYPE_SIMPLE)); | 755 id, message_center::NOTIFICATION_TYPE_SIMPLE)); |
718 EXPECT_TRUE(notification_list()->HasNotificationOfType( | 756 EXPECT_TRUE(notification_list()->HasNotificationOfType( |
719 id, message_center::NOTIFICATION_TYPE_PROGRESS)); | 757 id, message_center::NOTIFICATION_TYPE_PROGRESS)); |
720 } | 758 } |
721 | 759 |
722 } // namespace message_center | 760 } // namespace message_center |
OLD | NEW |