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

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

Issue 1297373004: Don't synthesize mousemove events if the mouse cursor is not on the widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change the property name and add a test Created 5 years, 4 months 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
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.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 08e15d5a724a563d6c8958fe083175a05c8e4dee..7d2691c0fdd5b7f12900cc37ab59826bb0bce2a3 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -1697,6 +1697,7 @@ TEST_F(WidgetTest, EventHandlersOnRootView) {
TEST_F(WidgetTest, SynthesizeMouseMoveEvent) {
Widget* widget = CreateTopLevelNativeWidget();
View* root_view = widget->GetRootView();
+ root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
EventCountView* v1 = new EventCountView();
v1->SetBounds(0, 0, 10, 10);
@@ -1705,13 +1706,28 @@ TEST_F(WidgetTest, SynthesizeMouseMoveEvent) {
v2->SetBounds(0, 10, 10, 10);
root_view->AddChildView(v2);
+ // SynthesizeMouseMoveEvent does nothing until the mouse is entered.
+ widget->SynthesizeMouseMoveEvent();
+ EXPECT_EQ(0, v1->GetEventCount(ui::ET_MOUSE_MOVED));
+ EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED));
+
gfx::Point cursor_location(5, 5);
+ ui::MouseEvent enter(ui::ET_MOUSE_ENTERED, cursor_location, cursor_location,
+ ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
+ widget->OnMouseEvent(&enter);
+
ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
widget->OnMouseEvent(&move);
EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED));
+ EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_MOVED));
EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
+ EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED));
+
+ // SynthesizeMouseMoveEvent dispatches an mousemove event.
+ widget->SynthesizeMouseMoveEvent();
+ EXPECT_EQ(2, v1->GetEventCount(ui::ET_MOUSE_MOVED));
delete v1;
v2->SetBounds(0, 0, 10, 10);
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698