summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 05:31:43 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 05:31:43 +0000
commitd05cf2f1ab93b70f152cb673a102ef2d0e125a72 (patch)
treedb52c14fa05e9c39faefde5a0ad2eff52266221c /ash
parent1b71f74af8a09558576bba939c9726cc7b4b7c4d (diff)
downloadchromium_src-d05cf2f1ab93b70f152cb673a102ef2d0e125a72.zip
chromium_src-d05cf2f1ab93b70f152cb673a102ef2d0e125a72.tar.gz
chromium_src-d05cf2f1ab93b70f152cb673a102ef2d0e125a72.tar.bz2
aura: Make sure WindowEventDispatcher only dipatches events to in it.
If an event arrives at a WindowEventDispatcher targeted to a Window not owned by it, then stop the event-dispatch at this dispatcher, and dispatch the event from the correct dispatcher instead. To explain with an example: * There are two WindowEventDispatchers A and B. * Window W is in A. * An event comes in (from the native platform) to dispatcher B. * The event is targeted at W (because it has capture, or because it has focus etc.) * Instead of dispatching the event to W from B, stop the event-dispatch in B and dispatch the event to W from A instead. BUG=346808 R=oshima@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/180173004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/extended_desktop_unittest.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index 0a7efa3..4276b5d 100644
--- a/ash/extended_desktop_unittest.cc
+++ b/ash/extended_desktop_unittest.cc
@@ -421,34 +421,46 @@ TEST_F(ExtendedDesktopTest, Capture) {
EXPECT_EQ(r1_w1.get(),
aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
- aura::test::EventGenerator generator2(root_windows[1]);
- generator2.MoveMouseToCenterOf(r2_w1.get());
- generator2.ClickLeftButton();
+ aura::test::EventGenerator& generator = GetEventGenerator();
+ generator.MoveMouseToCenterOf(r2_w1.get());
+ // |r1_w1| will receive the events because it has capture.
+ EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
+
+ generator.ClickLeftButton();
EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
// The mouse is outside. On chromeos, the mouse is warped to the
// dest root window, but it's not implemented on Win yet, so
// no mouse move event on Win.
- EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r1_d1.GetMouseMotionCountsAndReset());
EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
- // Emulate passive grab. (15,15) on 1st display is (-985,15) on 2nd
- // display.
- generator2.MoveMouseTo(-985, 15);
+
+ generator.MoveMouseTo(15, 15);
EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
r1_w2->SetCapture();
EXPECT_EQ(r1_w2.get(),
aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
- generator2.MoveMouseBy(10, 10);
- generator2.ClickLeftButton();
+ generator.MoveMouseBy(10, 10);
+ // |r1_w2| has the capture. So it will receive the mouse-move event.
+ EXPECT_EQ("0 0 0", r1_d1.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
+
+ generator.ClickLeftButton();
EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
- EXPECT_EQ("1 1 0", r1_d2.GetMouseMotionCountsAndReset());
+ EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset());
+
r1_w2->ReleaseCapture();
EXPECT_EQ(NULL, aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
- generator2.MoveMouseTo(15, 15);
- generator2.ClickLeftButton();
+
+ generator.MoveMouseToCenterOf(r2_w1.get());
+ generator.ClickLeftButton();
EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset());
EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset());
// Make sure the mouse_moved_handler_ is properly reset.