| Index: ui/message_center/views/notification_view_unittest.cc
|
| diff --git a/ui/message_center/views/notification_view_unittest.cc b/ui/message_center/views/notification_view_unittest.cc
|
| index 299a1068279aebdaf3ed195bcb96a83edd1eacd1..3e0ee88a8b823190b179ad9dd61d7a0a74dff054 100644
|
| --- a/ui/message_center/views/notification_view_unittest.cc
|
| +++ b/ui/message_center/views/notification_view_unittest.cc
|
| @@ -29,6 +29,8 @@
|
| #include "ui/message_center/views/message_center_controller.h"
|
| #include "ui/message_center/views/message_view_factory.h"
|
| #include "ui/message_center/views/notification_button.h"
|
| +#include "ui/message_center/views/notification_control_buttons_view.h"
|
| +#include "ui/message_center/views/padded_button.h"
|
| #include "ui/message_center/views/proportional_image_view.h"
|
| #include "ui/views/controls/button/image_button.h"
|
| #include "ui/views/layout/fill_layout.h"
|
| @@ -160,8 +162,14 @@
|
| }
|
| }
|
|
|
| - views::ImageButton* GetCloseButton() {
|
| - return notification_view()->close_button();
|
| + PaddedButton* GetCloseButton() {
|
| + return notification_view()
|
| + ->control_buttons_view_->close_button_for_testing();
|
| + }
|
| +
|
| + PaddedButton* GetSettingsButton() {
|
| + return notification_view()
|
| + ->control_buttons_view_->settings_button_for_testing();
|
| }
|
|
|
| void UpdateNotificationViews() {
|
| @@ -308,11 +316,16 @@
|
| notification()->set_message(base::ASCIIToUTF16(""));
|
| notification()->set_icon(gfx::Image());
|
|
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
| EXPECT_TRUE(NULL == notification_view()->title_view_);
|
| EXPECT_TRUE(NULL == notification_view()->message_view_);
|
| EXPECT_TRUE(NULL == notification_view()->image_view_);
|
| - EXPECT_TRUE(NULL == notification_view()->settings_button_view_);
|
| + // Notification must have a control buttons view.
|
| + EXPECT_TRUE(NULL != notification_view()->control_buttons_view_);
|
| + // Notification is not pinned and have a close button by default.
|
| + EXPECT_TRUE(NULL != GetCloseButton());
|
| + // Notification doesn't have a settings button by default.
|
| + EXPECT_TRUE(NULL == GetSettingsButton());
|
| // We still expect an icon view for all layouts.
|
| EXPECT_TRUE(NULL != notification_view()->icon_view_);
|
| }
|
| @@ -328,11 +341,12 @@
|
| NotifierId(NotifierId::APPLICATION, "extension_id"),
|
| *data(), delegate.get());
|
|
|
| - notification_view()->CreateOrUpdateViews(notf);
|
| + notification_view()->UpdateWithNotification(notf);
|
| EXPECT_TRUE(NULL != notification_view()->title_view_);
|
| EXPECT_TRUE(NULL != notification_view()->message_view_);
|
| EXPECT_TRUE(NULL != notification_view()->context_message_view_);
|
| - EXPECT_TRUE(NULL != notification_view()->settings_button_view_);
|
| + EXPECT_TRUE(NULL != GetCloseButton());
|
| + EXPECT_TRUE(NULL != GetSettingsButton());
|
| EXPECT_TRUE(NULL != notification_view()->icon_view_);
|
|
|
| EXPECT_TRUE(NULL == notification_view()->image_view_);
|
| @@ -341,21 +355,21 @@
|
| TEST_F(NotificationViewTest, TestLineLimits) {
|
| notification()->set_image(CreateTestImage(0, 0));
|
| notification()->set_context_message(base::ASCIIToUTF16(""));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
|
|
| EXPECT_EQ(5, notification_view()->GetMessageLineLimit(0, 360));
|
| EXPECT_EQ(5, notification_view()->GetMessageLineLimit(1, 360));
|
| EXPECT_EQ(3, notification_view()->GetMessageLineLimit(2, 360));
|
|
|
| notification()->set_image(CreateTestImage(2, 2));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
|
|
| EXPECT_EQ(2, notification_view()->GetMessageLineLimit(0, 360));
|
| EXPECT_EQ(2, notification_view()->GetMessageLineLimit(1, 360));
|
| EXPECT_EQ(1, notification_view()->GetMessageLineLimit(2, 360));
|
|
|
| notification()->set_context_message(base::ASCIIToUTF16("foo"));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
|
|
| EXPECT_TRUE(notification_view()->context_message_view_ != NULL);
|
|
|
| @@ -448,7 +462,7 @@
|
|
|
| TEST_F(NotificationViewTest, UpdateButtonsStateTest) {
|
| notification()->set_buttons(CreateButtons(2));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
| widget()->Show();
|
|
|
| EXPECT_EQ(views::CustomButton::STATE_NORMAL,
|
| @@ -466,7 +480,7 @@
|
| EXPECT_EQ(views::CustomButton::STATE_HOVERED,
|
| notification_view()->action_buttons_[0]->state());
|
|
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
|
|
| EXPECT_EQ(views::CustomButton::STATE_HOVERED,
|
| notification_view()->action_buttons_[0]->state());
|
| @@ -484,7 +498,7 @@
|
|
|
| TEST_F(NotificationViewTest, UpdateButtonCountTest) {
|
| notification()->set_buttons(CreateButtons(2));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
| widget()->Show();
|
|
|
| EXPECT_EQ(views::CustomButton::STATE_NORMAL,
|
| @@ -509,7 +523,7 @@
|
| notification_view()->action_buttons_[1]->state());
|
|
|
| notification()->set_buttons(CreateButtons(1));
|
| - notification_view()->CreateOrUpdateViews(*notification());
|
| + notification_view()->UpdateWithNotification(*notification());
|
|
|
| EXPECT_EQ(views::CustomButton::STATE_HOVERED,
|
| notification_view()->action_buttons_[0]->state());
|
| @@ -536,19 +550,16 @@
|
| GURL("https://hello.com"),
|
| NotifierId(NotifierId::APPLICATION, "extension_id"),
|
| *data(), delegate.get());
|
| - notification_view()->CreateOrUpdateViews(notf);
|
| + notification_view()->UpdateWithNotification(notf);
|
| widget()->Show();
|
| - notification_view()->Layout();
|
| -
|
| - EXPECT_TRUE(NULL != notification_view()->settings_button_view_);
|
| - EXPECT_EQ(views::CustomButton::STATE_NORMAL,
|
| - notification_view()->settings_button_view_->state());
|
| +
|
| + EXPECT_TRUE(NULL != GetSettingsButton());
|
| + EXPECT_EQ(views::CustomButton::STATE_NORMAL, GetSettingsButton()->state());
|
|
|
| // Now construct a mouse move event 1 pixel inside the boundary of the action
|
| // button.
|
| gfx::Point cursor_location(1, 1);
|
| - views::View::ConvertPointToScreen(notification_view()->settings_button_view_,
|
| - &cursor_location);
|
| + views::View::ConvertPointToScreen(GetSettingsButton(), &cursor_location);
|
| ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
|
| ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
|
| widget()->OnMouseEvent(&move);
|
| @@ -556,8 +567,7 @@
|
| views::test::WidgetTest::GetEventSink(widget())->OnEventFromSource(&move);
|
| EXPECT_FALSE(details.dispatcher_destroyed);
|
|
|
| - EXPECT_EQ(views::CustomButton::STATE_HOVERED,
|
| - notification_view()->settings_button_view_->state());
|
| + EXPECT_EQ(views::CustomButton::STATE_HOVERED, GetSettingsButton()->state());
|
|
|
| // Now construct a mouse move event 1 pixel outside the boundary of the
|
| // widget.
|
| @@ -566,8 +576,7 @@
|
| ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
|
| widget()->OnMouseEvent(&move);
|
|
|
| - EXPECT_EQ(views::CustomButton::STATE_NORMAL,
|
| - notification_view()->settings_button_view_->state());
|
| + EXPECT_EQ(views::CustomButton::STATE_NORMAL, GetSettingsButton()->state());
|
| }
|
|
|
| TEST_F(NotificationViewTest, ViewOrderingTest) {
|
|
|