Chromium Code Reviews| Index: components/exo/pointer_unittest.cc |
| diff --git a/components/exo/pointer_unittest.cc b/components/exo/pointer_unittest.cc |
| index 5549834bbdf441146f4a2972d1b1c8264fc7219c..53e0df174904f003049a8ce253515bde53bc1840 100644 |
| --- a/components/exo/pointer_unittest.cc |
| +++ b/components/exo/pointer_unittest.cc |
| @@ -3,7 +3,9 @@ |
| // found in the LICENSE file. |
| #include "ash/common/shell_window_ids.h" |
| +#include "ash/common/wm_shell.h" |
| #include "ash/shell.h" |
| +#include "ash/wm/window_util.h" |
| #include "components/exo/buffer.h" |
| #include "components/exo/pointer.h" |
| #include "components/exo/pointer_delegate.h" |
| @@ -289,5 +291,64 @@ TEST_F(PointerTest, OnPointerScrollDiscrete) { |
| pointer.reset(); |
| } |
| +TEST_F(PointerTest, IgnorePointerEventDuringModal) { |
| + 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(); |
| + |
| + MockPointerDelegate delegate; |
| + std::unique_ptr<Pointer> pointer(new Pointer(&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/07 22:01:18
Make the windowmodal. (The window is already opene
|
| + shell_surface2->SetSystemModal(true); |
| + EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| + |
| + // Check if pointer events on non-modal window are ignored. |
| + EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) |
| + .WillRepeatedly(testing::Return(true)); |
| + EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)) |
| + .Times(0); |
| + EXPECT_CALL(delegate, OnPointerLeave(surface.get())).Times(0); |
| + EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(10, 10))) |
| + .Times(0); |
| + EXPECT_CALL(delegate, |
| + OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true)) |
| + .Times(0); |
| + EXPECT_CALL(delegate, |
| + OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false)) |
| + .Times(0); |
| + EXPECT_CALL(delegate, OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true)) |
| + .Times(0); |
| + EXPECT_CALL(delegate, |
| + OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), false)) |
| + .Times(0); |
| + EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_)).Times(0); |
| + EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)).Times(0); |
| + EXPECT_CALL(delegate, OnPointerFrame()).Times(0); |
|
oshima
2016/07/07 22:01:17
can you also test touch & gesture?
|
| + |
| + generator.MoveMouseTo(location); |
|
oshima
2016/07/07 22:01:17
can you group the event and expectation together ,
|
| + generator.ClickLeftButton(); |
| + generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1); |
| + |
|
oshima
2016/07/07 22:01:18
can you also close the modal dialog and test if th
|
| + EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); |
| + pointer.reset(); |
| +} |
| + |
| } // namespace |
| } // namespace exo |