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") {
"wm/overlay_event_filter_unittest.cc",
"wm/overlay_layout_manager_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/window_selector_controller_unittest.cc",
"wm/overview/window_selector_unittest.cc",
......
......@@ -25,6 +25,7 @@
#include "ash/wallpaper/wallpaper_view.h"
#include "ash/wallpaper/wallpaper_widget_controller.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 "base/bind.h"
#include "base/command_line.h"
......@@ -1467,8 +1468,7 @@ void WallpaperController::InstallDesktopController(aura::Window* root_window) {
const int container_id = GetWallpaperContainerId(locked_);
float blur = login_constants::kClearBlurSigma;
if (is_wallpaper_blurred) {
blur = session_blocked ? login_constants::kBlurSigma
: WindowSelectorController::kWallpaperBlurSigma;
blur = session_blocked ? login_constants::kBlurSigma : kWallpaperBlurSigma;
}
RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller()
......
......@@ -5,6 +5,7 @@
#include "ash/wm/overview/drop_target_view.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/views/border.h"
#include "ui/views/controls/image_view.h"
......
......@@ -15,9 +15,6 @@ namespace ash {
// be dragged into it and then dropped into overview.
class DropTargetView : public views::View {
public:
// The amount of rounding on window edges in overview mode.
static constexpr int kOverviewWindowRoundingDp = 4;
explicit DropTargetView(bool has_plus_icon);
~DropTargetView() override = default;
......
......@@ -22,6 +22,18 @@ constexpr int kWindowSelectorMargin = kWindowMargin * 2;
// Height of an item header.
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
#endif // ASH_WM_OVERVIEW_OVERVIEW_CONSTANTS_H_
......@@ -10,7 +10,7 @@
#include "ash/public/cpp/window_properties.h"
#include "ash/shell.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/scoped_overview_animation_settings.h"
#include "ash/wm/overview/start_animation_observer.h"
......@@ -130,10 +130,10 @@ class ScopedTransformOverviewWindow::WindowMask : public ui::LayerDelegate,
// transformed, so reverse the transform so the final scaled round matches
// |kOverviewWindowRoundingDp|.
const gfx::Vector2dF scale = window_->transform().Scale2d();
const SkScalar r_x = SkIntToScalar(
std::round(DropTargetView::kOverviewWindowRoundingDp / scale.x()));
const SkScalar r_y = SkIntToScalar(
std::round(DropTargetView::kOverviewWindowRoundingDp / scale.y()));
const SkScalar r_x =
SkIntToScalar(std::round(kOverviewWindowRoundingDp / scale.x()));
const SkScalar r_y =
SkIntToScalar(std::round(kOverviewWindowRoundingDp / scale.y()));
SkPath path;
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(
return new_bounds;
}
gfx::Rect ScopedTransformOverviewWindow::GetMaskBoundsForTesting() const {
if (!mask_)
return gfx::Rect();
return mask_->layer()->bounds();
}
void ScopedTransformOverviewWindow::Close() {
if (immediate_close_for_tests) {
CloseWidget();
......@@ -524,6 +518,12 @@ void ScopedTransformOverviewWindow::OnImplicitAnimationsCompleted() {
selector_item_->OnDragAnimationCompleted();
}
gfx::Rect ScopedTransformOverviewWindow::GetMaskBoundsForTesting() const {
if (!mask_)
return gfx::Rect();
return mask_->layer()->bounds();
}
void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
DCHECK(!minimized_widget_.get());
views::Widget::InitParams params;
......
......@@ -145,8 +145,6 @@ class ASH_EXPORT ScopedTransformOverviewWindow
return window_selector_bounds_;
}
gfx::Rect GetMaskBoundsForTesting() const;
// Closes the transient root of the window managed by |this|.
void Close();
......@@ -184,10 +182,14 @@ class ASH_EXPORT ScopedTransformOverviewWindow
// ui::ImplicitAnimationObserver:
void OnImplicitAnimationsCompleted() override;
gfx::Rect GetMaskBoundsForTesting() const;
private:
friend class WindowSelectorTest;
class LayerCachingAndFilteringObserver;
class WindowMask;
FRIEND_TEST_ALL_PREFIXES(ScopedTransformOverviewWindowTest,
WindowBoundsChangeTest);
// Closes the window managed by |this|.
void CloseWidget();
......
This diff is collapsed.
......@@ -26,6 +26,7 @@
#include "ash/wallpaper/wallpaper_widget_controller.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/rounded_rect_view.h"
#include "ash/wm/overview/scoped_overview_animation_settings.h"
......@@ -84,11 +85,6 @@ constexpr int kWindowSelectionShadowElevation = 24;
// form the shield widgets color.
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.
constexpr int kMaxHeight = 512;
......
......@@ -58,10 +58,6 @@ class ASH_EXPORT WindowGrid : public aura::WindowObserver,
const gfx::Rect& bounds_in_screen);
~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.
static SkColor GetShieldColor();
......
......@@ -15,6 +15,7 @@
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_widget_controller.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/window_grid.h"
#include "ash/wm/overview/window_selector.h"
......
......@@ -34,11 +34,6 @@ class ASH_EXPORT WindowSelectorController
WindowSelectorController();
~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
// at certain times, such as when the lock screen is visible.
static bool CanSelect();
......
This diff is collapsed.
......@@ -12,6 +12,7 @@
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_widget_controller.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/window_grid.h"
#include "ash/wm/overview/window_selector_controller.h"
......@@ -152,8 +153,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
// Blurs the wallpaper background.
RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller()
->SetWallpaperBlur(
static_cast<float>(WindowSelectorController::kWallpaperBlurSigma));
->SetWallpaperBlur(kWallpaperBlurSigma);
// Darken the background.
shield_widget_ = CreateBackgroundWidget(
......@@ -166,7 +166,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
views::View* shield_view = new views::View();
shield_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
shield_view->layer()->SetColor(WindowGrid::GetShieldColor());
shield_view->layer()->SetOpacity(WindowGrid::kShieldOpacity);
shield_view->layer()->SetOpacity(kShieldOpacity);
shield_widget_->SetContentsView(shield_view);
}
......@@ -194,7 +194,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
// Clears the background wallpaper blur.
RootWindowController::ForWindow(dragged_window_->GetRootWindow())
->wallpaper_widget_controller()
->SetWallpaperBlur(WindowSelectorController::kWallpaperClearBlurSigma);
->SetWallpaperBlur(kWallpaperClearBlurSigma);
// Clears the background darken widget.
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