| Index: ash/wm/lock_state_controller_unittest.cc
|
| diff --git a/ash/wm/lock_state_controller_unittest.cc b/ash/wm/lock_state_controller_unittest.cc
|
| index 7c3f0e25e871e1ba139883a083625b3d68024ccb..faa39cf79cc8f0cbec59585bad117f8d4d223c9b 100644
|
| --- a/ash/wm/lock_state_controller_unittest.cc
|
| +++ b/ash/wm/lock_state_controller_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "ash/shell_window_ids.h"
|
| #include "ash/test/ash_test_base.h"
|
| #include "ash/test/test_lock_state_controller_delegate.h"
|
| +#include "ash/test/test_screenshot_delegate.h"
|
| #include "ash/test/test_shell_delegate.h"
|
| #include "ash/wm/power_button_controller.h"
|
| #include "ash/wm/session_state_animator.h"
|
| @@ -67,7 +68,7 @@ void HideBackground() {
|
| GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide();
|
| }
|
|
|
| -} // namespace
|
| +} // namespace
|
|
|
| class LockStateControllerTest : public AshTestBase {
|
| public:
|
| @@ -124,13 +125,13 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void Advance(SessionStateAnimator::AnimationSpeed speed) {
|
| - // TODO (antrim) : restore
|
| + // TODO(antrim) : restore
|
| // animator_helper_->Advance(SessionStateAnimator::GetDuration(speed));
|
| }
|
|
|
| void AdvancePartially(SessionStateAnimator::AnimationSpeed speed,
|
| float factor) {
|
| -// TODO (antrim) : restore
|
| +// TODO(antrim) : restore
|
| // base::TimeDelta duration = SessionStateAnimator::GetDuration(speed);
|
| // base::TimeDelta partial_duration =
|
| // base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor);
|
| @@ -138,7 +139,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectPreLockAnimationStarted() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| @@ -166,7 +167,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectPreLockAnimationFinished() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| @@ -182,7 +183,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectPostLockAnimationStarted() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
|
| @@ -190,7 +191,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectPastLockAnimationFinished() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
|
| @@ -198,7 +199,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectUnlockBeforeUIDestroyedAnimationStarted() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
|
| @@ -206,7 +207,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectUnlockBeforeUIDestroyedAnimationFinished() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
|
| @@ -214,7 +215,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectUnlockAfterUIDestroyedAnimationStarted() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| @@ -226,7 +227,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectUnlockAfterUIDestroyedAnimationFinished() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| @@ -238,28 +239,28 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectShutdownAnimationStarted() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->RootWindowIsAnimated(
|
| SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS));
|
| }
|
|
|
| void ExpectShutdownAnimationFinished() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->RootWindowIsAnimated(
|
| SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS));
|
| }
|
|
|
| void ExpectShutdownAnimationCancel() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->RootWindowIsAnimated(
|
| SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS));
|
| }
|
|
|
| void ExpectBackgroundIsShowing() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::DESKTOP_BACKGROUND,
|
| @@ -267,7 +268,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectBackgroundIsHiding() {
|
| - //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(
|
| animator_api_->ContainersAreAnimated(
|
| SessionStateAnimator::DESKTOP_BACKGROUND,
|
| @@ -275,7 +276,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectUnlockedState() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_FALSE(session_state_delegate_->IsScreenLocked());
|
|
|
| aura::Window::Windows containers;
|
| @@ -296,7 +297,7 @@ class LockStateControllerTest : public AshTestBase {
|
| }
|
|
|
| void ExpectLockedState() {
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| EXPECT_TRUE(session_state_delegate_->IsScreenLocked());
|
|
|
| aura::Window::Windows containers;
|
| @@ -318,12 +319,12 @@ class LockStateControllerTest : public AshTestBase {
|
|
|
| void PressPowerButton() {
|
| controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
|
| - //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| + // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| }
|
|
|
| void ReleasePowerButton() {
|
| controller_->OnPowerButtonEvent(false, base::TimeTicks::Now());
|
| - //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| + // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| }
|
|
|
| void PressLockButton() {
|
| @@ -334,22 +335,30 @@ class LockStateControllerTest : public AshTestBase {
|
| controller_->OnLockButtonEvent(false, base::TimeTicks::Now());
|
| }
|
|
|
| + void PressVolumeDown() {
|
| + GetEventGenerator().PressKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
|
| + }
|
| +
|
| + void ReleaseVolumeDown() {
|
| + GetEventGenerator().ReleaseKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
|
| + }
|
| +
|
| void SystemLocks() {
|
| lock_state_controller_->OnLockStateChanged(true);
|
| session_state_delegate_->LockScreen();
|
| - //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| + // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| }
|
|
|
| void SuccessfulAuthentication(bool* call_flag) {
|
| base::Closure closure = base::Bind(&CheckCalledCallback, call_flag);
|
| lock_state_controller_->OnLockScreenHide(closure);
|
| - //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| + // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| }
|
|
|
| void SystemUnlocks() {
|
| lock_state_controller_->OnLockStateChanged(false);
|
| session_state_delegate_->UnlockScreen();
|
| - //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| + // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta());
|
| }
|
|
|
| void Initialize(bool legacy_button, user::LoginStatus status) {
|
| @@ -418,7 +427,7 @@ TEST_F(LockStateControllerTest, DISABLED_LegacyLockAndShutDown) {
|
| // Notify that we locked successfully.
|
| lock_state_controller_->OnStartingLock();
|
| // We had that animation already.
|
| - //TODO (antrim) : restore
|
| + // TODO(antrim) : restore
|
| // EXPECT_FALSE(animator_helper_->IsAnimating());
|
|
|
| SystemLocks();
|
| @@ -533,7 +542,7 @@ TEST_F(LockStateControllerTest, DISABLED_LockAndUnlock) {
|
| // Notify that we locked successfully.
|
| lock_state_controller_->OnStartingLock();
|
| // We had that animation already.
|
| - //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
| + // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
|
|
|
| SystemLocks();
|
|
|
| @@ -1090,5 +1099,43 @@ TEST_F(LockStateControllerTest, DISABLED_TestHiddenBackgroundLockUnlock) {
|
| ExpectUnlockedState();
|
| }
|
|
|
| +// Tests that a screenshot can be taken by holding volume down and
|
| +// pressing power.
|
| +TEST_F(LockStateControllerTest, Screenshot) {
|
| + Shell::GetInstance()->lock_state_controller()->SetDelegate(
|
| + new test::TestLockStateControllerDelegate);
|
| + test::TestScreenshotDelegate* delegate = GetScreenshotDelegate();
|
| + delegate->set_can_take_screenshot(true);
|
| +
|
| + // Pressing power alone does not take a screenshot.
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + EXPECT_EQ(0, delegate->handle_take_screenshot_count());
|
| +
|
| + // Press & release volume then pressing power does not take a screenshot.
|
| + ASSERT_EQ(0, delegate->handle_take_screenshot_count());
|
| + PressVolumeDown();
|
| + ReleaseVolumeDown();
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + EXPECT_EQ(0, delegate->handle_take_screenshot_count());
|
| +
|
| + // Pressing power and then volume does not take a screenshot.
|
| + ASSERT_EQ(0, delegate->handle_take_screenshot_count());
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + PressVolumeDown();
|
| + ReleaseVolumeDown();
|
| + EXPECT_EQ(0, delegate->handle_take_screenshot_count());
|
| +
|
| + // Holding volume down and pressing power takes a screenshot.
|
| + ASSERT_EQ(0, delegate->handle_take_screenshot_count());
|
| + PressVolumeDown();
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + ReleaseVolumeDown();
|
| + EXPECT_EQ(1, delegate->handle_take_screenshot_count());
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace ash
|
|
|