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

Side by Side Diff: components/exo/shell_surface_unittest.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 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 "components/exo/shell_surface.h"
6
5 #include "ash/accessibility_delegate.h" 7 #include "ash/accessibility_delegate.h"
6 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
7 #include "ash/public/cpp/window_properties.h" 9 #include "ash/public/cpp/window_properties.h"
8 #include "ash/public/interfaces/window_pin_type.mojom.h" 10 #include "ash/public/interfaces/window_pin_type.mojom.h"
9 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_port.h"
10 #include "ash/wm/window_state.h" 13 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_state_aura.h" 14 #include "ash/wm/window_state_aura.h"
12 #include "ash/wm/wm_event.h" 15 #include "ash/wm/wm_event.h"
13 #include "ash/wm_shell.h"
14 #include "ash/wm_window.h" 16 #include "ash/wm_window.h"
15 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
16 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
17 #include "components/exo/buffer.h" 19 #include "components/exo/buffer.h"
18 #include "components/exo/display.h" 20 #include "components/exo/display.h"
19 #include "components/exo/shell_surface.h"
20 #include "components/exo/sub_surface.h" 21 #include "components/exo/sub_surface.h"
21 #include "components/exo/surface.h" 22 #include "components/exo/surface.h"
22 #include "components/exo/test/exo_test_base.h" 23 #include "components/exo/test/exo_test_base.h"
23 #include "components/exo/test/exo_test_helper.h" 24 #include "components/exo/test/exo_test_helper.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
27 #include "ui/aura/window_targeter.h" 28 #include "ui/aura/window_targeter.h"
28 #include "ui/base/hit_test.h" 29 #include "ui/base/hit_test.h"
29 #include "ui/display/display.h" 30 #include "ui/display/display.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface( 450 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(
450 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(), 451 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(),
451 true, false, ash::kShellWindowId_SystemModalContainer)); 452 true, false, ash::kShellWindowId_SystemModalContainer));
452 gfx::Size desktop_size(640, 480); 453 gfx::Size desktop_size(640, 480);
453 std::unique_ptr<Buffer> desktop_buffer( 454 std::unique_ptr<Buffer> desktop_buffer(
454 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size))); 455 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size)));
455 surface->Attach(desktop_buffer.get()); 456 surface->Attach(desktop_buffer.get());
456 surface->SetInputRegion(SkRegion()); 457 surface->SetInputRegion(SkRegion());
457 surface->Commit(); 458 surface->Commit();
458 459
459 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 460 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
460 461
461 // Creating a surface without input region should not make it modal. 462 // Creating a surface without input region should not make it modal.
462 std::unique_ptr<Display> display(new Display); 463 std::unique_ptr<Display> display(new Display);
463 std::unique_ptr<Surface> child = display->CreateSurface(); 464 std::unique_ptr<Surface> child = display->CreateSurface();
464 gfx::Size buffer_size(128, 128); 465 gfx::Size buffer_size(128, 128);
465 std::unique_ptr<Buffer> child_buffer( 466 std::unique_ptr<Buffer> child_buffer(
466 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 467 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
467 child->Attach(child_buffer.get()); 468 child->Attach(child_buffer.get());
468 std::unique_ptr<SubSurface> sub_surface( 469 std::unique_ptr<SubSurface> sub_surface(
469 display->CreateSubSurface(child.get(), surface.get())); 470 display->CreateSubSurface(child.get(), surface.get()));
470 surface->SetSubSurfacePosition(child.get(), gfx::Point(10, 10)); 471 surface->SetSubSurfacePosition(child.get(), gfx::Point(10, 10));
471 child->Commit(); 472 child->Commit();
472 surface->Commit(); 473 surface->Commit();
473 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 474 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
474 475
475 // Making the surface opaque shouldn't make it modal either. 476 // Making the surface opaque shouldn't make it modal either.
476 child->SetBlendMode(SkBlendMode::kSrc); 477 child->SetBlendMode(SkBlendMode::kSrc);
477 child->Commit(); 478 child->Commit();
478 surface->Commit(); 479 surface->Commit();
479 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 480 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
480 481
481 // Setting input regions won't make it modal either. 482 // Setting input regions won't make it modal either.
482 surface->SetInputRegion( 483 surface->SetInputRegion(
483 SkRegion(gfx::RectToSkIRect(gfx::Rect(10, 10, 100, 100)))); 484 SkRegion(gfx::RectToSkIRect(gfx::Rect(10, 10, 100, 100))));
484 surface->Commit(); 485 surface->Commit();
485 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 486 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
486 487
487 // Only SetSystemModal changes modality. 488 // Only SetSystemModal changes modality.
488 shell_surface->SetSystemModal(true); 489 shell_surface->SetSystemModal(true);
489 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 490 EXPECT_TRUE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
490 491
491 shell_surface->SetSystemModal(false); 492 shell_surface->SetSystemModal(false);
492 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 493 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
493 } 494 }
494 495
495 TEST_F(ShellSurfaceTest, ModalWindowSetSystemModalBeforeCommit) { 496 TEST_F(ShellSurfaceTest, ModalWindowSetSystemModalBeforeCommit) {
496 std::unique_ptr<Surface> surface(new Surface); 497 std::unique_ptr<Surface> surface(new Surface);
497 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface( 498 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(
498 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(), 499 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(),
499 true, false, ash::kShellWindowId_SystemModalContainer)); 500 true, false, ash::kShellWindowId_SystemModalContainer));
500 gfx::Size desktop_size(640, 480); 501 gfx::Size desktop_size(640, 480);
501 std::unique_ptr<Buffer> desktop_buffer( 502 std::unique_ptr<Buffer> desktop_buffer(
502 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size))); 503 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size)));
503 surface->Attach(desktop_buffer.get()); 504 surface->Attach(desktop_buffer.get());
504 surface->SetInputRegion(SkRegion()); 505 surface->SetInputRegion(SkRegion());
505 506
506 // Set SetSystemModal before any commit happens. Widget is not created at 507 // Set SetSystemModal before any commit happens. Widget is not created at
507 // this time. 508 // this time.
508 EXPECT_FALSE(shell_surface->GetWidget()); 509 EXPECT_FALSE(shell_surface->GetWidget());
509 shell_surface->SetSystemModal(true); 510 shell_surface->SetSystemModal(true);
510 511
511 surface->Commit(); 512 surface->Commit();
512 513
513 // It is expected that modal window is shown. 514 // It is expected that modal window is shown.
514 EXPECT_TRUE(shell_surface->GetWidget()); 515 EXPECT_TRUE(shell_surface->GetWidget());
515 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 516 EXPECT_TRUE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
516 517
517 // Now widget is created and setting modal state should be applied 518 // Now widget is created and setting modal state should be applied
518 // immediately. 519 // immediately.
519 shell_surface->SetSystemModal(false); 520 shell_surface->SetSystemModal(false);
520 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 521 EXPECT_FALSE(ash::ShellPort::Get()->IsSystemModalWindowOpen());
521 } 522 }
522 523
523 TEST_F(ShellSurfaceTest, PopupWindow) { 524 TEST_F(ShellSurfaceTest, PopupWindow) {
524 Surface parent_surface; 525 Surface parent_surface;
525 ShellSurface parent(&parent_surface); 526 ShellSurface parent(&parent_surface);
526 const gfx::Rect parent_bounds(100, 100, 300, 300); 527 const gfx::Rect parent_bounds(100, 100, 300, 300);
527 528
528 Buffer parent_buffer( 529 Buffer parent_buffer(
529 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size())); 530 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size()));
530 parent_surface.Attach(&parent_buffer); 531 parent_surface.Attach(&parent_buffer);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 shell_surface.OnAccessibilityModeChanged(); 1009 shell_surface.OnAccessibilityModeChanged();
1009 shell_surface2.OnAccessibilityModeChanged(); 1010 shell_surface2.OnAccessibilityModeChanged();
1010 1011
1011 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 1012 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
1012 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 1013 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
1013 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 1014 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
1014 } 1015 }
1015 1016
1016 } // namespace 1017 } // namespace
1017 } // namespace exo 1018 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698