diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 10:21:07 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 10:21:07 +0000 |
commit | 4e565304128372540caaf3cf457664c674f6da87 (patch) | |
tree | 0668ce5ac565e5bdd8eaea9227e42e0551042608 /ash/wm | |
parent | c9c672f06a769462db0eb4fb0412337b3d6aefd9 (diff) | |
download | chromium_src-4e565304128372540caaf3cf457664c674f6da87.zip chromium_src-4e565304128372540caaf3cf457664c674f6da87.tar.gz chromium_src-4e565304128372540caaf3cf457664c674f6da87.tar.bz2 |
Improve existing lock transition - remove black splash.
During screen lock we move wallpaper from normal background
layer to screen lock background layer. That means that both
these layers should be excluded from the lock animations.
Lock background layer (with wallpaper, not black solid color layer)
is included in shutdown animation though.
BUG=144737
TEST=Manual: Lock/Shutdown from login screen/user session using power button / shortcut / UI controls.
Review URL: https://chromiumcodereview.appspot.com/10909008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r-- | ash/wm/power_button_controller.cc | 194 | ||||
-rw-r--r-- | ash/wm/power_button_controller.h | 79 | ||||
-rw-r--r-- | ash/wm/power_button_controller_unittest.cc | 200 |
3 files changed, 251 insertions, 222 deletions
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index 55d5993..f44ab9d 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -159,48 +159,43 @@ void RestoreWindow(aura::Window* window) { window->layer()->SetOpacity(1.0); } -// Fills |containers| with the containers described by |group|. -void GetContainers(PowerButtonController::ContainerGroup group, - aura::Window::Windows* containers) { +// Fills |containers| with the containers described by |container_mask|. +void GetContainers(int container_mask, aura::Window::Windows* containers) { aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); - - aura::Window* non_lock_screen_containers = Shell::GetContainer( - root_window, - internal::kShellWindowId_NonLockScreenContainersContainer); - aura::Window* lock_screen_containers = Shell::GetContainer( - root_window, - internal::kShellWindowId_LockScreenContainersContainer); - aura::Window* lock_screen_related_containers = Shell::GetContainer( - root_window, - internal::kShellWindowId_LockScreenRelatedContainersContainer); - containers->clear(); - switch (group) { - case PowerButtonController::ALL_CONTAINERS: - containers->push_back(non_lock_screen_containers); - containers->push_back(lock_screen_containers); - containers->push_back(lock_screen_related_containers); - break; - case PowerButtonController::SCREEN_LOCKER_CONTAINERS: - containers->push_back(lock_screen_containers); - break; - case PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS: - containers->push_back(lock_screen_containers); - containers->push_back(lock_screen_related_containers); - break; - case PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS: - containers->push_back(non_lock_screen_containers); - break; - default: - NOTREACHED() << "Unhandled container group " << group; + + if (container_mask & PowerButtonController::DESKTOP_BACKGROUND) { + containers->push_back(Shell::GetContainer( + root_window, + internal::kShellWindowId_DesktopBackgroundContainer)); + } + if (container_mask & PowerButtonController::NON_LOCK_SCREEN_CONTAINERS) { + containers->push_back(Shell::GetContainer( + root_window, + internal::kShellWindowId_NonLockScreenContainersContainer)); + } + if (container_mask & PowerButtonController::LOCK_SCREEN_BACKGROUND) { + containers->push_back(Shell::GetContainer( + root_window, + internal::kShellWindowId_LockScreenBackgroundContainer)); + } + if (container_mask & PowerButtonController::LOCK_SCREEN_CONTAINERS) { + containers->push_back(Shell::GetContainer( + root_window, + internal::kShellWindowId_LockScreenContainersContainer)); + } + if (container_mask & PowerButtonController::LOCK_SCREEN_RELATED_CONTAINERS) { + containers->push_back(Shell::GetContainer( + root_window, + internal::kShellWindowId_LockScreenRelatedContainersContainer)); } } -// Apply animation |type| to all containers described by |group|. -void StartAnimation(PowerButtonController::ContainerGroup group, +// Apply animation |type| to all containers described by |container_mask|. +void StartAnimation(int container_mask, PowerButtonController::AnimationType type) { aura::Window::Windows containers; - GetContainers(group, &containers); + GetContainers(container_mask, &containers); for (aura::Window::Windows::const_iterator it = containers.begin(); it != containers.end(); ++it) { @@ -232,10 +227,10 @@ void StartAnimation(PowerButtonController::ContainerGroup group, } // namespace -bool PowerButtonController::TestApi::ContainerGroupIsAnimated( - ContainerGroup group, AnimationType type) const { +bool PowerButtonController::TestApi::ContainersAreAnimated( + int container_mask, AnimationType type) const { aura::Window::Windows containers; - GetContainers(group, &containers); + GetContainers(container_mask, &containers); for (aura::Window::Windows::const_iterator it = containers.begin(); it != containers.end(); ++it) { aura::Window* window = *it; @@ -275,16 +270,30 @@ bool PowerButtonController::TestApi::ContainerGroupIsAnimated( return true; } -bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const { - return controller_->background_layer_.get() && - controller_->background_layer_->visible(); +bool PowerButtonController::TestApi::BlackLayerIsVisible() const { + return controller_->black_layer_.get() && + controller_->black_layer_->visible(); } -gfx::Rect PowerButtonController::TestApi::GetBackgroundLayerBounds() const { - ui::Layer* layer = controller_->background_layer_.get(); +gfx::Rect PowerButtonController::TestApi::GetBlackLayerBounds() const { + ui::Layer* layer = controller_->black_layer_.get(); return layer ? layer->bounds() : gfx::Rect(); } +// static +int PowerButtonController::GetAllContainersMask() { + return PowerButtonController::DESKTOP_BACKGROUND | + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS | + GetAllLockScreenContainersMask(); +} + +// static +int PowerButtonController::GetAllLockScreenContainersMask() { + return PowerButtonController::LOCK_SCREEN_BACKGROUND | + PowerButtonController::LOCK_SCREEN_CONTAINERS | + PowerButtonController::LOCK_SCREEN_RELATED_CONTAINERS; +} + PowerButtonController::PowerButtonController() : login_status_(user::LOGGED_IN_NONE), unlocked_login_status_(user::LOGGED_IN_NONE), @@ -315,8 +324,8 @@ void PowerButtonController::OnAppTerminating() { Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_update_cursor_visibility(false); shell->cursor_manager()->ShowCursor(false); - ShowBackgroundLayer(); - StartAnimation(ALL_CONTAINERS, ANIMATION_HIDE); + ShowBlackLayer(); + StartAnimation(GetAllContainersMask(), ANIMATION_HIDE); } } @@ -333,7 +342,7 @@ void PowerButtonController::OnLockStateChanged(bool locked) { } if (locked) { - StartAnimation(SCREEN_LOCKER_CONTAINERS, ANIMATION_FADE_IN); + StartAnimation(LOCK_SCREEN_CONTAINERS, ANIMATION_FADE_IN); lock_timer_.Stop(); lock_fail_timer_.Stop(); @@ -345,9 +354,8 @@ void PowerButtonController::OnLockStateChanged(bool locked) { this, &PowerButtonController::OnLockToShutdownTimeout); } } else { - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_RESTORE); - HideBackgroundLayer(); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_RESTORE); + HideBlackLayer(); } } @@ -359,16 +367,15 @@ void PowerButtonController::OnStartingLock() { if (shutting_down_ || login_status_ == user::LOGGED_IN_LOCKED) return; - // Ensure that the background layer is visible -- if the screen was locked via - // the wrench menu, we won't have already shown the background as part of the - // slow-close animation. - ShowBackgroundLayer(); + // Ensure that the black layer is visible -- if the screen was locked via + // the wrench menu, we won't have already shown the black background + // as part of the slow-close animation. + ShowBlackLayer(); - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_FAST_CLOSE); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_FAST_CLOSE); // Hide the screen locker containers so we can make them fade in later. - StartAnimation(SCREEN_LOCKER_CONTAINERS, ANIMATION_HIDE); + StartAnimation(LOCK_SCREEN_CONTAINERS, ANIMATION_HIDE); } void PowerButtonController::OnPowerButtonEvent( @@ -388,10 +395,9 @@ void PowerButtonController::OnPowerButtonEvent( // running on official hardware, just lock the screen or shut down // immediately. if (down) { - ShowBackgroundLayer(); + ShowBlackLayer(); if (LoggedInAsNonGuest() && login_status_ != user::LOGGED_IN_LOCKED) { - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_SLOW_CLOSE); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_SLOW_CLOSE); OnLockTimeout(); } else { OnShutdownTimeout(); @@ -411,17 +417,17 @@ void PowerButtonController::OnPowerButtonEvent( if (lock_timer_.IsRunning() || shutdown_timer_.IsRunning()) StartAnimation( (login_status_ == user::LOGGED_IN_LOCKED) ? - SCREEN_LOCKER_AND_RELATED_CONTAINERS : ALL_CONTAINERS, + GetAllLockScreenContainersMask() : GetAllContainersMask(), ANIMATION_UNDO_SLOW_CLOSE); - // Drop the background layer after the undo animation finishes. + // Drop the black layer after the undo animation finishes. if (lock_timer_.IsRunning() || (shutdown_timer_.IsRunning() && !LoggedInAsNonGuest())) { - hide_background_layer_timer_.Stop(); - hide_background_layer_timer_.Start( + hide_black_layer_timer_.Stop(); + hide_black_layer_timer_.Start( FROM_HERE, base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), - this, &PowerButtonController::HideBackgroundLayer); + this, &PowerButtonController::HideBlackLayer); } lock_timer_.Stop(); @@ -450,13 +456,12 @@ void PowerButtonController::OnLockButtonEvent( StartLockTimer(); } else { if (lock_timer_.IsRunning()) { - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_UNDO_SLOW_CLOSE); - hide_background_layer_timer_.Stop(); - hide_background_layer_timer_.Start( + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_UNDO_SLOW_CLOSE); + hide_black_layer_timer_.Stop(); + hide_black_layer_timer_.Start( FROM_HERE, base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs), - this, &PowerButtonController::HideBackgroundLayer); + this, &PowerButtonController::HideBlackLayer); lock_timer_.Stop(); } } @@ -469,8 +474,8 @@ void PowerButtonController::RequestShutdown() { void PowerButtonController::OnRootWindowResized(const aura::RootWindow* root, const gfx::Size& new_size) { - if (background_layer_.get()) - background_layer_->SetBounds(gfx::Rect(root->bounds().size())); + if (black_layer_.get()) + black_layer_->SetBounds(gfx::Rect(root->bounds().size())); } void PowerButtonController::OnRootWindowHostCloseRequested( @@ -499,9 +504,8 @@ void PowerButtonController::OnLockTimeout() { void PowerButtonController::OnLockFailTimeout() { DCHECK_NE(login_status_, user::LOGGED_IN_LOCKED); LOG(ERROR) << "Screen lock request timed out"; - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_RESTORE); - HideBackgroundLayer(); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_RESTORE); + HideBlackLayer(); } void PowerButtonController::OnLockToShutdownTimeout() { @@ -520,9 +524,8 @@ void PowerButtonController::OnRealShutdownTimeout() { } void PowerButtonController::StartLockTimer() { - ShowBackgroundLayer(); - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_SLOW_CLOSE); + ShowBlackLayer(); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_SLOW_CLOSE); lock_timer_.Stop(); lock_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), @@ -530,8 +533,8 @@ void PowerButtonController::StartLockTimer() { } void PowerButtonController::StartShutdownTimer() { - ShowBackgroundLayer(); - StartAnimation(ALL_CONTAINERS, ANIMATION_SLOW_CLOSE); + ShowBlackLayer(); + StartAnimation(GetAllContainersMask(), ANIMATION_SLOW_CLOSE); shutdown_timer_.Stop(); shutdown_timer_.Start( FROM_HERE, @@ -547,16 +550,15 @@ void PowerButtonController::StartShutdownAnimationAndRequestShutdown() { shell->env_filter()->set_update_cursor_visibility(false); shell->cursor_manager()->ShowCursor(false); - ShowBackgroundLayer(); + ShowBlackLayer(); if (login_status_ != user::LOGGED_IN_NONE) { // Hide the other containers before starting the animation. // ANIMATION_FAST_CLOSE will make the screen locker windows partially // transparent, and we don't want the other windows to show through. - StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ANIMATION_HIDE); - StartAnimation(SCREEN_LOCKER_AND_RELATED_CONTAINERS, ANIMATION_FAST_CLOSE); + StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_HIDE); + StartAnimation(GetAllLockScreenContainersMask(), ANIMATION_FAST_CLOSE); } else { - StartAnimation(ALL_CONTAINERS, ANIMATION_FAST_CLOSE); + StartAnimation(GetAllContainersMask(), ANIMATION_FAST_CLOSE); } real_shutdown_timer_.Start( @@ -566,24 +568,24 @@ void PowerButtonController::StartShutdownAnimationAndRequestShutdown() { this, &PowerButtonController::OnRealShutdownTimeout); } -void PowerButtonController::ShowBackgroundLayer() { - if (hide_background_layer_timer_.IsRunning()) - hide_background_layer_timer_.Stop(); +void PowerButtonController::ShowBlackLayer() { + if (hide_black_layer_timer_.IsRunning()) + hide_black_layer_timer_.Stop(); - if (!background_layer_.get()) { - background_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); - background_layer_->SetColor(SK_ColorBLACK); + if (!black_layer_.get()) { + black_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); + black_layer_->SetColor(SK_ColorBLACK); ui::Layer* root_layer = Shell::GetPrimaryRootWindow()->layer(); - background_layer_->SetBounds(root_layer->bounds()); - root_layer->Add(background_layer_.get()); - root_layer->StackAtBottom(background_layer_.get()); + black_layer_->SetBounds(root_layer->bounds()); + root_layer->Add(black_layer_.get()); + root_layer->StackAtBottom(black_layer_.get()); } - background_layer_->SetVisible(true); + black_layer_->SetVisible(true); } -void PowerButtonController::HideBackgroundLayer() { - background_layer_.reset(); +void PowerButtonController::HideBlackLayer() { + black_layer_.reset(); } } // namespace ash diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h index eee5f1c..1bb4d32 100644 --- a/ash/wm/power_button_controller.h +++ b/ash/wm/power_button_controller.h @@ -43,7 +43,7 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, public ShellObserver { public: // Animations that can be applied to groups of containers. - // Exposed here for TestApi::ContainerGroupIsAnimated(). + // Exposed here for TestApi::ContainersAreAnimated(). enum AnimationType { ANIMATION_SLOW_CLOSE = 0, ANIMATION_UNDO_SLOW_CLOSE, @@ -53,13 +53,27 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, ANIMATION_RESTORE, }; - // Groups of containers that can be animated. - // Exposed here for TestApi::ContainerGroupIsAnimated(). - enum ContainerGroup { - ALL_CONTAINERS = 0, - SCREEN_LOCKER_CONTAINERS, - SCREEN_LOCKER_AND_RELATED_CONTAINERS, - ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + // Specific containers or groups of containers that can be animated. + // Exposed here for TestApi::ContainersAreAnimated(). + enum Container { + DESKTOP_BACKGROUND = 1 << 0, + + // All user session related containers including system background but + // not including desktop background (wallpaper). + NON_LOCK_SCREEN_CONTAINERS = 1 << 1, + + // Desktop wallpaper is moved to this layer when screen is locked. + // This layer is excluded from lock animation so that wallpaper stays as is, + // user session windows are hidden and lock UI is shown on top of it. + // This layer is included in shutdown animation. + LOCK_SCREEN_BACKGROUND = 1 << 2, + + // Lock screen and lock screen modal containers. + LOCK_SCREEN_CONTAINERS = 1 << 3, + + // Multiple system layers belong here like status, menu, tooltip + // and overlay layers. + LOCK_SCREEN_RELATED_CONTAINERS = 1 << 4, }; // Helper class used by tests to access internal state. @@ -83,8 +97,8 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, bool real_shutdown_timer_is_running() const { return controller_->real_shutdown_timer_.IsRunning(); } - bool hide_background_layer_timer_is_running() const { - return controller_->hide_background_layer_timer_.IsRunning(); + bool hide_black_layer_timer_is_running() const { + return controller_->hide_black_layer_timer_.IsRunning(); } void trigger_lock_timeout() { @@ -107,22 +121,22 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, controller_->OnRealShutdownTimeout(); controller_->real_shutdown_timer_.Stop(); } - void trigger_hide_background_layer_timeout() { - controller_->HideBackgroundLayer(); - controller_->hide_background_layer_timer_.Stop(); + void trigger_hide_black_layer_timeout() { + controller_->HideBlackLayer(); + controller_->hide_black_layer_timer_.Stop(); } - // Returns true if the given set of containers was last animated with - // |type| (probably; the analysis is fairly ad-hoc). - bool ContainerGroupIsAnimated(ContainerGroup group, - AnimationType type) const; + // Returns true if containers of a given |container_mask| + // were last animated with |type| (probably; the analysis is fairly ad-hoc). + // |container_mask| is a bitfield of a Container. + bool ContainersAreAnimated(int container_mask, AnimationType type) const; - // Returns true if |background_layer_| is non-NULL and visible. - bool BackgroundLayerIsVisible() const; + // Returns true if |black_layer_| is non-NULL and visible. + bool BlackLayerIsVisible() const; - // Returns |background_layer_|'s bounds, or an empty rect if the layer is + // Returns |black_layer_|'s bounds, or an empty rect if the layer is // NULL. - gfx::Rect GetBackgroundLayerBounds() const; + gfx::Rect GetBlackLayerBounds() const; private: PowerButtonController* controller_; // not owned @@ -130,6 +144,13 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, DISALLOW_COPY_AND_ASSIGN(TestApi); }; + // Helper method that returns a bitfield mask of all containers. + static int GetAllContainersMask(); + + // Helper method that returns a bitfield mask including LOCK_SCREEN_WALLPAPER, + // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. + static int GetAllLockScreenContainersMask(); + PowerButtonController(); virtual ~PowerButtonController(); @@ -190,10 +211,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, // Displays the shutdown animation and starts |real_shutdown_timer_|. void StartShutdownAnimationAndRequestShutdown(); - // Shows or hides |background_layer_|. The show method creates and + // Shows or hides |black_layer_|. The show method creates and // initializes the layer if it doesn't already exist. - void ShowBackgroundLayer(); - void HideBackgroundLayer(); + void ShowBlackLayer(); + void HideBlackLayer(); scoped_ptr<PowerButtonControllerDelegate> delegate_; @@ -213,10 +234,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, // Are we in the process of shutting the machine down? bool shutting_down_; - // Should we start |shutdown_timer_| when we receive notification that the - // screen has been locked? - bool should_start_shutdown_timer_after_lock_; - // Was a command-line switch set telling us that we're running on hardware // that misreports power button releases? bool has_legacy_power_button_; @@ -226,7 +243,7 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, // TODO(derat): Remove this in favor of having the compositor only clear the // viewport when there are regions not covered by a layer: // http://crbug.com/113445 - scoped_ptr<ui::Layer> background_layer_; + scoped_ptr<ui::Layer> black_layer_; // Started when the user first presses the power button while in a // logged-in-as-a-non-guest-user, unlocked state. When it fires, we lock the @@ -252,9 +269,9 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, base::OneShotTimer<PowerButtonController> real_shutdown_timer_; // Started when we abort the pre-lock state. When it fires, we hide - // |background_layer_|, as the desktop background is now covering the whole + // |black_layer_|, as the desktop background is now covering the whole // screen. - base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; + base::OneShotTimer<PowerButtonController> hide_black_layer_timer_; DISALLOW_COPY_AND_ASSIGN(PowerButtonController); }; diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc index b84a071..10b6a78 100644 --- a/ash/wm/power_button_controller_unittest.cc +++ b/ash/wm/power_button_controller_unittest.cc @@ -83,30 +83,30 @@ TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) { // power button get pressed. controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); - EXPECT_FALSE(test_api_->hide_background_layer_timer_is_running()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); + EXPECT_FALSE(test_api_->hide_black_layer_timer_is_running()); EXPECT_FALSE(test_api_->lock_timer_is_running()); EXPECT_EQ(1, delegate_->num_lock_requests()); // Notify that we locked successfully. controller_->OnStartingLock(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_FAST_CLOSE)); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_HIDE)); // Notify that the lock window is visible. We should make it fade in. controller_->OnLockStateChanged(true); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FADE_IN)); // We shouldn't progress towards the shutdown state, however. @@ -117,9 +117,19 @@ TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) { // Hold the button again and check that we start shutting down. controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); EXPECT_EQ(0, delegate_->num_shutdown_requests()); + + // Previously we're checking that the all containers group was animated which + // was in fact checking that + // 1. All user session containers have transform (including wallpaper). + // They're in this state after lock. + // 2. Screen locker and related containers are in fact animating + // (as shutdown is in progress). + // With http://crbug.com/144737 we no longer animate user session wallpaper + // during lock so it makes sense only to check that screen lock and related + // containers are animated during shutdown. EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FAST_CLOSE)); EXPECT_FALSE(cursor_visible()); EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); @@ -153,32 +163,32 @@ TEST_F(PowerButtonControllerTest, ShutdownWhenNotLoggedIn) { controller_->set_has_legacy_power_button_for_test(false); controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); controller_->OnLockStateChanged(false); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); // Press the power button and check that we start the shutdown timer. controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); EXPECT_FALSE(test_api_->lock_timer_is_running()); EXPECT_TRUE(test_api_->shutdown_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllContainersMask(), PowerButtonController::ANIMATION_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); // Release the power button before the shutdown timer fires. controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); EXPECT_FALSE(test_api_->shutdown_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllContainersMask(), PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); - // We should re-hide the black background layer after waiting long enough for + // We should re-hide the black layer after waiting long enough for // the animation to finish. - EXPECT_TRUE(test_api_->hide_background_layer_timer_is_running()); - test_api_->trigger_hide_background_layer_timeout(); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->hide_black_layer_timer_is_running()); + test_api_->trigger_hide_black_layer_timeout(); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); // Press the button again and make the shutdown timeout fire this time. // Check that we start the timer for actually requesting the shutdown. @@ -188,12 +198,12 @@ TEST_F(PowerButtonControllerTest, ShutdownWhenNotLoggedIn) { EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); EXPECT_EQ(0, delegate_->num_shutdown_requests()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_HIDE)); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FAST_CLOSE)); // When the timout fires, we should request a shutdown. @@ -206,14 +216,14 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { controller_->set_has_legacy_power_button_for_test(false); controller_->OnLoginStateChanged(user::LOGGED_IN_USER); controller_->OnLockStateChanged(false); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); // We should initially be showing the screen locker containers, since they // also contain login-related windows that we want to show during the // logging-in animation. EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_RESTORE)); // Press the power button and check that the lock timer is started and that we @@ -222,22 +232,22 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { EXPECT_TRUE(test_api_->lock_timer_is_running()); EXPECT_FALSE(test_api_->shutdown_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); // Release the button before the lock timer fires. controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); EXPECT_FALSE(test_api_->lock_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); - EXPECT_TRUE(test_api_->hide_background_layer_timer_is_running()); - test_api_->trigger_hide_background_layer_timeout(); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); + EXPECT_TRUE(test_api_->hide_black_layer_timer_is_running()); + test_api_->trigger_hide_black_layer_timeout(); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); // Press the button and fire the lock timer. We should request that the // screen be locked, but we should still be in the slow-close animation. @@ -247,27 +257,27 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { test_api_->trigger_lock_timeout(); EXPECT_EQ(1, delegate_->num_lock_requests()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); // Notify that we locked successfully. controller_->OnStartingLock(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_FAST_CLOSE)); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_HIDE)); // Notify that the lock window is visible. We should make it fade in. controller_->OnLockStateChanged(true); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FADE_IN)); // When we release the power button, the lock-to-shutdown timer should be @@ -277,13 +287,13 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); // Notify that the screen has been unlocked. We should show the - // non-screen-locker windows and hide the background layer. + // non-screen-locker windows and hide the black layer. controller_->OnLockStateChanged(false); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_RESTORE)); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); } // Hold the power button down from the unlocked state to eventual shutdown. @@ -298,7 +308,7 @@ TEST_F(PowerButtonControllerTest, LockToShutdown) { test_api_->trigger_lock_timeout(); controller_->OnStartingLock(); controller_->OnLockStateChanged(true); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); // When the lock-to-shutdown timeout fires, we should start the shutdown // timer. @@ -306,8 +316,8 @@ TEST_F(PowerButtonControllerTest, LockToShutdown) { test_api_->trigger_lock_to_shutdown_timeout(); EXPECT_TRUE(test_api_->shutdown_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllContainersMask(), PowerButtonController::ANIMATION_SLOW_CLOSE)); // Fire the shutdown timeout and check that we request shutdown. @@ -316,7 +326,7 @@ TEST_F(PowerButtonControllerTest, LockToShutdown) { EXPECT_EQ(0, delegate_->num_shutdown_requests()); test_api_->trigger_real_shutdown_timeout(); EXPECT_EQ(1, delegate_->num_shutdown_requests()); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); } // Test that we handle the case where lock requests are ignored. @@ -332,10 +342,10 @@ TEST_F(PowerButtonControllerTest, LockFail) { controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); EXPECT_TRUE(test_api_->lock_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_RESTORE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); test_api_->trigger_lock_timeout(); EXPECT_EQ(1, delegate_->num_lock_requests()); EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); @@ -347,13 +357,13 @@ TEST_F(PowerButtonControllerTest, LockFail) { // Act as if the request timed out. We should restore the windows. test_api_->trigger_lock_fail_timeout(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_RESTORE)); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); } -// Test that we start the timer to hide the background layer when the power +// Test that we start the timer to hide the black layer when the power // button is released, but that we cancel the timer if the button is pressed // again before the timer has fired. TEST_F(PowerButtonControllerTest, CancelHideBackground) { @@ -363,11 +373,11 @@ TEST_F(PowerButtonControllerTest, CancelHideBackground) { controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); - EXPECT_TRUE(test_api_->hide_background_layer_timer_is_running()); + EXPECT_TRUE(test_api_->hide_black_layer_timer_is_running()); // We should cancel the timer if we get another button-down event. controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); - EXPECT_FALSE(test_api_->hide_background_layer_timer_is_running()); + EXPECT_FALSE(test_api_->hide_black_layer_timer_is_running()); } // Test the basic operation of the lock button. @@ -394,22 +404,22 @@ TEST_F(PowerButtonControllerTest, LockButtonBasic) { controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); EXPECT_TRUE(test_api_->lock_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); // If the button is released immediately, we shouldn't lock the screen. controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); EXPECT_FALSE(test_api_->lock_timer_is_running()); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); - EXPECT_TRUE(test_api_->hide_background_layer_timer_is_running()); - test_api_->trigger_hide_background_layer_timeout(); - EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); + EXPECT_TRUE(test_api_->hide_black_layer_timer_is_running()); + test_api_->trigger_hide_black_layer_timeout(); + EXPECT_FALSE(test_api_->BlackLayerIsVisible()); EXPECT_EQ(0, delegate_->num_lock_requests()); // Press the button again and let the lock timeout fire. We should request @@ -467,15 +477,15 @@ TEST_F(PowerButtonControllerTest, PowerButtonPreemptsLockButton) { // When the screen is locked without going through the usual power-button // slow-close path (e.g. via the wrench menu), test that we still show the -// fast-close animation and display the background layer. +// fast-close animation and display the black layer. TEST_F(PowerButtonControllerTest, LockWithoutButton) { controller_->OnLoginStateChanged(user::LOGGED_IN_USER); controller_->OnStartingLock(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_FAST_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); } // When we hear that the process is exiting but we haven't had a chance to @@ -484,10 +494,10 @@ TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) { controller_->OnLoginStateChanged(user::LOGGED_IN_USER); controller_->OnAppTerminating(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllContainersMask(), PowerButtonController::ANIMATION_HIDE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); EXPECT_FALSE(cursor_visible()); } @@ -497,14 +507,14 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) { controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); controller_->RequestShutdown(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_HIDE)); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FAST_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); EXPECT_FALSE(cursor_visible()); EXPECT_EQ(0, delegate_->num_shutdown_requests()); @@ -518,14 +528,14 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { controller_->OnLockStateChanged(true); controller_->RequestShutdown(); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, PowerButtonController::ANIMATION_HIDE)); EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, + test_api_->ContainersAreAnimated( + PowerButtonController::GetAllLockScreenContainersMask(), PowerButtonController::ANIMATION_FAST_CLOSE)); - EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); + EXPECT_TRUE(test_api_->BlackLayerIsVisible()); EXPECT_FALSE(cursor_visible()); EXPECT_EQ(0, delegate_->num_shutdown_requests()); @@ -534,16 +544,16 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { EXPECT_EQ(1, delegate_->num_shutdown_requests()); } -// Test that the background layer is resized in response to root window resizes. -TEST_F(PowerButtonControllerTest, ResizeBackgroundLayer) { +// Test that the black layer is resized in response to root window resizes. +TEST_F(PowerButtonControllerTest, ResizeBlackLayer) { controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); EXPECT_EQ(Shell::GetPrimaryRootWindow()->bounds().ToString(), - test_api_->GetBackgroundLayerBounds().ToString()); + test_api_->GetBlackLayerBounds().ToString()); const gfx::Size kNewSize(400, 300); Shell::GetPrimaryRootWindow()->SetHostSize(kNewSize); EXPECT_EQ(gfx::Rect(kNewSize).ToString(), - test_api_->GetBackgroundLayerBounds().ToString()); + test_api_->GetBlackLayerBounds().ToString()); } // Test that we ignore power button presses when the screen is turned off. |