Index: components/exo/touch_unittest.cc |
diff --git a/components/exo/touch_unittest.cc b/components/exo/touch_unittest.cc |
index d9548a1050340c3d36ac79f01683359821b40138..c6b56a9bf86237de5bfcaaba5d3215053140b2e1 100644 |
--- a/components/exo/touch_unittest.cc |
+++ b/components/exo/touch_unittest.cc |
@@ -2,7 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "ash/common/shell_window_ids.h" |
#include "ash/common/wm/window_positioner.h" |
+#include "ash/common/wm_shell.h" |
#include "ash/shell.h" |
#include "ash/wm/window_util.h" |
#include "components/exo/buffer.h" |
@@ -188,5 +190,51 @@ TEST_F(TouchTest, OnTouchCancel) { |
touch.reset(); |
} |
+TEST_F(TouchTest, IgnoreTouchEventDuringModal) { |
+ std::unique_ptr<Surface> surface(new Surface); |
+ std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
+ std::unique_ptr<Buffer> buffer( |
+ new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10)))); |
+ surface->Attach(buffer.get()); |
+ surface->Commit(); |
+ gfx::Point location = surface->window()->GetBoundsInScreen().origin(); |
+ |
+ MockTouchDelegate delegate; |
+ std::unique_ptr<Touch> touch(new Touch(&delegate)); |
+ ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
+ |
+ // Create surface for modal window. |
+ std::unique_ptr<Surface> surface2(new Surface); |
+ std::unique_ptr<ShellSurface> shell_surface2( |
+ new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 8, 8), true, |
+ ash::kShellWindowId_SystemModalContainer)); |
+ std::unique_ptr<Buffer> buffer2( |
+ new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(8, 8)))); |
+ surface2->Attach(buffer2.get()); |
+ surface2->Commit(); |
+ ash::wm::CenterWindow(surface2->window()); |
+ |
+ // Open modal. |
oshima
2016/07/08 17:23:21
ditto.
|
+ shell_surface2->SetSystemModal(true); |
+ EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
+ |
+ // Check if touch events on non-modal window are ignored. |
+ EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(surface.get())) |
+ .WillRepeatedly(testing::Return(true)); |
+ EXPECT_CALL(delegate, |
+ OnTouchDown(surface.get(), testing::_, testing::_, gfx::Point())) |
+ .Times(0); |
+ EXPECT_CALL(delegate, |
+ OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100))) |
+ .Times(0); |
+ EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0); |
+ |
+ generator.set_current_location(location); |
+ generator.PressMoveAndReleaseTouchBy(100, 100); |
+ |
+ EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
oshima
2016/07/08 17:23:21
ditto. close the modal and verify that it'll recei
|
+ touch.reset(); |
+} |
+ |
} // namespace |
} // namespace exo |