Commit 0f939daf authored by dewittj@chromium.org's avatar dewittj@chromium.org

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
parent 5719034d
...@@ -695,7 +695,7 @@ void NotificationView::CreateOrUpdateImageView( ...@@ -695,7 +695,7 @@ void NotificationView::CreateOrUpdateImageView(
gfx::Size image_size(kNotificationPreferredImageWidth, gfx::Size image_size(kNotificationPreferredImageWidth,
kNotificationPreferredImageHeight); kNotificationPreferredImageHeight);
image_view_ = MakeNotificationImage(notification.image(), image_size); image_view_ = MakeNotificationImage(notification.image(), image_size);
bottom_view_->AddChildView(image_view_); bottom_view_->AddChildViewAt(image_view_, 0);
} }
} }
......
...@@ -76,6 +76,8 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView, ...@@ -76,6 +76,8 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView,
FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest);
FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest);
friend class NotificationViewTest;
void CreateOrUpdateViews(const Notification& notification); void CreateOrUpdateViews(const Notification& notification);
void SetAccessibleName(const Notification& notification); void SetAccessibleName(const Notification& notification);
......
...@@ -66,6 +66,34 @@ class NotificationViewTest : public views::ViewsTestBase, ...@@ -66,6 +66,34 @@ class NotificationViewTest : public views::ViewsTestBase,
return std::vector<ButtonInfo>(number, info); 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(), &current_point);
EXPECT_LT(last_point.y(), current_point.y());
last = current++;
}
}
void UpdateNotificationViews() {
notification_view()->CreateOrUpdateViews(*notification());
notification_view()->Layout();
}
private: private:
scoped_ptr<RichNotificationData> data_; scoped_ptr<RichNotificationData> data_;
scoped_ptr<Notification> notification_; scoped_ptr<Notification> notification_;
...@@ -277,4 +305,19 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) { ...@@ -277,4 +305,19 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) {
EXPECT_TRUE(NULL == notification_view()->action_buttons_[0]->background()); 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 } // namespace message_center
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment