Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/shell_window_ids.h" | |
| 5 #include "ash/common/wm/window_positioner.h" | 6 #include "ash/common/wm/window_positioner.h" |
| 7 #include "ash/common/wm_shell.h" | |
| 6 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 7 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 8 #include "components/exo/buffer.h" | 10 #include "components/exo/buffer.h" |
| 9 #include "components/exo/shell_surface.h" | 11 #include "components/exo/shell_surface.h" |
| 10 #include "components/exo/surface.h" | 12 #include "components/exo/surface.h" |
| 11 #include "components/exo/test/exo_test_base.h" | 13 #include "components/exo/test/exo_test_base.h" |
| 12 #include "components/exo/test/exo_test_helper.h" | 14 #include "components/exo/test/exo_test_helper.h" |
| 13 #include "components/exo/touch.h" | 15 #include "components/exo/touch.h" |
| 14 #include "components/exo/touch_delegate.h" | 16 #include "components/exo/touch_delegate.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 // One touch point being canceled is enough for OnTouchCancel to be called. | 183 // One touch point being canceled is enough for OnTouchCancel to be called. |
| 182 EXPECT_CALL(delegate, OnTouchCancel()); | 184 EXPECT_CALL(delegate, OnTouchCancel()); |
| 183 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, | 185 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, |
| 184 ui::EventTimeForNow()); | 186 ui::EventTimeForNow()); |
| 185 generator.Dispatch(&cancel_event); | 187 generator.Dispatch(&cancel_event); |
| 186 | 188 |
| 187 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 189 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 188 touch.reset(); | 190 touch.reset(); |
| 189 } | 191 } |
| 190 | 192 |
| 193 TEST_F(TouchTest, IgnoreTouchEventDuringModal) { | |
| 194 std::unique_ptr<Surface> surface(new Surface); | |
| 195 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | |
| 196 std::unique_ptr<Buffer> buffer( | |
| 197 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10)))); | |
| 198 surface->Attach(buffer.get()); | |
| 199 surface->Commit(); | |
| 200 gfx::Point location = surface->window()->GetBoundsInScreen().origin(); | |
| 201 | |
| 202 MockTouchDelegate delegate; | |
| 203 std::unique_ptr<Touch> touch(new Touch(&delegate)); | |
| 204 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | |
| 205 | |
| 206 // Create surface for modal window. | |
| 207 std::unique_ptr<Surface> surface2(new Surface); | |
| 208 std::unique_ptr<ShellSurface> shell_surface2( | |
| 209 new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 8, 8), true, | |
| 210 ash::kShellWindowId_SystemModalContainer)); | |
| 211 std::unique_ptr<Buffer> buffer2( | |
| 212 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(8, 8)))); | |
| 213 surface2->Attach(buffer2.get()); | |
| 214 surface2->Commit(); | |
| 215 ash::wm::CenterWindow(surface2->window()); | |
| 216 | |
| 217 // Open modal. | |
|
oshima
2016/07/08 17:23:21
ditto.
| |
| 218 shell_surface2->SetSystemModal(true); | |
| 219 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | |
| 220 | |
| 221 // Check if touch events on non-modal window are ignored. | |
| 222 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(surface.get())) | |
| 223 .WillRepeatedly(testing::Return(true)); | |
| 224 EXPECT_CALL(delegate, | |
| 225 OnTouchDown(surface.get(), testing::_, testing::_, gfx::Point())) | |
| 226 .Times(0); | |
| 227 EXPECT_CALL(delegate, | |
| 228 OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100))) | |
| 229 .Times(0); | |
| 230 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0); | |
| 231 | |
| 232 generator.set_current_location(location); | |
| 233 generator.PressMoveAndReleaseTouchBy(100, 100); | |
| 234 | |
| 235 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | |
|
oshima
2016/07/08 17:23:21
ditto. close the modal and verify that it'll recei
| |
| 236 touch.reset(); | |
| 237 } | |
| 238 | |
| 191 } // namespace | 239 } // namespace |
| 192 } // namespace exo | 240 } // namespace exo |
| OLD | NEW |