| Index: components/exo/shell_surface_unittest.cc
|
| diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
|
| index 7c6ddaaf28d89ab40387a62515c7be23d5c5cfd3..00f8086e119f0932d069607494d2057dd307c6ab 100644
|
| --- a/components/exo/shell_surface_unittest.cc
|
| +++ b/components/exo/shell_surface_unittest.cc
|
| @@ -536,11 +536,17 @@ TEST_F(ShellSurfaceTest, Shadow) {
|
| EXPECT_FALSE(shadow->layer()->visible());
|
|
|
| // 3) Create a shadow.
|
| - shell_surface->SetRectangularShadow(true);
|
| - shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100));
|
| + shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
|
| surface->Commit();
|
| EXPECT_TRUE(shadow->layer()->visible());
|
|
|
| + // For surface shadow, the underlay is placed at the bottom of shell surfaces.
|
| + EXPECT_EQ(surface->window(), shell_surface->shadow_underlay()->parent());
|
| + EXPECT_EQ(window, shell_surface->shadow_overlay()->parent());
|
| +
|
| + EXPECT_EQ(*surface->window()->children().begin(),
|
| + shell_surface->shadow_underlay());
|
| +
|
| gfx::Rect before = shadow->layer()->bounds();
|
|
|
| // 4) Shadow bounds is independent of the sub surface.
|
| @@ -558,19 +564,24 @@ TEST_F(ShellSurfaceTest, Shadow) {
|
| EXPECT_EQ(before, shadow->layer()->bounds());
|
|
|
| // 5) This should disable shadow.
|
| - shell_surface->SetRectangularShadow(false);
|
| + shell_surface->SetEnableRectangularShadow(false);
|
| surface->Commit();
|
|
|
| EXPECT_EQ(wm::ShadowElevation::NONE, wm::GetShadowElevation(window));
|
| EXPECT_FALSE(shadow->layer()->visible());
|
|
|
| - // 6) This should enable shadow.
|
| - shell_surface->SetRectangularShadow(true);
|
| + // 6) This should enable non surface shadow.
|
| + shell_surface->SetEnableRectangularShadow(true);
|
| surface->Commit();
|
|
|
| EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window));
|
| EXPECT_TRUE(shadow->layer()->visible());
|
|
|
| + // For no surface shadow, both of underlay and overlay should be stacked
|
| + // below the surface window.
|
| + EXPECT_EQ(window, shell_surface->shadow_underlay()->parent());
|
| + EXPECT_EQ(window, shell_surface->shadow_overlay()->parent());
|
| +
|
| // Shadow overlay should be stacked just above the shadow underlay.
|
| auto underlay_it =
|
| std::find(window->children().begin(), window->children().end(),
|
| @@ -608,8 +619,7 @@ TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
|
| aura::Window* window = widget->GetNativeWindow();
|
| wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
|
|
|
| - shell_surface->SetRectangularShadow(true);
|
| - shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface->SetRectangularSurfaceShadow(shadow_bounds);
|
| surface->Commit();
|
| EXPECT_EQ(wm::ShadowElevation::MEDIUM, wm::GetShadowElevation(window));
|
|
|
| @@ -626,7 +636,7 @@ TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
|
| ASSERT_TRUE(widget->IsMaximized());
|
| EXPECT_FALSE(shadow->layer()->visible());
|
|
|
| - shell_surface->SetRectangularShadowContentBounds(work_area);
|
| + shell_surface->SetRectangularSurfaceShadow(work_area);
|
| surface->Commit();
|
| EXPECT_FALSE(shadow->layer()->visible());
|
|
|
| @@ -638,7 +648,7 @@ TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
|
| EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds());
|
|
|
| // The bounds is updated.
|
| - shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface->SetRectangularSurfaceShadow(shadow_bounds);
|
| surface->Commit();
|
| EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds());
|
| }
|
| @@ -670,8 +680,7 @@ TEST_F(ShellSurfaceTest, ShadowWithTransform) {
|
| gfx::Transform transform;
|
| transform.Translate(50, 50);
|
| window->SetTransform(transform);
|
| - shell_surface->SetRectangularShadow(true);
|
| - shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface->SetRectangularSurfaceShadow(shadow_bounds);
|
| surface->Commit();
|
| EXPECT_TRUE(shadow->layer()->visible());
|
| EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds());
|
| @@ -690,8 +699,7 @@ TEST_F(ShellSurfaceTest, ShadowStartMaximized) {
|
| EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
|
|
|
| // Sending a shadow bounds in maximized state won't create a shaodw.
|
| - shell_surface->SetRectangularShadow(true);
|
| - shell_surface->SetRectangularShadowContentBounds(gfx::Rect(10, 10, 100, 100));
|
| + shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
|
| surface->Commit();
|
|
|
| EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window));
|
| @@ -744,21 +752,27 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) {
|
| }
|
|
|
| TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
|
| - gfx::Size buffer_size(256, 256);
|
| + const gfx::Size display_size =
|
| + display::Screen::GetScreen()->GetPrimaryDisplay().size();
|
| + const gfx::Size buffer_size(display_size);
|
| std::unique_ptr<Buffer> buffer(
|
| new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
|
| std::unique_ptr<Surface> surface(new Surface);
|
| std::unique_ptr<ShellSurface> shell_surface(
|
| - new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, false,
|
| + new ShellSurface(surface.get(), nullptr, gfx::Rect(100, 100), true, false,
|
| ash::kShellWindowId_DefaultContainer));
|
|
|
| surface->Attach(buffer.get());
|
|
|
| gfx::Rect shadow_bounds(10, 10, 100, 100);
|
| - shell_surface->SetRectangularShadow(true);
|
| - shell_surface->SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface->SetGeometry(shadow_bounds);
|
| + shell_surface->SetRectangularSurfaceShadow(shadow_bounds);
|
| surface->Commit();
|
| + EXPECT_EQ(shadow_bounds,
|
| + shell_surface->GetWidget()->GetWindowBoundsInScreen());
|
| ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
|
| + EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(),
|
| + shell_surface->surface()->window()->bounds().size());
|
|
|
| ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN);
|
| ash::WmWindow* window =
|
| @@ -767,12 +781,10 @@ TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
|
| // Enter immersive fullscreen mode. Shadow underlay is fullscreen.
|
| window->GetWindowState()->OnWMEvent(&event);
|
|
|
| - EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
|
| - shell_surface->shadow_underlay()->bounds());
|
| EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
|
| EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity());
|
| - EXPECT_NE(shell_surface->GetWidget()->GetWindowBoundsInScreen(),
|
| - shell_surface->shadow_underlay()->bounds());
|
| + EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(),
|
| + shell_surface->shadow_underlay()->bounds().size());
|
|
|
| // Leave fullscreen mode. Shadow underlay is restored.
|
| window->GetWindowState()->OnWMEvent(&event);
|
| @@ -781,30 +793,35 @@ TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
|
| }
|
|
|
| TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
|
| - gfx::Size buffer_size(256, 256);
|
| + const gfx::Size display_size =
|
| + display::Screen::GetScreen()->GetPrimaryDisplay().size();
|
| + const gfx::Size buffer_size(display_size);
|
| Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
|
| Surface surface;
|
| - ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true,
|
| + ShellSurface shell_surface(&surface, nullptr, gfx::Rect(100, 100), true,
|
| false, ash::kShellWindowId_DefaultContainer);
|
| -
|
| surface.Attach(&buffer);
|
|
|
| gfx::Rect shadow_bounds(10, 10, 100, 100);
|
| - shell_surface.SetRectangularShadow(true);
|
| - shell_surface.SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface.SetGeometry(shadow_bounds);
|
| + shell_surface.SetRectangularSurfaceShadow(shadow_bounds);
|
| surface.Commit();
|
| + EXPECT_EQ(shadow_bounds,
|
| + shell_surface.GetWidget()->GetWindowBoundsInScreen());
|
| ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
|
|
|
| aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow();
|
| aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>(
|
| static_cast<ui::EventTarget*>(shell_window)->GetEventTargeter());
|
|
|
| - gfx::Point pt(300, 300);
|
| - ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt, pt, ui::EventTimeForNow(),
|
| - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
|
| - gfx::Point pt2(250, 250);
|
| - ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt2, pt2, ui::EventTimeForNow(),
|
| - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
|
| + gfx::Point pt_out(300, 300);
|
| + ui::MouseEvent ev_out(ui::ET_MOUSE_PRESSED, pt_out, pt_out,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| + gfx::Point pt_in(70, 70);
|
| + ui::MouseEvent ev_in(ui::ET_MOUSE_PRESSED, pt_in, pt_in,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
|
|
| EXPECT_FALSE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
|
|
|
| @@ -834,8 +851,7 @@ TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
|
| ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true,
|
| false, ash::kShellWindowId_DefaultContainer);
|
| surface2.Attach(&buffer2);
|
| - shell_surface2.SetRectangularShadow(true);
|
| - shell_surface2.SetRectangularShadowContentBounds(shadow_bounds);
|
| + shell_surface2.SetRectangularSurfaceShadow(shadow_bounds);
|
| surface2.Commit();
|
|
|
| // spoken-feedback was already on, so underlay should fill screen
|
|
|