Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/event_dispatcher.h" | 5 #include "services/ui/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1556 EXPECT_TRUE(details->IsNonclientArea()); | 1556 EXPECT_TRUE(details->IsNonclientArea()); |
| 1557 | 1557 |
| 1558 ASSERT_TRUE(details->event); | 1558 ASSERT_TRUE(details->event); |
| 1559 ASSERT_TRUE(details->event->IsPointerEvent()); | 1559 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1560 | 1560 |
| 1561 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1561 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1562 EXPECT_EQ(gfx::Point(45, 15), dispatched_event->root_location()); | 1562 EXPECT_EQ(gfx::Point(45, 15), dispatched_event->root_location()); |
| 1563 EXPECT_EQ(gfx::Point(35, 5), dispatched_event->location()); | 1563 EXPECT_EQ(gfx::Point(35, 5), dispatched_event->location()); |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 // Tests events on a sub-window of system modal window target the window itself. | |
| 1567 TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { | |
| 1568 auto w1 = CreateChildWindow(WindowId(1, 3)); | |
|
sky
2017/03/09 23:23:26
excessive use of auto makes for hard to read code.
Hadi
2017/03/10 14:02:38
Done.
| |
| 1569 w1->SetModalType(MODAL_TYPE_SYSTEM); | |
| 1570 event_dispatcher()->AddSystemModalWindow(w1.get()); | |
| 1571 | |
| 1572 auto w2 = CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | |
| 1573 auto w3 = CreateChildWindow(WindowId(1, 5)); | |
| 1574 | |
| 1575 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | |
| 1576 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | |
| 1577 w2->SetBounds(gfx::Rect(10, 10, 10, 10)); | |
| 1578 w3->SetBounds(gfx::Rect(50, 10, 10, 10)); | |
| 1579 | |
| 1580 struct { | |
| 1581 gfx::Point location; | |
| 1582 ServerWindow* expected_target; | |
| 1583 } kTouchData[] = { | |
| 1584 // Touch on |w1| should go to |w1|. | |
| 1585 {gfx::Point(11, 11), w1.get()}, | |
| 1586 // Touch on |w2| should go to |w2|. | |
| 1587 {gfx::Point(25, 25), w2.get()}, | |
| 1588 // Touch on |w3| should go to |w1|. | |
| 1589 {gfx::Point(11, 31), w1.get()}, | |
| 1590 }; | |
| 1591 | |
| 1592 for (size_t i = 0; i < arraysize(kTouchData); i++) { | |
| 1593 // Send touch press and check that the expected target receives it. | |
| 1594 event_dispatcher()->ProcessEvent( | |
| 1595 ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_PRESSED, | |
| 1596 kTouchData[i].location, 0, | |
| 1597 base::TimeTicks())), | |
| 1598 EventDispatcher::AcceleratorMatchPhase::ANY); | |
| 1599 auto details = | |
| 1600 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | |
| 1601 ASSERT_TRUE(details); | |
|
sky
2017/03/09 23:23:26
You should redirect the index to this so if there
Hadi
2017/03/10 14:02:38
Done.
| |
| 1602 EXPECT_EQ(kTouchData[i].expected_target, details->window); | |
| 1603 | |
| 1604 // Release touch. | |
| 1605 event_dispatcher()->ProcessEvent( | |
| 1606 ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_RELEASED, | |
| 1607 kTouchData[i].location, 0, | |
| 1608 base::TimeTicks())), | |
| 1609 EventDispatcher::AcceleratorMatchPhase::ANY); | |
| 1610 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | |
| 1611 } | |
| 1612 } | |
| 1613 | |
| 1566 // Tests that setting capture to a descendant of a modal parent fails. | 1614 // Tests that setting capture to a descendant of a modal parent fails. |
| 1567 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { | 1615 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| 1568 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1616 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1569 std::unique_ptr<ServerWindow> w11 = | 1617 std::unique_ptr<ServerWindow> w11 = |
| 1570 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | 1618 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1571 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1619 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1572 | 1620 |
| 1573 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1621 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1574 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1622 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1575 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1623 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1810 | 1858 |
| 1811 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); | 1859 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); |
| 1812 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); | 1860 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); |
| 1813 c1.reset(); | 1861 c1.reset(); |
| 1814 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); | 1862 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); |
| 1815 } | 1863 } |
| 1816 | 1864 |
| 1817 } // namespace test | 1865 } // namespace test |
| 1818 } // namespace ws | 1866 } // namespace ws |
| 1819 } // namespace ui | 1867 } // namespace ui |
| OLD | NEW |