| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 3623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3634 EXPECT_FALSE(removals_observer.DidRemoveView(child)); | 3634 EXPECT_FALSE(removals_observer.DidRemoveView(child)); |
| 3635 | 3635 |
| 3636 // Moving the child to a different widget should call the removals observer. | 3636 // Moving the child to a different widget should call the removals observer. |
| 3637 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); | 3637 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); |
| 3638 widget2->client_view()->AddChildView(child); | 3638 widget2->client_view()->AddChildView(child); |
| 3639 EXPECT_TRUE(removals_observer.DidRemoveView(child)); | 3639 EXPECT_TRUE(removals_observer.DidRemoveView(child)); |
| 3640 | 3640 |
| 3641 widget->RemoveRemovalsObserver(&removals_observer); | 3641 widget->RemoveRemovalsObserver(&removals_observer); |
| 3642 } | 3642 } |
| 3643 | 3643 |
| 3644 // Tests that we don't get Exited notification when we're handling the dragging |
| 3645 // operation. When we stop the drag outside of Widget's bounds we should get the |
| 3646 // Exited notification when the mouse capture will be released. |
| 3647 TEST_F(WidgetTest, MouseExitOnMouseReleaseOutsideView) { |
| 3648 Widget* widget = CreateTopLevelNativeWidget(); |
| 3649 widget->SetBounds(gfx::Rect(0, 0, 300, 300)); |
| 3650 EventCountView* mock_view = new EventCountView(); |
| 3651 widget->GetContentsView()->AddChildView(mock_view); |
| 3652 mock_view->SetBounds(0, 0, 300, 300); |
| 3653 widget->Show(); |
| 3654 |
| 3655 // Use an event generator to ask views code to set the cursor. However, note |
| 3656 // that this does not cause Cocoa to generate tracking rectangle updates. |
| 3657 ui::test::EventGenerator event_generator(GetContext(), |
| 3658 widget->GetNativeWindow()); |
| 3659 |
| 3660 event_generator.MoveMouseTo(gfx::Point(50, 50)); |
| 3661 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_ENTERED)); |
| 3662 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 3663 mock_view->ResetCounts(); |
| 3664 |
| 3665 |
| 3666 mock_view->set_handle_mode(EventCountView::CONSUME_EVENTS); |
| 3667 event_generator.PressLeftButton(); |
| 3668 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_PRESSED)); |
| 3669 mock_view->set_handle_mode(EventCountView::PROPAGATE_EVENTS); |
| 3670 mock_view->ResetCounts(); |
| 3671 |
| 3672 EXPECT_TRUE(widget->HasCapture()); |
| 3673 |
| 3674 mock_view->set_handle_mode(EventCountView::CONSUME_EVENTS); |
| 3675 event_generator.MoveMouseTo(gfx::Point(-50, -50)); |
| 3676 // The mouse exited event should not be received, if we have capture. |
| 3677 EXPECT_EQ(0, mock_view->GetEventCount(ui::ET_MOUSE_EXITED)); |
| 3678 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_DRAGGED)); |
| 3679 mock_view->set_handle_mode(EventCountView::PROPAGATE_EVENTS); |
| 3680 mock_view->ResetCounts(); |
| 3681 |
| 3682 event_generator.ReleaseLeftButton(); |
| 3683 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_RELEASED)); |
| 3684 // The mouse exited event should be received, after mouse released |
| 3685 // outside view bounds. |
| 3686 EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_EXITED)); |
| 3687 mock_view->ResetCounts(); |
| 3688 |
| 3689 EXPECT_FALSE(widget->HasCapture()); |
| 3690 |
| 3691 widget->CloseNow(); |
| 3692 } |
| 3693 |
| 3644 // Test dispatch of ui::ET_MOUSEWHEEL. | 3694 // Test dispatch of ui::ET_MOUSEWHEEL. |
| 3645 TEST_F(WidgetTest, MouseWheelEvent) { | 3695 TEST_F(WidgetTest, MouseWheelEvent) { |
| 3646 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); | 3696 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); |
| 3647 widget->SetBounds(gfx::Rect(0, 0, 600, 600)); | 3697 widget->SetBounds(gfx::Rect(0, 0, 600, 600)); |
| 3648 EventCountView* event_count_view = new EventCountView(); | 3698 EventCountView* event_count_view = new EventCountView(); |
| 3649 widget->GetContentsView()->AddChildView(event_count_view); | 3699 widget->GetContentsView()->AddChildView(event_count_view); |
| 3650 event_count_view->SetBounds(0, 0, 600, 600); | 3700 event_count_view->SetBounds(0, 0, 600, 600); |
| 3651 widget->Show(); | 3701 widget->Show(); |
| 3652 | 3702 |
| 3653 ui::test::EventGenerator event_generator(GetContext(), | 3703 ui::test::EventGenerator event_generator(GetContext(), |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3857 Transparency_DesktopWidgetTranslucent | 3907 Transparency_DesktopWidgetTranslucent |
| 3858 #endif | 3908 #endif |
| 3859 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) { | 3909 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) { |
| 3860 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); | 3910 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); |
| 3861 } | 3911 } |
| 3862 | 3912 |
| 3863 #endif // !defined(OS_CHROMEOS) | 3913 #endif // !defined(OS_CHROMEOS) |
| 3864 | 3914 |
| 3865 } // namespace test | 3915 } // namespace test |
| 3866 } // namespace views | 3916 } // namespace views |
| OLD | NEW |