Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, | 270 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, |
| 271 cursor_location, | 271 cursor_location, |
| 272 cursor_location, | 272 cursor_location, |
| 273 ui::EF_NONE, | 273 ui::EF_NONE, |
| 274 ui::EF_NONE); | 274 ui::EF_NONE); |
| 275 widget()->OnMouseEvent(&move); | 275 widget()->OnMouseEvent(&move); |
| 276 | 276 |
| 277 EXPECT_TRUE(NULL == notification_view()->action_buttons_[0]->background()); | 277 EXPECT_TRUE(NULL == notification_view()->action_buttons_[0]->background()); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(NotificationViewTest, ViewOrderingTest) { | |
| 281 // Tests that views remain in the correct order even after an update. | |
| 282 notification()->set_buttons(CreateButtons(2)); | |
| 283 // Layout the initial views. | |
| 284 notification_view()->CreateOrUpdateViews(*notification()); | |
| 285 widget()->Show(); | |
| 286 | |
| 287 std::vector<views::View*> vertical_order; | |
| 288 vertical_order.push_back(notification_view()->top_view_); | |
| 289 vertical_order.push_back(notification_view()->image_view_); | |
| 290 std::copy(notification_view()->action_buttons_.begin(), | |
| 291 notification_view()->action_buttons_.end(), | |
| 292 std::back_inserter(vertical_order)); | |
| 293 | |
| 294 std::vector<views::View*>::iterator last = vertical_order.begin(); | |
| 295 std::vector<views::View*>::iterator current = last; | |
| 296 ++current; | |
| 297 while (current != vertical_order.end()) { | |
| 298 gfx::Point last_point = (*last)->bounds().CenterPoint(); | |
| 299 views::View::ConvertPointToTarget( | |
| 300 (*last), notification_view(), &last_point); | |
| 301 | |
| 302 gfx::Point current_point = (*current)->bounds().CenterPoint(); | |
| 303 views::View::ConvertPointToTarget( | |
| 304 (*current), notification_view(), ¤t_point); | |
| 305 | |
| 306 EXPECT_LT(last_point.y(), current_point.y()); | |
| 307 last = current++; | |
| 308 } | |
| 309 | |
| 310 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.
| |
| 311 | |
| 312 last = vertical_order.begin(); | |
| 313 current = last; | |
| 314 ++current; | |
| 315 while (current != vertical_order.end()) { | |
| 316 gfx::Point last_point = (*last)->bounds().CenterPoint(); | |
| 317 views::View::ConvertPointToTarget( | |
| 318 (*last), notification_view(), &last_point); | |
| 319 | |
| 320 gfx::Point current_point = (*current)->bounds().CenterPoint(); | |
| 321 views::View::ConvertPointToTarget( | |
| 322 (*current), notification_view(), ¤t_point); | |
| 323 | |
| 324 EXPECT_LT(last_point.y(), current_point.y()); | |
| 325 last = current++; | |
| 326 } | |
| 327 } | |
| 328 | |
| 280 } // namespace message_center | 329 } // namespace message_center |
| OLD | NEW |