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..b2a613fbf8ae837f6b6fa87549b18bb2c06e1ab0 100644 |
| --- a/ui/message_center/views/notification_view_unittest.cc |
| +++ b/ui/message_center/views/notification_view_unittest.cc |
| @@ -277,4 +277,53 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) { |
| EXPECT_TRUE(NULL == notification_view()->action_buttons_[0]->background()); |
| } |
| +TEST_F(NotificationViewTest, ViewOrderingTest) { |
| + // Tests that views remain in the correct order even after an update. |
| + notification()->set_buttons(CreateButtons(2)); |
| + // Layout the initial views. |
| + notification_view()->CreateOrUpdateViews(*notification()); |
| + widget()->Show(); |
| + |
| + 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 last = vertical_order.begin(); |
| + std::vector<views::View*>::iterator current = last; |
| + ++current; |
| + while (current != vertical_order.end()) { |
| + gfx::Point last_point = (*last)->bounds().CenterPoint(); |
| + views::View::ConvertPointToTarget( |
| + (*last), notification_view(), &last_point); |
| + |
| + gfx::Point current_point = (*current)->bounds().CenterPoint(); |
| + views::View::ConvertPointToTarget( |
| + (*current), notification_view(), ¤t_point); |
| + |
| + EXPECT_LT(last_point.y(), current_point.y()); |
| + last = current++; |
| + } |
| + |
| + notification_view()->CreateOrUpdateViews(*notification()); |
|
robliao
2014/05/28 17:55:48
Seems like we're repeating what we just tested. Wh
dewittj
2014/05/28 18:59:04
The bug only repros when createorupdateviews is ca
robliao
2014/05/28 19:29:05
Let's put a note about that here before this gets
dewittj
2014/05/30 00:44:36
Done.
|
| + |
| + last = vertical_order.begin(); |
| + current = last; |
| + ++current; |
| + while (current != vertical_order.end()) { |
| + gfx::Point last_point = (*last)->bounds().CenterPoint(); |
| + views::View::ConvertPointToTarget( |
| + (*last), notification_view(), &last_point); |
| + |
| + gfx::Point current_point = (*current)->bounds().CenterPoint(); |
| + views::View::ConvertPointToTarget( |
| + (*current), notification_view(), ¤t_point); |
| + |
| + EXPECT_LT(last_point.y(), current_point.y()); |
| + last = current++; |
| + } |
| +} |
| + |
| } // namespace message_center |