diff options
author | dewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 22:25:36 +0000 |
---|---|---|
committer | dewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 22:25:36 +0000 |
commit | 0f939daffbdbf70a3e1ec0ef61160761caa26d26 (patch) | |
tree | 22819d709db4294586591a6cb65d582314524a39 /ui/message_center | |
parent | 5719034d7aa91bf92da30af8e4aec156f8ef1de1 (diff) | |
download | chromium_src-0f939daffbdbf70a3e1ec0ef61160761caa26d26.zip chromium_src-0f939daffbdbf70a3e1ec0ef61160761caa26d26.tar.gz chromium_src-0f939daffbdbf70a3e1ec0ef61160761caa26d26.tar.bz2 |
Puts notification buttons back below the image
A regression caused buttons to be rendered above the image. This fixes
the problem by forcing the image to be the first child of the bottom
view (image is together with the buttons in the bottom view).
BUG=378077,368025
Review URL: https://codereview.chromium.org/305633004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274353 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center')
-rw-r--r-- | ui/message_center/views/notification_view.cc | 2 | ||||
-rw-r--r-- | ui/message_center/views/notification_view.h | 2 | ||||
-rw-r--r-- | ui/message_center/views/notification_view_unittest.cc | 43 |
3 files changed, 46 insertions, 1 deletions
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc index 3dc31bf..be77657 100644 --- a/ui/message_center/views/notification_view.cc +++ b/ui/message_center/views/notification_view.cc @@ -695,7 +695,7 @@ void NotificationView::CreateOrUpdateImageView( gfx::Size image_size(kNotificationPreferredImageWidth, kNotificationPreferredImageHeight); image_view_ = MakeNotificationImage(notification.image(), image_size); - bottom_view_->AddChildView(image_view_); + bottom_view_->AddChildViewAt(image_view_, 0); } } diff --git a/ui/message_center/views/notification_view.h b/ui/message_center/views/notification_view.h index 3e009d7..2d69131 100644 --- a/ui/message_center/views/notification_view.h +++ b/ui/message_center/views/notification_view.h @@ -76,6 +76,8 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView, FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); + friend class NotificationViewTest; + void CreateOrUpdateViews(const Notification& notification); void SetAccessibleName(const Notification& notification); diff --git a/ui/message_center/views/notification_view_unittest.cc b/ui/message_center/views/notification_view_unittest.cc index 596e9ae..b6d6752 100644 --- a/ui/message_center/views/notification_view_unittest.cc +++ b/ui/message_center/views/notification_view_unittest.cc @@ -66,6 +66,34 @@ class NotificationViewTest : public views::ViewsTestBase, return std::vector<ButtonInfo>(number, info); } + void CheckVerticalOrderInNotification() { + std::vector<views::View*> vertical_order; + vertical_order.push_back(notification_view()->top_view_); + vertical_order.push_back(notification_view()->image_view_); + std::copy(notification_view()->action_buttons_.begin(), + notification_view()->action_buttons_.end(), + std::back_inserter(vertical_order)); + std::vector<views::View*>::iterator current = vertical_order.begin(); + std::vector<views::View*>::iterator last = current++; + while (current != vertical_order.end()) { + gfx::Point last_point = (*last)->bounds().origin(); + views::View::ConvertPointToTarget( + (*last), notification_view(), &last_point); + + gfx::Point current_point = (*current)->bounds().origin(); + views::View::ConvertPointToTarget( + (*current), notification_view(), ¤t_point); + + EXPECT_LT(last_point.y(), current_point.y()); + last = current++; + } + } + + void UpdateNotificationViews() { + notification_view()->CreateOrUpdateViews(*notification()); + notification_view()->Layout(); + } + private: scoped_ptr<RichNotificationData> data_; scoped_ptr<Notification> notification_; @@ -277,4 +305,19 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) { EXPECT_TRUE(NULL == notification_view()->action_buttons_[0]->background()); } +TEST_F(NotificationViewTest, ViewOrderingTest) { + // Tests that views are created in the correct vertical order. + notification()->set_buttons(CreateButtons(2)); + + // Layout the initial views. + UpdateNotificationViews(); + + // Double-check that vertical order is correct. + CheckVerticalOrderInNotification(); + + // Tests that views remain in that order even after an update. + UpdateNotificationViews(); + CheckVerticalOrderInNotification(); +} + } // namespace message_center |