Chromium Code Reviews| 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 596e9ae792829e27cb78fddbb808464bcc9b7e70..b6d67526905cfbf380fea2fcfb9e19ced3de8d41 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(); |
|
robliao
2014/05/30 01:19:33
This was CenterPoint before. Is origin a better me
dewittj
2014/06/02 18:00:05
It was easier for me to verify that they were in r
|
| + 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 |