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/shell_window_ids.h" |
| 6 #include "ash/common/wm_shell.h" | |
| 6 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/window_util.h" | |
| 7 #include "components/exo/buffer.h" | 9 #include "components/exo/buffer.h" |
| 8 #include "components/exo/pointer.h" | 10 #include "components/exo/pointer.h" |
| 9 #include "components/exo/pointer_delegate.h" | 11 #include "components/exo/pointer_delegate.h" |
| 10 #include "components/exo/shell_surface.h" | 12 #include "components/exo/shell_surface.h" |
| 11 #include "components/exo/surface.h" | 13 #include "components/exo/surface.h" |
| 12 #include "components/exo/test/exo_test_base.h" | 14 #include "components/exo/test/exo_test_base.h" |
| 13 #include "components/exo/test/exo_test_helper.h" | 15 #include "components/exo/test/exo_test_helper.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/test/event_generator.h" | 18 #include "ui/events/test/event_generator.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); | 284 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); |
| 283 | 285 |
| 284 EXPECT_CALL(delegate, | 286 EXPECT_CALL(delegate, |
| 285 OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true)); | 287 OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true)); |
| 286 generator.MoveMouseWheel(1, 1); | 288 generator.MoveMouseWheel(1, 1); |
| 287 | 289 |
| 288 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); | 290 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); |
| 289 pointer.reset(); | 291 pointer.reset(); |
| 290 } | 292 } |
| 291 | 293 |
| 294 TEST_F(PointerTest, IgnorePointerEventDuringModal) { | |
| 295 std::unique_ptr<Surface> surface(new Surface); | |
| 296 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | |
| 297 std::unique_ptr<Buffer> buffer( | |
| 298 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10)))); | |
| 299 surface->Attach(buffer.get()); | |
| 300 surface->Commit(); | |
| 301 gfx::Point location = surface->window()->GetBoundsInScreen().origin(); | |
| 302 | |
| 303 MockPointerDelegate delegate; | |
| 304 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); | |
| 305 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | |
| 306 | |
| 307 // Create surface for modal window. | |
| 308 std::unique_ptr<Surface> surface2(new Surface); | |
| 309 std::unique_ptr<ShellSurface> shell_surface2( | |
| 310 new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 8, 8), true, | |
| 311 ash::kShellWindowId_SystemModalContainer)); | |
| 312 std::unique_ptr<Buffer> buffer2( | |
| 313 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(8, 8)))); | |
| 314 surface2->Attach(buffer2.get()); | |
| 315 surface2->Commit(); | |
| 316 ash::wm::CenterWindow(surface2->window()); | |
| 317 | |
| 318 // Open modal. | |
|
oshima
2016/07/07 22:01:18
Make the windowmodal. (The window is already opene
| |
| 319 shell_surface2->SetSystemModal(true); | |
| 320 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | |
| 321 | |
| 322 // Check if pointer events on non-modal window are ignored. | |
| 323 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) | |
| 324 .WillRepeatedly(testing::Return(true)); | |
| 325 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)) | |
| 326 .Times(0); | |
| 327 EXPECT_CALL(delegate, OnPointerLeave(surface.get())).Times(0); | |
| 328 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(10, 10))) | |
| 329 .Times(0); | |
| 330 EXPECT_CALL(delegate, | |
| 331 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true)) | |
| 332 .Times(0); | |
| 333 EXPECT_CALL(delegate, | |
| 334 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false)) | |
| 335 .Times(0); | |
| 336 EXPECT_CALL(delegate, OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true)) | |
| 337 .Times(0); | |
| 338 EXPECT_CALL(delegate, | |
| 339 OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), false)) | |
| 340 .Times(0); | |
| 341 EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_)).Times(0); | |
| 342 EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)).Times(0); | |
| 343 EXPECT_CALL(delegate, OnPointerFrame()).Times(0); | |
|
oshima
2016/07/07 22:01:17
can you also test touch & gesture?
| |
| 344 | |
| 345 generator.MoveMouseTo(location); | |
|
oshima
2016/07/07 22:01:17
can you group the event and expectation together ,
| |
| 346 generator.ClickLeftButton(); | |
| 347 generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1); | |
| 348 | |
|
oshima
2016/07/07 22:01:18
can you also close the modal dialog and test if th
| |
| 349 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); | |
| 350 pointer.reset(); | |
| 351 } | |
| 352 | |
| 292 } // namespace | 353 } // namespace |
| 293 } // namespace exo | 354 } // namespace exo |
| OLD | NEW |