| 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 RemoveNotification(kNotificationId1, false); | 571 RemoveNotification(kNotificationId1, false); |
| 572 | 572 |
| 573 // Wait until the animation finishes if available. | 573 // Wait until the animation finishes if available. |
| 574 if (GetAnimator()->IsAnimating()) | 574 if (GetAnimator()->IsAnimating()) |
| 575 base::RunLoop().Run(); | 575 base::RunLoop().Run(); |
| 576 | 576 |
| 577 EXPECT_EQ(1, GetMessageListView()->child_count()); | 577 EXPECT_EQ(1, GetMessageListView()->child_count()); |
| 578 | 578 |
| 579 EXPECT_FALSE(GetNotificationView(kNotificationId1)); | 579 EXPECT_FALSE(GetNotificationView(kNotificationId1)); |
| 580 EXPECT_TRUE(GetNotificationView(kNotificationId2)); | 580 EXPECT_TRUE(GetNotificationView(kNotificationId2)); |
| 581 EXPECT_EQ(GetMessageListView()->height(), original_height); | 581 EXPECT_EQ(original_height, GetMessageListView()->height()); |
| 582 } | 582 } |
| 583 | 583 |
| 584 TEST_F(MessageCenterViewTest, PositionAfterUpdate) { | 584 TEST_F(MessageCenterViewTest, PositionAfterUpdate) { |
| 585 // Make sure that the notification 2 is placed above the notification 1. | 585 // Make sure that the notification 2 is placed above the notification 1. |
| 586 EXPECT_LT(GetNotificationView(kNotificationId2)->bounds().y(), | 586 EXPECT_LT(GetNotificationView(kNotificationId2)->bounds().y(), |
| 587 GetNotificationView(kNotificationId1)->bounds().y()); | 587 GetNotificationView(kNotificationId1)->bounds().y()); |
| 588 | 588 |
| 589 int previous_vertical_pos_from_bottom = | 589 int previous_vertical_pos_from_bottom = |
| 590 GetMessageListView()->height() - | 590 GetMessageListView()->height() - |
| 591 GetNotificationView(kNotificationId1)->bounds().y(); | 591 GetNotificationView(kNotificationId1)->bounds().y(); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 NotifierId(NotifierId::APPLICATION, "extension_id"), | 844 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 845 message_center::RichNotificationData(), nullptr)); | 845 message_center::RichNotificationData(), nullptr)); |
| 846 EXPECT_EQ(Mode::SETTINGS, GetMessageCenterViewInternalMode()); | 846 EXPECT_EQ(Mode::SETTINGS, GetMessageCenterViewInternalMode()); |
| 847 | 847 |
| 848 // Hide the settings. | 848 // Hide the settings. |
| 849 GetMessageCenterView()->SetSettingsVisible(false); | 849 GetMessageCenterView()->SetSettingsVisible(false); |
| 850 EXPECT_EQ(Mode::NOTIFICATIONS, GetMessageCenterViewInternalMode()); | 850 EXPECT_EQ(Mode::NOTIFICATIONS, GetMessageCenterViewInternalMode()); |
| 851 } | 851 } |
| 852 | 852 |
| 853 TEST_F(MessageCenterViewTest, LockScreen) { | 853 TEST_F(MessageCenterViewTest, LockScreen) { |
| 854 const int kLockedMessageCenterViewHeight = 50; | 854 const int kLockedMessageCenterViewHeight = 51; |
| 855 | 855 |
| 856 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); | 856 EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); |
| 857 EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn()); | 857 EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn()); |
| 858 | 858 |
| 859 views::Button* close_button = GetButtonBar()->GetCloseAllButtonForTest(); | 859 views::Button* close_button = GetButtonBar()->GetCloseAllButtonForTest(); |
| 860 ASSERT_NE(nullptr, close_button); | 860 ASSERT_NE(nullptr, close_button); |
| 861 views::Button* quiet_mode_button = | 861 views::Button* quiet_mode_button = |
| 862 GetButtonBar()->GetQuietModeButtonForTest(); | 862 GetButtonBar()->GetQuietModeButtonForTest(); |
| 863 ASSERT_NE(nullptr, quiet_mode_button); | 863 ASSERT_NE(nullptr, quiet_mode_button); |
| 864 views::Button* settings_button = GetButtonBar()->GetSettingsButtonForTest(); | 864 views::Button* settings_button = GetButtonBar()->GetSettingsButtonForTest(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 | 921 |
| 922 GetMessageCenterView()->SizeToPreferredSize(); | 922 GetMessageCenterView()->SizeToPreferredSize(); |
| 923 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); | 923 EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 924 | 924 |
| 925 EXPECT_FALSE(close_button->visible()); | 925 EXPECT_FALSE(close_button->visible()); |
| 926 EXPECT_FALSE(quiet_mode_button->visible()); | 926 EXPECT_FALSE(quiet_mode_button->visible()); |
| 927 EXPECT_FALSE(settings_button->visible()); | 927 EXPECT_FALSE(settings_button->visible()); |
| 928 } | 928 } |
| 929 | 929 |
| 930 TEST_F(MessageCenterViewTest, NoNotification) { | 930 TEST_F(MessageCenterViewTest, NoNotification) { |
| 931 const int kEmptyMessageCenterViewHeight = 50; | 931 const int kEmptyMessageCenterViewHeight = 51; |
| 932 | 932 |
| 933 GetMessageCenterView()->SizeToPreferredSize(); | 933 GetMessageCenterView()->SizeToPreferredSize(); |
| 934 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 934 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 935 RemoveNotification(kNotificationId1, false); | 935 RemoveNotification(kNotificationId1, false); |
| 936 GetMessageCenterView()->SizeToPreferredSize(); | 936 GetMessageCenterView()->SizeToPreferredSize(); |
| 937 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 937 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 938 RemoveNotification(kNotificationId2, false); | 938 RemoveNotification(kNotificationId2, false); |
| 939 GetMessageCenterView()->SizeToPreferredSize(); | 939 GetMessageCenterView()->SizeToPreferredSize(); |
| 940 EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 940 EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 941 | 941 |
| 942 AddNotification(base::MakeUnique<Notification>( | 942 AddNotification(base::MakeUnique<Notification>( |
| 943 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), | 943 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), |
| 944 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), | 944 base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(), |
| 945 base::UTF8ToUTF16("display source"), GURL(), | 945 base::UTF8ToUTF16("display source"), GURL(), |
| 946 NotifierId(NotifierId::APPLICATION, "extension_id"), | 946 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 947 message_center::RichNotificationData(), nullptr)); | 947 message_center::RichNotificationData(), nullptr)); |
| 948 | 948 |
| 949 GetMessageCenterView()->SizeToPreferredSize(); | 949 GetMessageCenterView()->SizeToPreferredSize(); |
| 950 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); | 950 EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); |
| 951 } | 951 } |
| 952 | 952 |
| 953 } // namespace message_center | 953 } // namespace message_center |
| OLD | NEW |