Commit acbdf928 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Introduce ScopedTransformOverviewWindowTest.

This cl:
1) Moves a bunch of tests from WindowSelectorTest to new
ScopedTransformOverviewWindowTest file.
2) Moves some static class constants to a newly introduced overview
constants file.

Test: ash_unittests ScopedTransformOverviewWindowTest*
Bug: 914147
Change-Id: I1c81533a0d0cb245c05ce4a4d288b574c0fc1784
Reviewed-on: https://chromium-review.googlesource.com/c/1394324
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619799}
parent cd81c8b9
...@@ -1836,6 +1836,7 @@ test("ash_unittests") { ...@@ -1836,6 +1836,7 @@ test("ash_unittests") {
"wm/overlay_event_filter_unittest.cc", "wm/overlay_event_filter_unittest.cc",
"wm/overlay_layout_manager_unittest.cc", "wm/overlay_layout_manager_unittest.cc",
"wm/overview/cleanup_animation_observer_unittest.cc", "wm/overview/cleanup_animation_observer_unittest.cc",
"wm/overview/scoped_transform_overview_window_unittest.cc",
"wm/overview/start_animation_observer_unittest.cc", "wm/overview/start_animation_observer_unittest.cc",
"wm/overview/window_selector_controller_unittest.cc", "wm/overview/window_selector_controller_unittest.cc",
"wm/overview/window_selector_unittest.cc", "wm/overview/window_selector_unittest.cc",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ash/wallpaper/wallpaper_view.h" #include "ash/wallpaper/wallpaper_view.h"
#include "ash/wallpaper/wallpaper_widget_controller.h" #include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wallpaper/wallpaper_window_state_manager.h" #include "ash/wallpaper/wallpaper_window_state_manager.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/window_selector_controller.h" #include "ash/wm/overview/window_selector_controller.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -1467,8 +1468,7 @@ void WallpaperController::InstallDesktopController(aura::Window* root_window) { ...@@ -1467,8 +1468,7 @@ void WallpaperController::InstallDesktopController(aura::Window* root_window) {
const int container_id = GetWallpaperContainerId(locked_); const int container_id = GetWallpaperContainerId(locked_);
float blur = login_constants::kClearBlurSigma; float blur = login_constants::kClearBlurSigma;
if (is_wallpaper_blurred) { if (is_wallpaper_blurred) {
blur = session_blocked ? login_constants::kBlurSigma blur = session_blocked ? login_constants::kBlurSigma : kWallpaperBlurSigma;
: WindowSelectorController::kWallpaperBlurSigma;
} }
RootWindowController::ForWindow(root_window) RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller() ->wallpaper_widget_controller()
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/wm/overview/drop_target_view.h" #include "ash/wm/overview/drop_target_view.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/wm/overview/overview_constants.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
......
...@@ -15,9 +15,6 @@ namespace ash { ...@@ -15,9 +15,6 @@ namespace ash {
// be dragged into it and then dropped into overview. // be dragged into it and then dropped into overview.
class DropTargetView : public views::View { class DropTargetView : public views::View {
public: public:
// The amount of rounding on window edges in overview mode.
static constexpr int kOverviewWindowRoundingDp = 4;
explicit DropTargetView(bool has_plus_icon); explicit DropTargetView(bool has_plus_icon);
~DropTargetView() override = default; ~DropTargetView() override = default;
......
...@@ -22,6 +22,18 @@ constexpr int kWindowSelectorMargin = kWindowMargin * 2; ...@@ -22,6 +22,18 @@ constexpr int kWindowSelectorMargin = kWindowMargin * 2;
// Height of an item header. // Height of an item header.
constexpr int kHeaderHeightDp = 40; constexpr int kHeaderHeightDp = 40;
// The opacity of the shield widget that is used to darken the background of
// the grid.
constexpr float kShieldOpacity = 0.4f;
// The amount of rounding on window edges in overview mode.
constexpr int kOverviewWindowRoundingDp = 4;
// Amount of blur to apply on the wallpaper when we enter or exit overview
// mode.
constexpr float kWallpaperBlurSigma = 10.f;
constexpr float kWallpaperClearBlurSigma = 0.f;
} // namespace ash } // namespace ash
#endif // ASH_WM_OVERVIEW_OVERVIEW_CONSTANTS_H_ #endif // ASH_WM_OVERVIEW_OVERVIEW_CONSTANTS_H_
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/overview/cleanup_animation_observer.h" #include "ash/wm/overview/cleanup_animation_observer.h"
#include "ash/wm/overview/drop_target_view.h" #include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_utils.h" #include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/scoped_overview_animation_settings.h" #include "ash/wm/overview/scoped_overview_animation_settings.h"
#include "ash/wm/overview/start_animation_observer.h" #include "ash/wm/overview/start_animation_observer.h"
...@@ -130,10 +130,10 @@ class ScopedTransformOverviewWindow::WindowMask : public ui::LayerDelegate, ...@@ -130,10 +130,10 @@ class ScopedTransformOverviewWindow::WindowMask : public ui::LayerDelegate,
// transformed, so reverse the transform so the final scaled round matches // transformed, so reverse the transform so the final scaled round matches
// |kOverviewWindowRoundingDp|. // |kOverviewWindowRoundingDp|.
const gfx::Vector2dF scale = window_->transform().Scale2d(); const gfx::Vector2dF scale = window_->transform().Scale2d();
const SkScalar r_x = SkIntToScalar( const SkScalar r_x =
std::round(DropTargetView::kOverviewWindowRoundingDp / scale.x())); SkIntToScalar(std::round(kOverviewWindowRoundingDp / scale.x()));
const SkScalar r_y = SkIntToScalar( const SkScalar r_y =
std::round(DropTargetView::kOverviewWindowRoundingDp / scale.y())); SkIntToScalar(std::round(kOverviewWindowRoundingDp / scale.y()));
SkPath path; SkPath path;
SkScalar radii[8] = {r_x, r_y, r_x, r_y, r_x, r_y, r_x, r_y}; SkScalar radii[8] = {r_x, r_y, r_x, r_y, r_x, r_y, r_x, r_y};
...@@ -397,12 +397,6 @@ gfx::Rect ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( ...@@ -397,12 +397,6 @@ gfx::Rect ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
return new_bounds; return new_bounds;
} }
gfx::Rect ScopedTransformOverviewWindow::GetMaskBoundsForTesting() const {
if (!mask_)
return gfx::Rect();
return mask_->layer()->bounds();
}
void ScopedTransformOverviewWindow::Close() { void ScopedTransformOverviewWindow::Close() {
if (immediate_close_for_tests) { if (immediate_close_for_tests) {
CloseWidget(); CloseWidget();
...@@ -524,6 +518,12 @@ void ScopedTransformOverviewWindow::OnImplicitAnimationsCompleted() { ...@@ -524,6 +518,12 @@ void ScopedTransformOverviewWindow::OnImplicitAnimationsCompleted() {
selector_item_->OnDragAnimationCompleted(); selector_item_->OnDragAnimationCompleted();
} }
gfx::Rect ScopedTransformOverviewWindow::GetMaskBoundsForTesting() const {
if (!mask_)
return gfx::Rect();
return mask_->layer()->bounds();
}
void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() { void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
DCHECK(!minimized_widget_.get()); DCHECK(!minimized_widget_.get());
views::Widget::InitParams params; views::Widget::InitParams params;
......
...@@ -145,8 +145,6 @@ class ASH_EXPORT ScopedTransformOverviewWindow ...@@ -145,8 +145,6 @@ class ASH_EXPORT ScopedTransformOverviewWindow
return window_selector_bounds_; return window_selector_bounds_;
} }
gfx::Rect GetMaskBoundsForTesting() const;
// Closes the transient root of the window managed by |this|. // Closes the transient root of the window managed by |this|.
void Close(); void Close();
...@@ -184,10 +182,14 @@ class ASH_EXPORT ScopedTransformOverviewWindow ...@@ -184,10 +182,14 @@ class ASH_EXPORT ScopedTransformOverviewWindow
// ui::ImplicitAnimationObserver: // ui::ImplicitAnimationObserver:
void OnImplicitAnimationsCompleted() override; void OnImplicitAnimationsCompleted() override;
gfx::Rect GetMaskBoundsForTesting() const;
private: private:
friend class WindowSelectorTest; friend class WindowSelectorTest;
class LayerCachingAndFilteringObserver; class LayerCachingAndFilteringObserver;
class WindowMask; class WindowMask;
FRIEND_TEST_ALL_PREFIXES(ScopedTransformOverviewWindowTest,
WindowBoundsChangeTest);
// Closes the window managed by |this|. // Closes the window managed by |this|.
void CloseWidget(); void CloseWidget();
......
This diff is collapsed.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ash/wallpaper/wallpaper_widget_controller.h" #include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/overview/cleanup_animation_observer.h" #include "ash/wm/overview/cleanup_animation_observer.h"
#include "ash/wm/overview/drop_target_view.h" #include "ash/wm/overview/drop_target_view.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_utils.h" #include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/rounded_rect_view.h" #include "ash/wm/overview/rounded_rect_view.h"
#include "ash/wm/overview/scoped_overview_animation_settings.h" #include "ash/wm/overview/scoped_overview_animation_settings.h"
...@@ -84,11 +85,6 @@ constexpr int kWindowSelectionShadowElevation = 24; ...@@ -84,11 +85,6 @@ constexpr int kWindowSelectionShadowElevation = 24;
// form the shield widgets color. // form the shield widgets color.
constexpr SkColor kShieldBaseColor = SkColorSetARGB(179, 0, 0, 0); constexpr SkColor kShieldBaseColor = SkColorSetARGB(179, 0, 0, 0);
// In the conceptual overview table, the window margin is the space reserved
// around the window within the cell. This margin does not overlap so the
// closest distance between adjacent windows will be twice this amount.
constexpr int kWindowMargin = 5;
// Windows are not allowed to get taller than this. // Windows are not allowed to get taller than this.
constexpr int kMaxHeight = 512; constexpr int kMaxHeight = 512;
......
...@@ -58,10 +58,6 @@ class ASH_EXPORT WindowGrid : public aura::WindowObserver, ...@@ -58,10 +58,6 @@ class ASH_EXPORT WindowGrid : public aura::WindowObserver,
const gfx::Rect& bounds_in_screen); const gfx::Rect& bounds_in_screen);
~WindowGrid() override; ~WindowGrid() override;
// The opacity of the shield widget that is used to darken the background of
// the grid.
static constexpr float kShieldOpacity = 0.4f;
// Returns the shield color that is used to darken the background of the grid. // Returns the shield color that is used to darken the background of the grid.
static SkColor GetShieldColor(); static SkColor GetShieldColor();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ash/wallpaper/wallpaper_controller.h" #include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_widget_controller.h" #include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_utils.h" #include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/window_grid.h" #include "ash/wm/overview/window_grid.h"
#include "ash/wm/overview/window_selector.h" #include "ash/wm/overview/window_selector.h"
......
...@@ -34,11 +34,6 @@ class ASH_EXPORT WindowSelectorController ...@@ -34,11 +34,6 @@ class ASH_EXPORT WindowSelectorController
WindowSelectorController(); WindowSelectorController();
~WindowSelectorController() override; ~WindowSelectorController() override;
// Amount of blur to apply on the wallpaper when we enter or exit overview
// mode.
static constexpr float kWallpaperBlurSigma = 10.f;
static constexpr float kWallpaperClearBlurSigma = 0.f;
// Returns true if selecting windows in an overview is enabled. This is false // Returns true if selecting windows in an overview is enabled. This is false
// at certain times, such as when the lock screen is visible. // at certain times, such as when the lock screen is visible.
static bool CanSelect(); static bool CanSelect();
......
This diff is collapsed.
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wallpaper/wallpaper_widget_controller.h" #include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_utils.h" #include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/window_grid.h" #include "ash/wm/overview/window_grid.h"
#include "ash/wm/overview/window_selector_controller.h" #include "ash/wm/overview/window_selector_controller.h"
...@@ -152,8 +153,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider ...@@ -152,8 +153,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
// Blurs the wallpaper background. // Blurs the wallpaper background.
RootWindowController::ForWindow(root_window) RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller() ->wallpaper_widget_controller()
->SetWallpaperBlur( ->SetWallpaperBlur(kWallpaperBlurSigma);
static_cast<float>(WindowSelectorController::kWallpaperBlurSigma));
// Darken the background. // Darken the background.
shield_widget_ = CreateBackgroundWidget( shield_widget_ = CreateBackgroundWidget(
...@@ -166,7 +166,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider ...@@ -166,7 +166,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
views::View* shield_view = new views::View(); views::View* shield_view = new views::View();
shield_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR); shield_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
shield_view->layer()->SetColor(WindowGrid::GetShieldColor()); shield_view->layer()->SetColor(WindowGrid::GetShieldColor());
shield_view->layer()->SetOpacity(WindowGrid::kShieldOpacity); shield_view->layer()->SetOpacity(kShieldOpacity);
shield_widget_->SetContentsView(shield_view); shield_widget_->SetContentsView(shield_view);
} }
...@@ -194,7 +194,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider ...@@ -194,7 +194,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
// Clears the background wallpaper blur. // Clears the background wallpaper blur.
RootWindowController::ForWindow(dragged_window_->GetRootWindow()) RootWindowController::ForWindow(dragged_window_->GetRootWindow())
->wallpaper_widget_controller() ->wallpaper_widget_controller()
->SetWallpaperBlur(WindowSelectorController::kWallpaperClearBlurSigma); ->SetWallpaperBlur(kWallpaperClearBlurSigma);
// Clears the background darken widget. // Clears the background darken widget.
shield_widget_.reset(); shield_widget_.reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment