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

Unified Diff: components/exo/touch_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
« components/exo/pointer_unittest.cc ('K') | « components/exo/touch.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/touch_unittest.cc
diff --git a/components/exo/touch_unittest.cc b/components/exo/touch_unittest.cc
index d9548a1050340c3d36ac79f01683359821b40138..41d8f4d2c3ca099749e17c9866fae362e4e87fcf 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,74 @@ 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, 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, CanAcceptTouchEventsForSurface(surface.get()))
+ .WillRepeatedly(testing::Return(true));
+
+ // Check if touch events on non-modal window are ignored.
+ testing::Sequence s1, s2;
+
+ EXPECT_CALL(delegate,
+ OnTouchDown(surface.get(), testing::_, testing::_, gfx::Point()))
+ .Times(0)
+ .InSequence(s1);
+ EXPECT_CALL(delegate,
+ OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100)))
+ .Times(0)
+ .InSequence(s1);
+ EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_))
+ .Times(0)
+ .InSequence(s1);
+
+ generator.set_current_location(location);
+ generator.PressMoveAndReleaseTouchBy(100, 100);
+
+ // Make the window non-modal.
+ shell_surface2->SetSystemModal(false);
+ EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
+
+ // Check if touch events on non-modal window are registered.
+ EXPECT_CALL(delegate,
+ OnTouchDown(surface.get(), testing::_, testing::_, gfx::Point()))
+ .InSequence(s2);
+ EXPECT_CALL(delegate,
+ OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100)))
+ .InSequence(s2);
+ EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).InSequence(s2);
+
+ generator.set_current_location(location);
+ generator.PressMoveAndReleaseTouchBy(100, 100);
+
+ EXPECT_CALL(delegate, OnTouchDestroying(touch.get()));
+ touch.reset();
+}
+
} // namespace
} // namespace exo
« components/exo/pointer_unittest.cc ('K') | « components/exo/touch.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698