Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2466)

Unified Diff: ash/system/chromeos/power/tablet_power_button_controller_unittest.cc

Issue 2620383003: ash: Add one second grace period For LockScreenIfRequired (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
diff --git a/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc b/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
index a115f49061a8daf283e94d241216e075878b1709..ae61441988753509fcdebe3209107803f37d8e83 100644
--- a/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
+++ b/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
@@ -139,11 +139,15 @@ TEST_F(TabletPowerButtonControllerTest, LockScreenIfRequired) {
// automatic screen-locking was requested.
PressPowerButton();
ReleasePowerButton();
+ EXPECT_TRUE(test_api_->LockScreenTimerIsRunning());
+ EXPECT_FALSE(GetLockedState());
+ test_api_->TriggerLockScreenTimeout();
EXPECT_TRUE(GetLockedState());
// On locked state, power-button-press-release should do nothing.
PressPowerButton();
ReleasePowerButton();
+ EXPECT_FALSE(test_api_->LockScreenTimerIsRunning());
EXPECT_TRUE(GetLockedState());
// Unlock the sceen.
@@ -155,6 +159,26 @@ TEST_F(TabletPowerButtonControllerTest, LockScreenIfRequired) {
SetShouldLockScreenAutomatically(false);
PressPowerButton();
ReleasePowerButton();
+ EXPECT_FALSE(test_api_->LockScreenTimerIsRunning());
+ EXPECT_FALSE(GetLockedState());
+}
+
+// Tests when display is on, quickly tapping power button two times, screen is
+// not locked.
+TEST_F(TabletPowerButtonControllerTest, LockScreenGracePeriodTest) {
+ Initialize(LoginStatus::USER);
+ SetShouldLockScreenAutomatically(true);
+ EXPECT_FALSE(GetLockedState());
+
+ PressPowerButton();
+ ReleasePowerButton();
+ power_manager_client_->SendBrightnessChanged(0, false);
+ EXPECT_TRUE(test_api_->LockScreenTimerIsRunning());
+ PressPowerButton();
+ power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
+ EXPECT_FALSE(test_api_->LockScreenTimerIsRunning());
+ ReleasePowerButton();
+ EXPECT_FALSE(test_api_->LockScreenTimerIsRunning());
EXPECT_FALSE(GetLockedState());
}
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698