Chromium Code Reviews| Index: ash/wm/power_button_controller_unittest.cc |
| diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc |
| index 498349a61310f0512230225d94cdccb75e3f743c..5aeadd91d7afd458c5a25e4410567f3dc723e02c 100644 |
| --- a/ash/wm/power_button_controller_unittest.cc |
| +++ b/ash/wm/power_button_controller_unittest.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/time.h" |
| #include "ui/aura/root_window.h" |
| +#include "ui/aura/window.h" |
| namespace ash { |
| namespace test { |
| @@ -272,6 +273,69 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { |
| EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); |
| } |
| +// Test that we restore transformation that are non empty. |
|
Daniel Erat
2012/02/15 05:50:03
s/transformation/transformations/
alicet1
2012/02/15 20:48:53
Done.
|
| +TEST_F(PowerButtonControllerTest, LockAndUnlockTransformed) { |
| + controller_->set_has_legacy_power_button_for_test(false); |
| + controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/); |
| + controller_->OnLockStateChange(false); |
| + |
| + // Get current transformation on the containers. |
| + aura::Window::Windows windows; |
| + test_api_->GetContainerWindows( |
| + PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| + &windows); |
| + |
| + // Set a random transform to each container layer. |
| + ui::Transform expected_transform; |
| + expected_transform.ConcatTranslate(180, 180); |
| + for (aura::Window::Windows::iterator it = windows.begin(); |
| + it != windows.end(); |
| + ++it) { |
| + (*it)->layer()->SetTransform(expected_transform); |
| + } |
| + |
| + // Press the power button and check that the lock timer is started and that we |
| + // start scaling the non-screen-locker containers. |
| + controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| + 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, |
| + PowerButtonController::ANIMATION_SLOW_CLOSE)); |
| + |
| + // Check current transformation is different than before. |
| + windows.clear(); |
| + test_api_->GetContainerWindows( |
| + PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| + &windows); |
| + for (aura::Window::Windows::iterator it = windows.begin(); |
| + it != windows.end(); |
| + ++it) { |
| + EXPECT_FALSE(expected_transform == (*it)->layer()->GetTargetTransform()); |
|
Daniel Erat
2012/02/15 05:50:03
EXPECT_NE?
alicet1
2012/02/15 20:48:53
Done.
|
| + } |
| + |
| + // 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, |
| + PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE)); |
| + |
| + // Get current transformation on the containers to compare, |
| + // it shouldn't have changed. |
| + windows.clear(); |
| + test_api_->GetContainerWindows( |
| + PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| + &windows); |
| + for (aura::Window::Windows::iterator it = windows.begin(); |
| + it != windows.end(); |
| + ++it) { |
| + EXPECT_EQ(expected_transform, (*it)->layer()->GetTargetTransform()); |
| + } |
| +} |
| + |
| // Hold the power button down from the unlocked state to eventual shutdown. |
| TEST_F(PowerButtonControllerTest, LockToShutdown) { |
| controller_->set_has_legacy_power_button_for_test(false); |