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

Unified Diff: components/exo/pointer_unittest.cc

Issue 2127263002: Keep the SystemModalContainerEventHandler added (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignore touch/pointer events on Arc windows if modal open Created 4 years, 5 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 | « components/exo/pointer.cc ('k') | components/exo/touch.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/pointer_unittest.cc
diff --git a/components/exo/pointer_unittest.cc b/components/exo/pointer_unittest.cc
index 5549834bbdf441146f4a2972d1b1c8264fc7219c..45c4513a95f2d2518ca805c2fa16661aff03fd51 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,112 @@ 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();
+ gfx::Point location2 =
+ surface->window()->GetBoundsInScreen().origin() + gfx::Vector2d(1, 1);
oshima 2016/07/08 21:26:51 since this is used only once, you can just inline
hariank 2016/07/08 22:47:07 Done.
+ gfx::Point location3 = surface->window()->GetBoundsInScreen().bottom_right();
oshima 2016/07/08 21:26:51 ditto.
hariank 2016/07/08 22:47:07 Done.
+
+ 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::Sequence s1, s2;
oshima 2016/07/08 21:26:51 Can you do the following? I think it's easier to u
hariank 2016/07/08 22:47:07 Done.
+
+ EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0))
+ .Times(0)
+ .InSequence(s1);
+ generator.MoveMouseTo(location);
+
+ EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)))
+ .Times(0)
+ .InSequence(s1);
+ generator.MoveMouseTo(location2);
+
+ EXPECT_CALL(delegate,
+ OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true))
+ .Times(0)
+ .InSequence(s1);
+ EXPECT_CALL(delegate,
+ OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false))
+ .Times(0)
+ .InSequence(s1);
+ generator.ClickLeftButton();
+
+ EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_))
+ .Times(0)
+ .InSequence(s1);
+ EXPECT_CALL(delegate,
+ OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false))
+ .Times(0)
+ .InSequence(s1);
+ EXPECT_CALL(delegate, OnPointerScrollStop(testing::_))
+ .Times(0)
+ .InSequence(s1);
+ generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
+
+ EXPECT_CALL(delegate, OnPointerLeave(surface.get())).Times(0).InSequence(s1);
+ generator.MoveMouseTo(location3);
+
+ // 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.
+ EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0))
+ .InSequence(s2);
+ generator.MoveMouseTo(location);
+
+ EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)))
+ .InSequence(s2);
+ generator.MoveMouseTo(location2);
+
+ EXPECT_CALL(delegate,
+ OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true))
+ .InSequence(s2);
+ EXPECT_CALL(delegate,
+ OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false))
+ .InSequence(s2);
+ generator.ClickLeftButton();
+
+ EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_)).InSequence(s2);
+ EXPECT_CALL(delegate,
+ OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false))
+ .InSequence(s2);
+ EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)).InSequence(s2);
+ generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
+
+ EXPECT_CALL(delegate, OnPointerLeave(surface.get())).InSequence(s2);
+ generator.MoveMouseTo(location3);
+
+ EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())).InSequence(s2);
+ pointer.reset();
+}
+
} // namespace
} // namespace exo
« no previous file with comments | « components/exo/pointer.cc ('k') | components/exo/touch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698