| 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/views/message_center_view.h" | 5 #include "ui/message_center/views/message_center_view.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 GetMessageCenterView()->SetSettingsVisible(false); | 748 GetMessageCenterView()->SetSettingsVisible(false); |
| 749 EXPECT_EQ(Mode::NOTIFICATIONS, GetMessageCenterViewInternalMode()); | 749 EXPECT_EQ(Mode::NOTIFICATIONS, GetMessageCenterViewInternalMode()); |
| 750 } | 750 } |
| 751 | 751 |
| 752 TEST_F(MessageCenterViewTest, LockScreen) { | 752 TEST_F(MessageCenterViewTest, LockScreen) { |
| 753 const int kLockedMessageCenterViewHeight = 50; | 753 const int kLockedMessageCenterViewHeight = 50; |
| 754 | 754 |
| 755 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); | 755 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 756 EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn()); | 756 EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn()); |
| 757 | 757 |
| 758 views::Button* close_button = GetButtonBar()->GetCloseAllButtonForTest(); |
| 759 ASSERT_NE(nullptr, close_button); |
| 760 views::Button* quiet_mode_button = |
| 761 GetButtonBar()->GetQuietModeButtonForTest(); |
| 762 ASSERT_NE(nullptr, quiet_mode_button); |
| 763 views::Button* settings_button = GetButtonBar()->GetSettingsButtonForTest(); |
| 764 ASSERT_NE(nullptr, settings_button); |
| 765 |
| 766 EXPECT_TRUE(close_button->visible()); |
| 767 EXPECT_TRUE(quiet_mode_button->visible()); |
| 768 EXPECT_TRUE(settings_button->visible()); |
| 769 |
| 758 // Lock! | 770 // Lock! |
| 759 SetLockedState(true); | 771 SetLockedState(true); |
| 760 | 772 |
| 761 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); | 773 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 762 EXPECT_FALSE(GetNotificationView(kNotificationId2)->IsDrawn()); | 774 EXPECT_FALSE(GetNotificationView(kNotificationId2)->IsDrawn()); |
| 763 | 775 |
| 764 GetMessageCenterView()->SizeToPreferredSize(); | 776 GetMessageCenterView()->SizeToPreferredSize(); |
| 765 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); | 777 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 766 | 778 |
| 767 RemoveNotification(kNotificationId1, false); | 779 RemoveNotification(kNotificationId1, false); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 778 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), | 790 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), |
| 779 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), | 791 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), |
| 780 base::UTF8ToUTF16("display source"), GURL(), | 792 base::UTF8ToUTF16("display source"), GURL(), |
| 781 NotifierId(NotifierId::APPLICATION, "extension_id"), | 793 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 782 message_center::RichNotificationData(), nullptr)); | 794 message_center::RichNotificationData(), nullptr)); |
| 783 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); | 795 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 784 | 796 |
| 785 GetMessageCenterView()->SizeToPreferredSize(); | 797 GetMessageCenterView()->SizeToPreferredSize(); |
| 786 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); | 798 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 787 | 799 |
| 800 EXPECT_FALSE(close_button->visible()); |
| 801 EXPECT_FALSE(quiet_mode_button->visible()); |
| 802 EXPECT_FALSE(settings_button->visible()); |
| 803 |
| 788 // Unlock! | 804 // Unlock! |
| 789 SetLockedState(false); | 805 SetLockedState(false); |
| 790 | 806 |
| 791 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); | 807 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 792 | 808 |
| 793 GetMessageCenterView()->SizeToPreferredSize(); | 809 GetMessageCenterView()->SizeToPreferredSize(); |
| 794 EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); | 810 EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 795 | 811 |
| 812 EXPECT_TRUE(close_button->visible()); |
| 813 EXPECT_TRUE(quiet_mode_button->visible()); |
| 814 EXPECT_TRUE(settings_button->visible()); |
| 815 |
| 796 // Lock! | 816 // Lock! |
| 797 SetLockedState(true); | 817 SetLockedState(true); |
| 798 | 818 |
| 799 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); | 819 EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 800 | 820 |
| 801 GetMessageCenterView()->SizeToPreferredSize(); | 821 GetMessageCenterView()->SizeToPreferredSize(); |
| 802 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); | 822 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 823 |
| 824 EXPECT_FALSE(close_button->visible()); |
| 825 EXPECT_FALSE(quiet_mode_button->visible()); |
| 826 EXPECT_FALSE(settings_button->visible()); |
| 803 } | 827 } |
| 804 | 828 |
| 805 TEST_F(MessageCenterViewTest, NoNotification) { | 829 TEST_F(MessageCenterViewTest, NoNotification) { |
| 806 const int kEmptyMessageCenterViewHeight = 50; | 830 const int kEmptyMessageCenterViewHeight = 50; |
| 807 | 831 |
| 808 GetMessageCenterView()->SizeToPreferredSize(); | 832 GetMessageCenterView()->SizeToPreferredSize(); |
| 809 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 833 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 810 RemoveNotification(kNotificationId1, false); | 834 RemoveNotification(kNotificationId1, false); |
| 811 GetMessageCenterView()->SizeToPreferredSize(); | 835 GetMessageCenterView()->SizeToPreferredSize(); |
| 812 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 836 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 813 RemoveNotification(kNotificationId2, false); | 837 RemoveNotification(kNotificationId2, false); |
| 814 GetMessageCenterView()->SizeToPreferredSize(); | 838 GetMessageCenterView()->SizeToPreferredSize(); |
| 815 EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 839 EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 816 | 840 |
| 817 AddNotification(base::MakeUnique<Notification>( | 841 AddNotification(base::MakeUnique<Notification>( |
| 818 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), | 842 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), |
| 819 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), | 843 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), |
| 820 base::UTF8ToUTF16("display source"), GURL(), | 844 base::UTF8ToUTF16("display source"), GURL(), |
| 821 NotifierId(NotifierId::APPLICATION, "extension_id"), | 845 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 822 message_center::RichNotificationData(), nullptr)); | 846 message_center::RichNotificationData(), nullptr)); |
| 823 | 847 |
| 824 GetMessageCenterView()->SizeToPreferredSize(); | 848 GetMessageCenterView()->SizeToPreferredSize(); |
| 825 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 849 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 826 } | 850 } |
| 827 | 851 |
| 828 } // namespace message_center | 852 } // namespace message_center |
| OLD | NEW |