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

Side by Side 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 unified diff | Download patch
OLDNEW
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
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, 5, 5), true,
311 ash::kShellWindowId_SystemModalContainer));
312 std::unique_ptr<Buffer> buffer2(
313 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5))));
314 surface2->Attach(buffer2.get());
315 surface2->Commit();
316 ash::wm::CenterWindow(surface2->window());
317
318 // Make the window modal.
319 shell_surface2->SetSystemModal(true);
320 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
321
322 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
323 .WillRepeatedly(testing::Return(true));
324
325 // Check if pointer events on non-modal window are ignored.
326 {
327 testing::InSequence sequence;
328 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0))
329 .Times(0);
330 }
331 generator.MoveMouseTo(location);
332
333 {
334 testing::InSequence sequence;
335 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)))
336 .Times(0);
337 }
338 generator.MoveMouseTo(location + gfx::Vector2d(1, 1));
339
340 {
341 testing::InSequence sequence;
342 EXPECT_CALL(delegate,
343 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true))
344 .Times(0);
345 EXPECT_CALL(delegate,
346 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false))
347 .Times(0);
348 }
349 generator.ClickLeftButton();
350
351 {
352 testing::InSequence sequence;
353 EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_)).Times(0);
354 EXPECT_CALL(delegate,
355 OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false))
356 .Times(0);
357 EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)).Times(0);
358 }
359 generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
360
361 {
362 testing::InSequence sequence;
363 EXPECT_CALL(delegate, OnPointerLeave(surface.get())).Times(0);
364 }
365 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
366
367 // Make the window non-modal.
368 shell_surface2->SetSystemModal(false);
369 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
370
371 // Check if pointer events on non-modal window are registered.
372 {
373 testing::InSequence sequence;
374 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
375 }
376 generator.MoveMouseTo(location);
377
378 {
379 testing::InSequence sequence;
380 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)));
381 }
382 generator.MoveMouseTo(location + gfx::Vector2d(1, 1));
383
384 {
385 testing::InSequence sequence;
386 EXPECT_CALL(delegate,
387 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true));
388 EXPECT_CALL(delegate,
389 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false));
390 }
391 generator.ClickLeftButton();
392
393 {
394 testing::InSequence sequence;
395 EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_));
396 EXPECT_CALL(delegate,
397 OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false));
398 EXPECT_CALL(delegate, OnPointerScrollStop(testing::_));
399 }
400 generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
401
402 {
403 testing::InSequence sequence;
404 EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
405 }
406 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
407
408 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
409 pointer.reset();
410 }
411
292 } // namespace 412 } // namespace
293 } // namespace exo 413 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698