Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: ui/message_center/views/notification_view_unittest.cc

Issue 2964973002: Use shared NotificationControlButtonsView for non-arc notification buttons (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b0e37ba290fd107f175618cbe63f295cdbaead13 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 @@ class NotificationViewTest : public views::ViewsTestBase,
}
}
- 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() {
@@ -312,7 +320,12 @@ TEST_F(NotificationViewTest, CreateOrUpdateTest) {
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_);
}
@@ -332,7 +345,8 @@ TEST_F(NotificationViewTest, CreateOrUpdateTestSettingsButton) {
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_);
@@ -540,15 +554,13 @@ TEST_F(NotificationViewTest, SettingsButtonTest) {
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 +568,7 @@ TEST_F(NotificationViewTest, SettingsButtonTest) {
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 +577,7 @@ TEST_F(NotificationViewTest, SettingsButtonTest) {
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) {
« ui/message_center/views/notification_view.cc ('K') | « ui/message_center/views/notification_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698