Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: ui/views/widget/widget_unittest.cc

Issue 2456903003: Send mouse exited event after mouse release outside view.
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/root_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget_unittest.cc
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index ec0f1eb5cc8a4a66b0a81ad8bf0bfd9c254b4b2b..98f72e821b5244b3579f7f2963c0e829facf3a08 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -3641,6 +3641,56 @@ TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenMovingBetweenWidgets) {
widget->RemoveRemovalsObserver(&removals_observer);
}
+// Tests that we don't get Exited notification when we're handling the dragging
+// operation. When we stop the drag outside of Widget's bounds we should get the
+// Exited notification when the mouse capture will be released.
+TEST_F(WidgetTest, MouseExitOnMouseReleaseOutsideView) {
+ Widget* widget = CreateTopLevelNativeWidget();
+ widget->SetBounds(gfx::Rect(0, 0, 300, 300));
+ EventCountView* mock_view = new EventCountView();
+ widget->GetContentsView()->AddChildView(mock_view);
+ mock_view->SetBounds(0, 0, 300, 300);
+ widget->Show();
+
+ // Use an event generator to ask views code to set the cursor. However, note
+ // that this does not cause Cocoa to generate tracking rectangle updates.
+ ui::test::EventGenerator event_generator(GetContext(),
+ widget->GetNativeWindow());
+
+ event_generator.MoveMouseTo(gfx::Point(50, 50));
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_ENTERED));
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_MOVED));
+ mock_view->ResetCounts();
+
+
+ mock_view->set_handle_mode(EventCountView::CONSUME_EVENTS);
+ event_generator.PressLeftButton();
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_PRESSED));
+ mock_view->set_handle_mode(EventCountView::PROPAGATE_EVENTS);
+ mock_view->ResetCounts();
+
+ EXPECT_TRUE(widget->HasCapture());
+
+ mock_view->set_handle_mode(EventCountView::CONSUME_EVENTS);
+ event_generator.MoveMouseTo(gfx::Point(-50, -50));
+ // The mouse exited event should not be received, if we have capture.
+ EXPECT_EQ(0, mock_view->GetEventCount(ui::ET_MOUSE_EXITED));
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_DRAGGED));
+ mock_view->set_handle_mode(EventCountView::PROPAGATE_EVENTS);
+ mock_view->ResetCounts();
+
+ event_generator.ReleaseLeftButton();
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_RELEASED));
+ // The mouse exited event should be received, after mouse released
+ // outside view bounds.
+ EXPECT_EQ(1, mock_view->GetEventCount(ui::ET_MOUSE_EXITED));
+ mock_view->ResetCounts();
+
+ EXPECT_FALSE(widget->HasCapture());
+
+ widget->CloseNow();
+}
+
// Test dispatch of ui::ET_MOUSEWHEEL.
TEST_F(WidgetTest, MouseWheelEvent) {
WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
« no previous file with comments | « ui/views/widget/root_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698