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

Unified 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: Add a test. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | services/ui/ws/modal_window_controller.cc » ('j') | services/ui/ws/modal_window_controller.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « no previous file | services/ui/ws/modal_window_controller.cc » ('j') | services/ui/ws/modal_window_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698