| 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" |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "ui/events/event_processor.h" |
| 13 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 18 #include "ui/message_center/message_center_style.h" | 19 #include "ui/message_center/message_center_style.h" |
| 19 #include "ui/message_center/notification.h" | 20 #include "ui/message_center/notification.h" |
| 20 #include "ui/message_center/notification_list.h" | 21 #include "ui/message_center/notification_list.h" |
| 21 #include "ui/message_center/notification_types.h" | 22 #include "ui/message_center/notification_types.h" |
| 22 #include "ui/message_center/views/constants.h" | 23 #include "ui/message_center/views/constants.h" |
| 23 #include "ui/message_center/views/message_center_controller.h" | 24 #include "ui/message_center/views/message_center_controller.h" |
| 24 #include "ui/message_center/views/notification_button.h" | 25 #include "ui/message_center/views/notification_button.h" |
| 25 #include "ui/message_center/views/proportional_image_view.h" | 26 #include "ui/message_center/views/proportional_image_view.h" |
| 26 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
| 27 #include "ui/views/test/views_test_base.h" | 28 #include "ui/views/test/views_test_base.h" |
| 29 #include "ui/views/test/widget_test.h" |
| 28 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
| 29 | 31 |
| 30 namespace message_center { | 32 namespace message_center { |
| 31 | 33 |
| 32 /* Test fixture ***************************************************************/ | 34 /* Test fixture ***************************************************************/ |
| 33 | 35 |
| 34 class NotificationViewTest : public views::ViewsTestBase, | 36 class NotificationViewTest : public views::ViewsTestBase, |
| 35 public MessageCenterController { | 37 public MessageCenterController { |
| 36 public: | 38 public: |
| 37 NotificationViewTest(); | 39 NotificationViewTest(); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 widget()->Show(); | 412 widget()->Show(); |
| 411 | 413 |
| 412 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 414 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 413 notification_view()->action_buttons_[0]->state()); | 415 notification_view()->action_buttons_[0]->state()); |
| 414 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 416 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 415 notification_view()->action_buttons_[1]->state()); | 417 notification_view()->action_buttons_[1]->state()); |
| 416 | 418 |
| 417 // Now construct a mouse move event 1 pixel inside the boundary of the action | 419 // Now construct a mouse move event 1 pixel inside the boundary of the action |
| 418 // button. | 420 // button. |
| 419 gfx::Point cursor_location(1, 1); | 421 gfx::Point cursor_location(1, 1); |
| 420 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], | 422 views::View::ConvertPointToScreen(notification_view()->action_buttons_[0], |
| 421 &cursor_location); | 423 &cursor_location); |
| 422 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 424 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 423 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 425 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 424 widget()->OnMouseEvent(&move); | 426 ui::EventDispatchDetails details = |
| 427 views::test::WidgetTest::GetEventProcessor(widget())-> |
| 428 OnEventFromSource(&move); |
| 429 EXPECT_FALSE(details.dispatcher_destroyed); |
| 425 | 430 |
| 426 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 431 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| 427 notification_view()->action_buttons_[0]->state()); | 432 notification_view()->action_buttons_[0]->state()); |
| 428 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 433 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 429 notification_view()->action_buttons_[1]->state()); | 434 notification_view()->action_buttons_[1]->state()); |
| 430 | 435 |
| 431 notification()->set_buttons(CreateButtons(1)); | 436 notification()->set_buttons(CreateButtons(1)); |
| 432 notification_view()->CreateOrUpdateViews(*notification()); | 437 notification_view()->CreateOrUpdateViews(*notification()); |
| 433 | 438 |
| 434 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 439 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 455 | 460 |
| 456 // Double-check that vertical order is correct. | 461 // Double-check that vertical order is correct. |
| 457 CheckVerticalOrderInNotification(); | 462 CheckVerticalOrderInNotification(); |
| 458 | 463 |
| 459 // Tests that views remain in that order even after an update. | 464 // Tests that views remain in that order even after an update. |
| 460 UpdateNotificationViews(); | 465 UpdateNotificationViews(); |
| 461 CheckVerticalOrderInNotification(); | 466 CheckVerticalOrderInNotification(); |
| 462 } | 467 } |
| 463 | 468 |
| 464 } // namespace message_center | 469 } // namespace message_center |
| OLD | NEW |