Index: chromeos/dbus/power_policy_controller_unittest.cc |
diff --git a/chromeos/dbus/power_policy_controller_unittest.cc b/chromeos/dbus/power_policy_controller_unittest.cc |
index f09ad618c9d1ac5077d65fe23d844880c80c8495..96f5f1c278f387852ef6cafd4d773480004dd9ba 100644 |
--- a/chromeos/dbus/power_policy_controller_unittest.cc |
+++ b/chromeos/dbus/power_policy_controller_unittest.cc |
@@ -60,12 +60,12 @@ TEST_F(PowerPolicyControllerTest, Prefs) { |
power_manager::PowerManagementPolicy expected_policy; |
expected_policy.mutable_ac_delays()->set_screen_dim_ms(600000); |
expected_policy.mutable_ac_delays()->set_screen_off_ms(660000); |
- expected_policy.mutable_ac_delays()->set_screen_lock_ms(-1); |
+ expected_policy.mutable_ac_delays()->set_screen_lock_ms(0); |
expected_policy.mutable_ac_delays()->set_idle_warning_ms(-1); |
expected_policy.mutable_ac_delays()->set_idle_ms(720000); |
expected_policy.mutable_battery_delays()->set_screen_dim_ms(300000); |
expected_policy.mutable_battery_delays()->set_screen_off_ms(360000); |
- expected_policy.mutable_battery_delays()->set_screen_lock_ms(-1); |
+ expected_policy.mutable_battery_delays()->set_screen_lock_ms(0); |
expected_policy.mutable_battery_delays()->set_idle_warning_ms(-1); |
expected_policy.mutable_battery_delays()->set_idle_ms(420000); |
expected_policy.set_idle_action( |
@@ -94,23 +94,20 @@ TEST_F(PowerPolicyControllerTest, Prefs) { |
PowerPolicyController::GetPolicyDebugString( |
fake_power_client_.get_policy())); |
- // The enable-screen-lock pref should force the screen-lock delays to |
- // match the screen-off delays. |
- prefs.enable_screen_lock = true; |
+ // Screen lock delays should be ignored if the enable-screen-lock pref is |
+ // false. |
+ prefs.ac_screen_lock_delay_ms = 670000; |
+ prefs.battery_screen_lock_delay_ms = 370000; |
policy_controller_->ApplyPrefs(prefs); |
- expected_policy.mutable_ac_delays()->set_screen_lock_ms(660000); |
- expected_policy.mutable_battery_delays()->set_screen_lock_ms(360000); |
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. |
- prefs.ac_screen_lock_delay_ms = 70000; |
- prefs.battery_screen_lock_delay_ms = 60000; |
+ // After setting the enable-screen-lock pref, the lock delays should be sent. |
+ prefs.enable_screen_lock = true; |
policy_controller_->ApplyPrefs(prefs); |
- expected_policy.mutable_ac_delays()->set_screen_lock_ms(70000); |
- expected_policy.mutable_battery_delays()->set_screen_lock_ms(60000); |
+ expected_policy.mutable_ac_delays()->set_screen_lock_ms(670000); |
+ expected_policy.mutable_battery_delays()->set_screen_lock_ms(370000); |
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
PowerPolicyController::GetPolicyDebugString( |
fake_power_client_.get_policy())); |
@@ -127,6 +124,20 @@ TEST_F(PowerPolicyControllerTest, Prefs) { |
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
PowerPolicyController::GetPolicyDebugString( |
fake_power_client_.get_policy())); |
+ |
+ // Allow screen wake locks and check that the screen-related delays from |
+ // the prefs are overridden. |
+ prefs.allow_screen_wake_locks = true; |
+ policy_controller_->ApplyPrefs(prefs); |
+ 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); |
+ EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
+ PowerPolicyController::GetPolicyDebugString( |
+ fake_power_client_.get_policy())); |
} |
TEST_F(PowerPolicyControllerTest, WakeLocks) { |
@@ -146,8 +157,10 @@ TEST_F(PowerPolicyControllerTest, WakeLocks) { |
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), |