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

Side by Side Diff: services/ui/ws/event_dispatcher_unittest.cc

Issue 2737003002: Fix event targeting for sub-windows of system modal windows in mus+ash. (Closed)
Patch Set: Addressed feedback. Created 3 years, 9 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
« no previous file with comments | « no previous file | services/ui/ws/modal_window_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3));
1569 w1->SetModalType(MODAL_TYPE_SYSTEM);
1570 event_dispatcher()->AddSystemModalWindow(w1.get());
1571
1572 std::unique_ptr<ServerWindow> w2 =
1573 CreateChildWindowWithParent(WindowId(1, 4), w1.get());
1574 std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 5));
1575
1576 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1577 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1578 w2->SetBounds(gfx::Rect(10, 10, 10, 10));
1579 w3->SetBounds(gfx::Rect(50, 10, 10, 10));
1580
1581 struct {
1582 gfx::Point location;
1583 ServerWindow* expected_target;
1584 } kTouchData[] = {
1585 // Touch on |w1| should go to |w1|.
1586 {gfx::Point(11, 11), w1.get()},
1587 // Touch on |w2| should go to |w2|.
1588 {gfx::Point(25, 25), w2.get()},
1589 // Touch on |w3| should go to |w1|.
1590 {gfx::Point(11, 31), w1.get()},
1591 };
1592
1593 for (size_t i = 0; i < arraysize(kTouchData); i++) {
1594 // Send touch press and check that the expected target receives it.
1595 event_dispatcher()->ProcessEvent(
1596 ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_PRESSED,
1597 kTouchData[i].location, 0,
1598 base::TimeTicks())),
1599 EventDispatcher::AcceleratorMatchPhase::ANY);
1600 std::unique_ptr<DispatchedEventDetails> details =
1601 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1602 ASSERT_TRUE(details) << " details is nullptr " << i;
1603 EXPECT_EQ(kTouchData[i].expected_target, details->window);
1604
1605 // Release touch.
1606 event_dispatcher()->ProcessEvent(
1607 ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_RELEASED,
1608 kTouchData[i].location, 0,
1609 base::TimeTicks())),
1610 EventDispatcher::AcceleratorMatchPhase::ANY);
1611 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1612 }
1613 }
1614
1566 // Tests that setting capture to a descendant of a modal parent fails. 1615 // Tests that setting capture to a descendant of a modal parent fails.
1567 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { 1616 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) {
1568 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); 1617 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3));
1569 std::unique_ptr<ServerWindow> w11 = 1618 std::unique_ptr<ServerWindow> w11 =
1570 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); 1619 CreateChildWindowWithParent(WindowId(1, 4), w1.get());
1571 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); 1620 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5));
1572 1621
1573 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1622 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1574 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1623 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1575 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); 1624 w11->SetBounds(gfx::Rect(10, 10, 10, 10));
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 1859
1811 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); 1860 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15));
1812 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); 1861 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window());
1813 c1.reset(); 1862 c1.reset();
1814 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); 1863 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window());
1815 } 1864 }
1816 1865
1817 } // namespace test 1866 } // namespace test
1818 } // namespace ws 1867 } // namespace ws
1819 } // namespace ui 1868 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | services/ui/ws/modal_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698