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

Unified Diff: chromeos/dbus/power_policy_controller_unittest.cc

Issue 16346004: Merge 203774 "chromeos: Add delay between screen off and lock." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 years, 6 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 | « chromeos/dbus/power_policy_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/power_policy_controller_unittest.cc
===================================================================
--- chromeos/dbus/power_policy_controller_unittest.cc (revision 204009)
+++ chromeos/dbus/power_policy_controller_unittest.cc (working copy)
@@ -95,17 +95,20 @@
fake_power_client_.get_policy()));
// The enable-screen-lock pref should force the screen-lock delays to
- // match the screen-off delays.
+ // match the screen-off delays plus a constant value.
prefs.enable_screen_lock = true;
policy_controller_->ApplyPrefs(prefs);
- expected_policy.mutable_ac_delays()->set_screen_lock_ms(660000);
- expected_policy.mutable_battery_delays()->set_screen_lock_ms(360000);
+ expected_policy.mutable_ac_delays()->set_screen_lock_ms(
+ 660000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
+ expected_policy.mutable_battery_delays()->set_screen_lock_ms(
+ 360000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
PowerPolicyController::GetPolicyDebugString(
fake_power_client_.get_policy()));
// If the screen-lock-delay prefs are set to lower values than the
- // screen-off delays, the lock prefs should take precedence.
+ // screen-off delays plus the constant, the lock prefs should take
+ // precedence.
prefs.ac_screen_lock_delay_ms = 70000;
prefs.battery_screen_lock_delay_ms = 60000;
policy_controller_->ApplyPrefs(prefs);
@@ -115,6 +118,24 @@
PowerPolicyController::GetPolicyDebugString(
fake_power_client_.get_policy()));
+ // If the artificial screen-lock delays would exceed the idle delay, they
+ // shouldn't be set -- the power manager would ignore them since the
+ // idle action should lock the screen in this case.
+ prefs.ac_screen_off_delay_ms = prefs.ac_idle_delay_ms - 1;
+ prefs.battery_screen_off_delay_ms = prefs.battery_idle_delay_ms - 1;
+ prefs.ac_screen_lock_delay_ms = -1;
+ prefs.battery_screen_lock_delay_ms = -1;
+ policy_controller_->ApplyPrefs(prefs);
+ expected_policy.mutable_ac_delays()->set_screen_off_ms(
+ prefs.ac_screen_off_delay_ms);
+ expected_policy.mutable_battery_delays()->set_screen_off_ms(
+ prefs.battery_screen_off_delay_ms);
+ expected_policy.mutable_ac_delays()->set_screen_lock_ms(-1);
+ expected_policy.mutable_battery_delays()->set_screen_lock_ms(-1);
+ EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
+ PowerPolicyController::GetPolicyDebugString(
+ fake_power_client_.get_policy()));
+
// Set the "allow screen wake locks" pref to false. The system should be
// prevented from suspending due to user inactivity but the pref-supplied
// screen-related delays should be left untouched.
@@ -146,8 +167,10 @@
kScreenWakeLockReason);
expected_policy.mutable_ac_delays()->set_screen_dim_ms(0);
expected_policy.mutable_ac_delays()->set_screen_off_ms(0);
+ expected_policy.mutable_ac_delays()->set_screen_lock_ms(0);
expected_policy.mutable_battery_delays()->set_screen_dim_ms(0);
expected_policy.mutable_battery_delays()->set_screen_off_ms(0);
+ expected_policy.mutable_battery_delays()->set_screen_lock_ms(0);
expected_policy.set_reason(
std::string(kScreenWakeLockReason) + ", " + kSystemWakeLockReason);
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
« no previous file with comments | « chromeos/dbus/power_policy_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698