| 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 <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 Loading... |
| 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(5, 5, 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(5, 15, 10, 10); |
| 1706 root_view->AddChildView(v2); | 1707 root_view->AddChildView(v2); |
| 1707 | 1708 |
| 1709 widget->Show(); |
| 1710 |
| 1711 // SynthesizeMouseMoveEvent does nothing until the mouse is entered. |
| 1712 widget->SynthesizeMouseMoveEvent(); |
| 1713 EXPECT_EQ(0, v1->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1714 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1715 |
| 1708 gfx::Point cursor_location(5, 5); | 1716 gfx::Point cursor_location(5, 5); |
| 1717 View::ConvertPointToScreen(widget->GetRootView(), &cursor_location); |
| 1709 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 1718 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 1710 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 1719 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 1711 widget->OnMouseEvent(&move); | 1720 ui::EventDispatchDetails details = |
| 1721 WidgetTest::GetEventProcessor(widget)->OnEventFromSource(&move); |
| 1722 EXPECT_FALSE(details.dispatcher_destroyed); |
| 1712 | 1723 |
| 1713 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_MOVED)); |
| 1726 |
| 1727 // SynthesizeMouseMoveEvent dispatches an mousemove event. |
| 1728 widget->SynthesizeMouseMoveEvent(); |
| 1729 EXPECT_EQ(2, v1->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1715 | 1730 |
| 1716 delete v1; | 1731 delete v1; |
| 1717 v2->SetBounds(0, 0, 10, 10); | 1732 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1718 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); | 1733 v2->SetBounds(5, 5, 10, 10); |
| 1734 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 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_MOVED)); |
| 1722 | 1738 |
| 1723 widget->CloseNow(); | 1739 widget->CloseNow(); |
| 1724 } | 1740 } |
| 1725 | 1741 |
| 1726 // No touch on desktop Mac. Tracked in http://crbug.com/445520. | 1742 // No touch on desktop Mac. Tracked in http://crbug.com/445520. |
| 1727 #if !defined(OS_MACOSX) || defined(USE_AURA) | 1743 #if !defined(OS_MACOSX) || defined(USE_AURA) |
| 1728 | 1744 |
| 1729 namespace { | 1745 namespace { |
| 1730 | 1746 |
| 1731 // ui::EventHandler which handles all mouse press events. | 1747 // ui::EventHandler which handles all mouse press events. |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |