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

Unified Diff: components/exo/shell_surface_unittest.cc

Issue 2887103002: Revert of Refactor backdrop (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/shell_surface.cc ('k') | components/exo/wm_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/shell_surface_unittest.cc
diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
index 978272d4a8c4294ef44ef9191c56c40e8da5450e..d92a731337d06228c5343c48e0b47c89e6bb3293 100644
--- a/components/exo/shell_surface_unittest.cc
+++ b/components/exo/shell_surface_unittest.cc
@@ -10,12 +10,9 @@
#include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/shell.h"
#include "ash/shell_port.h"
-#include "ash/test/shell_test_api.h"
-#include "ash/test/workspace_controller_test_api.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_state_aura.h"
#include "ash/wm/wm_event.h"
-#include "ash/wm/workspace/workspace_window_resizer.h"
#include "ash/wm_window.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
@@ -28,9 +25,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_targeter.h"
#include "ui/base/hit_test.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
+#include "ui/events/base_event_utils.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/shadow.h"
#include "ui/wm/core/shadow_controller.h"
@@ -839,8 +838,9 @@
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
shell_surface->SetRectangularShadowEnabled(false);
surface->Commit();
- // No underlay if there is no shadow.
- EXPECT_FALSE(shell_surface->shadow_underlay());
+ // Underlay should be created even without shadow.
+ ASSERT_TRUE(shell_surface->shadow_underlay());
+ EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
shell_surface->SetRectangularShadowEnabled(true);
shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
@@ -890,11 +890,7 @@
shell_surface->GetWidget()->GetWindowBoundsInScreen().width());
}
-TEST_F(ShellSurfaceTest, MaximizedAndImmersiveFullscreenBackdrop) {
- ash::WorkspaceController* wc =
- ash::test::ShellTestApi(ash::Shell::Get()).workspace_controller();
- ash::test::WorkspaceControllerTestApi test_helper(wc);
-
+TEST_F(ShellSurfaceTest, MaximizedAndImmersiveFullscreenBackground) {
const gfx::Size display_size =
display::Screen::GetScreen()->GetPrimaryDisplay().size();
const gfx::Size buffer_size(display_size);
@@ -917,8 +913,6 @@
EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(),
shell_surface->surface_for_testing()->window()->bounds().size());
- EXPECT_FALSE(test_helper.GetBackdropWindow());
-
ash::wm::WMEvent fullscreen_event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN);
ash::WmWindow* window =
ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow());
@@ -926,21 +920,112 @@
// Enter immersive fullscreen mode. Shadow underlay is fullscreen.
window->GetWindowState()->OnWMEvent(&fullscreen_event);
- EXPECT_TRUE(test_helper.GetBackdropWindow());
+ EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
+ EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity());
+ EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(),
+ shell_surface->shadow_underlay()->bounds().size());
// Leave fullscreen mode. Shadow underlay is restored.
window->GetWindowState()->OnWMEvent(&fullscreen_event);
- EXPECT_FALSE(test_helper.GetBackdropWindow());
+ EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
+ EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
ash::wm::WMEvent maximize_event(ash::wm::WM_EVENT_TOGGLE_MAXIMIZE);
- // Enter maximized mode.
+ // Enter maximized mode. Shadow underlay is fullscreen.
window->GetWindowState()->OnWMEvent(&maximize_event);
- EXPECT_TRUE(test_helper.GetBackdropWindow());
-
- // Leave maximized mode.
+ EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
+ EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity());
+ EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(),
+ shell_surface->shadow_underlay()->bounds().size());
+
+ // Leave maximized mode. Shadow underlay is fullscreen.
window->GetWindowState()->OnWMEvent(&maximize_event);
- EXPECT_FALSE(test_helper.GetBackdropWindow());
+ EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
+ EXPECT_EQ(1.f, shell_surface->shadow_underlay()->layer()->opacity());
+ EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds());
+}
+
+TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
+ 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,
+ ShellSurface::BoundsMode::CLIENT, gfx::Point(),
+ true, false, ash::kShellWindowId_DefaultContainer);
+ surface.Attach(&buffer);
+
+ gfx::Rect shadow_bounds(10, 10, 100, 100);
+ 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_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));
+
+ // Enable spoken feedback.
+ ash::Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
+ ash::A11Y_NOTIFICATION_NONE);
+ shell_surface.OnAccessibilityModeChanged();
+
+ EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
+ shell_surface.shadow_underlay()->bounds());
+ EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
+ EXPECT_NE(shell_surface.GetWidget()->GetWindowBoundsInScreen(),
+ shell_surface.shadow_underlay()->bounds());
+
+ // Test event capture
+ EXPECT_TRUE(targeter->SubtreeShouldBeExploredForEvent(shell_window, ev_out));
+ EXPECT_EQ(shell_surface.shadow_underlay(),
+ static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
+ shell_window, &ev_out));
+ EXPECT_NE(shell_surface.shadow_underlay(),
+ static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent(
+ shell_window, &ev_in));
+
+ // Create a new surface
+ Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
+ Surface surface2;
+ ShellSurface shell_surface2(
+ &surface2, nullptr, ShellSurface::BoundsMode::CLIENT, gfx::Point(), true,
+ false, ash::kShellWindowId_DefaultContainer);
+ surface2.Attach(&buffer2);
+ shell_surface2.SetRectangularSurfaceShadow(shadow_bounds);
+ surface2.Commit();
+
+ // spoken-feedback was already on, so underlay should fill screen
+ EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(),
+ shell_surface2.shadow_underlay()->bounds());
+
+ // De-activated shell-surface should NOT have fullscreen underlay
+ EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
+
+ // Disable spoken feedback. Shadow underlay is restored.
+ ash::Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
+ ash::A11Y_NOTIFICATION_NONE);
+ shell_surface.OnAccessibilityModeChanged();
+ shell_surface2.OnAccessibilityModeChanged();
+
+ EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
+ EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
+ EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
}
// Make sure that a surface shell started in maximize creates deprecated
« no previous file with comments | « components/exo/shell_surface.cc ('k') | components/exo/wm_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698