Chromium Code Reviews| Index: services/ui/ws/event_dispatcher_unittest.cc |
| diff --git a/services/ui/ws/event_dispatcher_unittest.cc b/services/ui/ws/event_dispatcher_unittest.cc |
| index d7192a2d77059e7da9222f87ab5a6b5a5a5da2b9..5f5a242994fc081fb92a2ab15d857d382a17f367 100644 |
| --- a/services/ui/ws/event_dispatcher_unittest.cc |
| +++ b/services/ui/ws/event_dispatcher_unittest.cc |
| @@ -1563,6 +1563,54 @@ TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| EXPECT_EQ(gfx::Point(35, 5), dispatched_event->location()); |
| } |
| +// Tests events on a sub-window of system modal window target the window itself. |
| +TEST_F(EventDispatcherTest, ModalWindowEventSubWindowSystemModal) { |
| + 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.
|
| + w1->SetModalType(MODAL_TYPE_SYSTEM); |
| + event_dispatcher()->AddSystemModalWindow(w1.get()); |
| + |
| + auto w2 = CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| + auto w3 = CreateChildWindow(WindowId(1, 5)); |
| + |
| + root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| + w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| + w2->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| + w3->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| + |
| + struct { |
| + gfx::Point location; |
| + ServerWindow* expected_target; |
| + } kTouchData[] = { |
| + // Touch on |w1| should go to |w1|. |
| + {gfx::Point(11, 11), w1.get()}, |
| + // Touch on |w2| should go to |w2|. |
| + {gfx::Point(25, 25), w2.get()}, |
| + // Touch on |w3| should go to |w1|. |
| + {gfx::Point(11, 31), w1.get()}, |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(kTouchData); i++) { |
| + // Send touch press and check that the expected target receives it. |
| + event_dispatcher()->ProcessEvent( |
| + ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
| + kTouchData[i].location, 0, |
| + base::TimeTicks())), |
| + EventDispatcher::AcceleratorMatchPhase::ANY); |
| + auto details = |
| + test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| + 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.
|
| + EXPECT_EQ(kTouchData[i].expected_target, details->window); |
| + |
| + // Release touch. |
| + event_dispatcher()->ProcessEvent( |
| + ui::PointerEvent(ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| + kTouchData[i].location, 0, |
| + base::TimeTicks())), |
| + EventDispatcher::AcceleratorMatchPhase::ANY); |
| + test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| + } |
| +} |
| + |
| // Tests that setting capture to a descendant of a modal parent fails. |
| TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |