0

Cleanup/Renaming in preparation for larger refactoring

* Added name for wallpaper widget
* Renamed EndPendingAnimation to StopAnimating
* Renamed WallpaperWidgetController::property to GetWallpaperProperty().
  (It'll be delegated to wallpaper view in next CL).
* Added WallpaperView::proeprty(), instead of returning blur_sigma/opacity separately.

Bug: None
Test: None
Change-Id: Ic8aa86990a45e6a99472733f4949861be22dd89e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973963
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726026}
This commit is contained in:
Mitsuru Oshima
2019-12-18 18:36:15 +00:00
committed by Commit Bot
parent e50f2ddffc
commit ad0a5b042d
12 changed files with 33 additions and 25 deletions

@@ -435,11 +435,12 @@ TEST_F(DragWindowFromShelfControllerTest, WallpaperBlurDuringDragging) {
RootWindowController::ForWindow(window->GetRootWindow())
->wallpaper_widget_controller()
->wallpaper_view();
EXPECT_EQ(wallpaper_view->blur_sigma(), overview_constants::kBlurSigma);
EXPECT_EQ(wallpaper_view->property().blur_sigma,
overview_constants::kBlurSigma);
EndDrag(shelf_bounds.CenterPoint(),
/*velocity_y=*/base::nullopt);
EXPECT_EQ(wallpaper_view->blur_sigma(),
EXPECT_EQ(wallpaper_view->property().blur_sigma,
wallpaper_constants::kClear.blur_sigma);
}

@@ -44,6 +44,7 @@ std::unique_ptr<views::Widget> CreateLockScreenWidget(aura::Window* parent) {
params.show_state = ui::SHOW_STATE_FULLSCREEN;
params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent;
params.parent = parent;
params.name = "LockScreenWidget";
widget->Init(std::move(params));
widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
return widget;

@@ -345,7 +345,7 @@ void PowerEventObserver::EndPendingWallpaperAnimations() {
WallpaperWidgetController* wallpaper_widget_controller =
RootWindowController::ForWindow(window)->wallpaper_widget_controller();
if (wallpaper_widget_controller->IsAnimating())
wallpaper_widget_controller->EndPendingAnimation();
wallpaper_widget_controller->StopAnimating();
}
}

@@ -418,7 +418,7 @@ TEST_F(PowerEventObserverTest,
// Simulate wallpaper animation finishing - for the purpose of this test,
// before suspend begins.
wallpaper_widget_controller->EndPendingAnimation();
wallpaper_widget_controller->StopAnimating();
// Expect that two compositing cycles are completed before suspend continues,
// and displays get suspended.

@@ -1464,9 +1464,10 @@ void WallpaperControllerImpl::InstallDesktopController(
auto* wallpaper_widget_controller =
RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller();
WallpaperProperty property = is_wallpaper_blurred_for_lock_state
? wallpaper_constants::kLockState
: wallpaper_widget_controller->property();
WallpaperProperty property =
is_wallpaper_blurred_for_lock_state
? wallpaper_constants::kLockState
: wallpaper_widget_controller->GetWallpaperProperty();
WallpaperView* current_wallpaper_view = nullptr;
auto* widget = CreateWallpaperWidget(root_window, container_id, property,

@@ -1991,8 +1991,8 @@ TEST_F(WallpaperControllerTest, LockDuringOverview) {
->wallpaper_view();
// Make sure that wallpaper still have blur.
ASSERT_EQ(30, wallpaper_view->blur_sigma());
ASSERT_EQ(1, wallpaper_view->opacity());
ASSERT_EQ(30, wallpaper_view->property().blur_sigma);
ASSERT_EQ(1, wallpaper_view->property().opacity);
}
TEST_F(WallpaperControllerTest, OnlyShowDevicePolicyWallpaperOnLoginScreen) {

@@ -26,8 +26,7 @@ class WallpaperView : public WallpaperBaseView,
// Schedules a repaint of the wallpaper with blur and opacity changes.
void SetWallpaperProperty(const WallpaperProperty& property);
int blur_sigma() const { return property_.blur_sigma; }
float opacity() const { return property_.opacity; }
const WallpaperProperty& property() const { return property_; }
private:
// views::View:

@@ -156,7 +156,7 @@ bool WallpaperWidgetController::IsAnimating() const {
return animating_widget_.get();
}
void WallpaperWidgetController::EndPendingAnimation() {
void WallpaperWidgetController::StopAnimating() {
if (!IsAnimating())
return;
animating_widget_->StopAnimating();
@@ -212,6 +212,11 @@ bool WallpaperWidgetController::SetWallpaperProperty(
return true;
}
const WallpaperProperty& WallpaperWidgetController::GetWallpaperProperty()
const {
return property_;
}
void WallpaperWidgetController::ResetWidgetsForTesting() {
animating_widget_.reset();
active_widget_.reset();

@@ -40,7 +40,7 @@ class ASH_EXPORT WallpaperWidgetController {
// If an animating wallpaper change is in progress, it ends the animation and
// changes the wallpaper immediately. No-op if IsAnimation() returns false.
void EndPendingAnimation();
void StopAnimating();
// Adds a callback that will be run when the wallpaper animation ends. Used
// when you're expecting a wallpaper change (e.g. when IsAnimation() returns
@@ -59,8 +59,9 @@ class ASH_EXPORT WallpaperWidgetController {
// Returns true if there was something to reparent.
bool Reparent(aura::Window* root_window, int container);
// Set the properties (blur and opacity) used to draw wallpaper.
// Sets/Gets the properties (blur and opacity) used to draw wallpaper.
bool SetWallpaperProperty(const WallpaperProperty& property);
const WallpaperProperty& GetWallpaperProperty() const;
// TODO: Get the wallpaper view from |animating_widget_| or |active_widget_|
// instead of caching the pointer value.
@@ -70,8 +71,6 @@ class ASH_EXPORT WallpaperWidgetController {
// used in tests to reset the wallpaper widget controller state.
void ResetWidgetsForTesting();
const WallpaperProperty& property() const { return property_; }
private:
// Wrapper around wallpaper widgets that manages the widget state.
class WidgetHandler;

@@ -318,7 +318,7 @@ void LockStateController::PreLockAnimation(
bool request_lock_on_completion) {
saved_property_ = Shell::GetPrimaryRootWindowController()
->wallpaper_widget_controller()
->property();
->GetWallpaperProperty();
Shell::Get()->wallpaper_controller()->UpdateWallpaperBlurForLockState(true);
base::OnceClosure next_animation_starter = base::BindOnce(
&LockStateController::PreLockAnimationFinished,

@@ -715,14 +715,15 @@ TEST_F(LockStateControllerTest, CancelShouldResetWallpaperProperty) {
auto* overview_controller = Shell::Get()->overview_controller();
// Enter Overview and verify wallpaper properties.
overview_controller->StartOverview();
EXPECT_EQ(overview_constants::kBlurSigma, wallpaper_view->blur_sigma());
EXPECT_EQ(overview_constants::kOpacity, wallpaper_view->opacity());
EXPECT_EQ(overview_constants::kBlurSigma,
wallpaper_view->property().blur_sigma);
EXPECT_EQ(overview_constants::kOpacity, wallpaper_view->property().opacity);
// Start lock animation and verify wallpaper properties.
PressLockButton();
ExpectPreLockAnimationStarted();
EXPECT_EQ(login_constants::kBlurSigma, wallpaper_view->blur_sigma());
EXPECT_EQ(1.f, wallpaper_view->opacity());
EXPECT_EQ(login_constants::kBlurSigma, wallpaper_view->property().blur_sigma);
EXPECT_EQ(1.f, wallpaper_view->property().opacity);
// Cancel lock animation.
AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f);
@@ -732,8 +733,9 @@ TEST_F(LockStateControllerTest, CancelShouldResetWallpaperProperty) {
ExpectUnlockedState();
// Verify walpaper properties are restored to overview's.
EXPECT_EQ(overview_constants::kBlurSigma, wallpaper_view->blur_sigma());
EXPECT_EQ(overview_constants::kOpacity, wallpaper_view->opacity());
EXPECT_EQ(overview_constants::kBlurSigma,
wallpaper_view->property().blur_sigma);
EXPECT_EQ(overview_constants::kOpacity, wallpaper_view->property().opacity);
}
} // namespace ash

@@ -89,7 +89,7 @@ void OverviewWallpaperController::StopBlurAnimationsForTesting() {
layer_tree->root()->GetAnimator()->StopAnimating();
for (aura::Window* root : Shell::Get()->GetAllRootWindows()) {
auto* wallpaper_widget_controller = GetWallpaperWidgetController(root);
wallpaper_widget_controller->EndPendingAnimation();
wallpaper_widget_controller->StopAnimating();
GetAnimator(wallpaper_widget_controller)->StopAnimating();
}
}
@@ -120,7 +120,7 @@ void OverviewWallpaperController::OnBlurChange(WallpaperAnimationState state,
continue;
auto* wallpaper_widget_controller = GetWallpaperWidgetController(root);
wallpaper_widget_controller->EndPendingAnimation();
wallpaper_widget_controller->StopAnimating();
auto* wallpaper_window =
wallpaper_widget_controller->GetWidget()->GetNativeWindow();