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

Side by Side 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 unified diff | Download patch
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 EXPECT_EQ(0, h1.GetEventCount(ui::ET_MOUSEWHEEL)); 1690 EXPECT_EQ(0, h1.GetEventCount(ui::ET_MOUSEWHEEL));
1691 EXPECT_EQ(0, view->GetEventCount(ui::ET_MOUSEWHEEL)); 1691 EXPECT_EQ(0, view->GetEventCount(ui::ET_MOUSEWHEEL));
1692 EXPECT_EQ(0, h2.GetEventCount(ui::ET_MOUSEWHEEL)); 1692 EXPECT_EQ(0, h2.GetEventCount(ui::ET_MOUSEWHEEL));
1693 1693
1694 widget->CloseNow(); 1694 widget->CloseNow();
1695 } 1695 }
1696 1696
1697 TEST_F(WidgetTest, SynthesizeMouseMoveEvent) { 1697 TEST_F(WidgetTest, SynthesizeMouseMoveEvent) {
1698 Widget* widget = CreateTopLevelNativeWidget(); 1698 Widget* widget = CreateTopLevelNativeWidget();
1699 View* root_view = widget->GetRootView(); 1699 View* root_view = widget->GetRootView();
1700 root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
1700 1701
1701 EventCountView* v1 = new EventCountView(); 1702 EventCountView* v1 = new EventCountView();
1702 v1->SetBounds(0, 0, 10, 10); 1703 v1->SetBounds(0, 0, 10, 10);
1703 root_view->AddChildView(v1); 1704 root_view->AddChildView(v1);
1704 EventCountView* v2 = new EventCountView(); 1705 EventCountView* v2 = new EventCountView();
1705 v2->SetBounds(0, 10, 10, 10); 1706 v2->SetBounds(0, 10, 10, 10);
1706 root_view->AddChildView(v2); 1707 root_view->AddChildView(v2);
1707 1708
1709 // SynthesizeMouseMoveEvent does nothing until the mouse is entered.
1710 widget->SynthesizeMouseMoveEvent();
1711 EXPECT_EQ(0, v1->GetEventCount(ui::ET_MOUSE_MOVED));
1712 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED));
1713
1708 gfx::Point cursor_location(5, 5); 1714 gfx::Point cursor_location(5, 5);
1715 ui::MouseEvent enter(ui::ET_MOUSE_ENTERED, cursor_location, cursor_location,
1716 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
1717 widget->OnMouseEvent(&enter);
1718
1709 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, 1719 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
1710 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 1720 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
1711 widget->OnMouseEvent(&move); 1721 widget->OnMouseEvent(&move);
1712 1722
1713 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED)); 1723 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED));
1724 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_MOVED));
1714 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); 1725 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
1726 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED));
1727
1728 // SynthesizeMouseMoveEvent dispatches an mousemove event.
1729 widget->SynthesizeMouseMoveEvent();
1730 EXPECT_EQ(2, v1->GetEventCount(ui::ET_MOUSE_MOVED));
1715 1731
1716 delete v1; 1732 delete v1;
1717 v2->SetBounds(0, 0, 10, 10); 1733 v2->SetBounds(0, 0, 10, 10);
1718 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); 1734 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
1719 1735
1720 widget->SynthesizeMouseMoveEvent(); 1736 widget->SynthesizeMouseMoveEvent();
1721 EXPECT_EQ(1, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); 1737 EXPECT_EQ(1, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
1722 1738
1723 widget->CloseNow(); 1739 widget->CloseNow();
1724 } 1740 }
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3257 EXPECT_FALSE(widget->IsAlwaysOnTop());
3242 widget->SetAlwaysOnTop(true); 3258 widget->SetAlwaysOnTop(true);
3243 EXPECT_TRUE(widget->IsAlwaysOnTop()); 3259 EXPECT_TRUE(widget->IsAlwaysOnTop());
3244 widget->SetAlwaysOnTop(false); 3260 widget->SetAlwaysOnTop(false);
3245 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3261 EXPECT_FALSE(widget->IsAlwaysOnTop());
3246 widget->CloseNow(); 3262 widget->CloseNow();
3247 } 3263 }
3248 3264
3249 } // namespace test 3265 } // namespace test
3250 } // namespace views 3266 } // namespace views
OLDNEW
« 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