| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_center_impl.h" | 5 #include "ui/message_center/message_center_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 | 699 |
| 700 // Now try setting the icon to a different size. | 700 // Now try setting the icon to a different size. |
| 701 gfx::Size new_size(16, 16); | 701 gfx::Size new_size(16, 16); |
| 702 EXPECT_NE(original_size, new_size); | 702 EXPECT_NE(original_size, new_size); |
| 703 | 703 |
| 704 gfx::Canvas canvas(new_size, 1.0f, true); | 704 gfx::Canvas canvas(new_size, 1.0f, true); |
| 705 canvas.DrawColor(SK_ColorBLUE); | 705 canvas.DrawColor(SK_ColorBLUE); |
| 706 gfx::Image testImage(gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep()))); | 706 gfx::Image testImage(gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep()))); |
| 707 message_center()->SetNotificationIcon(id, testImage); | 707 message_center()->SetNotificationIcon(id, testImage); |
| 708 message_center()->SetNotificationImage(id, testImage); | 708 message_center()->SetNotificationImage(id, testImage); |
| 709 message_center()->SetNotificationSmallImage(id, testImage); |
| 709 message_center()->SetNotificationButtonIcon(id, 0, testImage); | 710 message_center()->SetNotificationButtonIcon(id, 0, testImage); |
| 710 message_center()->SetNotificationButtonIcon(id, 1, testImage); | 711 message_center()->SetNotificationButtonIcon(id, 1, testImage); |
| 711 | 712 |
| 712 // The notification should be in the queue. | 713 // The notification should be in the queue. |
| 713 EXPECT_FALSE(message_center()->HasNotification(id)); | 714 EXPECT_FALSE(message_center()->HasNotification(id)); |
| 714 | 715 |
| 715 // Close the message center; then the update should have propagated. | 716 // Close the message center; then the update should have propagated. |
| 716 message_center()->SetVisibility(VISIBILITY_TRANSIENT); | 717 message_center()->SetVisibility(VISIBILITY_TRANSIENT); |
| 717 // The notification should no longer be in the queue. | 718 // The notification should no longer be in the queue. |
| 718 EXPECT_TRUE(message_center()->HasNotification(id)); | 719 EXPECT_TRUE(message_center()->HasNotification(id)); |
| 719 | 720 |
| 720 Notification* mc_notification = | 721 Notification* mc_notification = |
| 721 *(message_center()->GetVisibleNotifications().begin()); | 722 *(message_center()->GetVisibleNotifications().begin()); |
| 722 const std::vector<ButtonInfo>& buttons = mc_notification->buttons(); | 723 const std::vector<ButtonInfo>& buttons = mc_notification->buttons(); |
| 723 ASSERT_EQ(2u, buttons.size()); | 724 ASSERT_EQ(2u, buttons.size()); |
| 724 | 725 |
| 725 EXPECT_EQ(new_size, mc_notification->icon().Size()); | 726 EXPECT_EQ(new_size, mc_notification->icon().Size()); |
| 726 EXPECT_EQ(new_size, mc_notification->image().Size()); | 727 EXPECT_EQ(new_size, mc_notification->image().Size()); |
| 728 EXPECT_EQ(new_size, mc_notification->small_image().Size()); |
| 727 EXPECT_EQ(new_size, buttons[0].icon.Size()); | 729 EXPECT_EQ(new_size, buttons[0].icon.Size()); |
| 728 EXPECT_EQ(new_size, buttons[1].icon.Size()); | 730 EXPECT_EQ(new_size, buttons[1].icon.Size()); |
| 729 } | 731 } |
| 730 | 732 |
| 731 TEST_F(MessageCenterImplTest, CachedUnreadCount) { | 733 TEST_F(MessageCenterImplTest, CachedUnreadCount) { |
| 732 message_center()->AddNotification( | 734 message_center()->AddNotification( |
| 733 scoped_ptr<Notification>(CreateSimpleNotification("id1"))); | 735 scoped_ptr<Notification>(CreateSimpleNotification("id1"))); |
| 734 message_center()->AddNotification( | 736 message_center()->AddNotification( |
| 735 scoped_ptr<Notification>(CreateSimpleNotification("id2"))); | 737 scoped_ptr<Notification>(CreateSimpleNotification("id2"))); |
| 736 message_center()->AddNotification( | 738 message_center()->AddNotification( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 755 } | 757 } |
| 756 EXPECT_EQ(3u, message_center()->UnreadNotificationCount()); | 758 EXPECT_EQ(3u, message_center()->UnreadNotificationCount()); |
| 757 | 759 |
| 758 // Opening the message center will reset the unread count. | 760 // Opening the message center will reset the unread count. |
| 759 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER); | 761 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER); |
| 760 EXPECT_EQ(0u, message_center()->UnreadNotificationCount()); | 762 EXPECT_EQ(0u, message_center()->UnreadNotificationCount()); |
| 761 } | 763 } |
| 762 | 764 |
| 763 } // namespace internal | 765 } // namespace internal |
| 764 } // namespace message_center | 766 } // namespace message_center |
| OLD | NEW |