| Index: components/exo/pointer_unittest.cc
|
| diff --git a/components/exo/pointer_unittest.cc b/components/exo/pointer_unittest.cc
|
| index 5549834bbdf441146f4a2972d1b1c8264fc7219c..4ce788738c661f2217dd8697022c9a50be67b47f 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,123 @@ 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, 5, 5), true,
|
| + ash::kShellWindowId_SystemModalContainer));
|
| + std::unique_ptr<Buffer> buffer2(
|
| + new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5))));
|
| + surface2->Attach(buffer2.get());
|
| + surface2->Commit();
|
| + ash::wm::CenterWindow(surface2->window());
|
| +
|
| + // Make the window modal.
|
| + shell_surface2->SetSystemModal(true);
|
| + EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
|
| +
|
| + EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
|
| + .WillRepeatedly(testing::Return(true));
|
| +
|
| + // Check if pointer events on non-modal window are ignored.
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0))
|
| + .Times(0);
|
| + }
|
| + generator.MoveMouseTo(location);
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)))
|
| + .Times(0);
|
| + }
|
| + generator.MoveMouseTo(location + gfx::Vector2d(1, 1));
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + 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);
|
| + }
|
| + generator.ClickLeftButton();
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_)).Times(0);
|
| + EXPECT_CALL(delegate,
|
| + OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false))
|
| + .Times(0);
|
| + EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)).Times(0);
|
| + }
|
| + generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerLeave(surface.get())).Times(0);
|
| + }
|
| + generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
|
| +
|
| + // Make the window non-modal.
|
| + shell_surface2->SetSystemModal(false);
|
| + EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
|
| +
|
| + // Check if pointer events on non-modal window are registered.
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
|
| + }
|
| + generator.MoveMouseTo(location);
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)));
|
| + }
|
| + generator.MoveMouseTo(location + gfx::Vector2d(1, 1));
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate,
|
| + OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true));
|
| + EXPECT_CALL(delegate,
|
| + OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false));
|
| + }
|
| + generator.ClickLeftButton();
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_));
|
| + EXPECT_CALL(delegate,
|
| + OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false));
|
| + EXPECT_CALL(delegate, OnPointerScrollStop(testing::_));
|
| + }
|
| + generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
|
| +
|
| + {
|
| + testing::InSequence sequence;
|
| + EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
|
| + }
|
| + generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
|
| +
|
| + EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
|
| + pointer.reset();
|
| +}
|
| +
|
| } // namespace
|
| } // namespace exo
|
|
|