| 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 513dd3822b859bb10d95e202e95c32a913cb23c1..a2c1eb60d2beea08b1c4d55f0b99bc2f515ee1c7 100644
|
| --- a/chromeos/dbus/power_policy_controller_unittest.cc
|
| +++ b/chromeos/dbus/power_policy_controller_unittest.cc
|
| @@ -91,7 +91,7 @@
|
| expected_policy.set_reason("Prefs");
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| // Change some prefs and check that an updated policy is sent.
|
| prefs.ac_idle_warning_delay_ms = 700000;
|
| @@ -106,7 +106,7 @@
|
| expected_policy.clear_ac_brightness_percent();
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| // The enable-screen-lock pref should force the screen-lock delays to
|
| // match the screen-off delays plus a constant value.
|
| @@ -118,7 +118,7 @@
|
| 360000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| // If the screen-lock-delay prefs are set to lower values than the
|
| // screen-off delays plus the constant, the lock prefs should take
|
| @@ -130,7 +130,7 @@
|
| expected_policy.mutable_battery_delays()->set_screen_lock_ms(60000);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->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
|
| @@ -148,7 +148,7 @@
|
| expected_policy.mutable_battery_delays()->set_screen_lock_ms(-1);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| // Set the "allow screen wake locks" pref to false. The system should be
|
| // prevented from suspending due to user inactivity on AC power but the
|
| @@ -161,7 +161,7 @@
|
| expected_policy.set_reason("Prefs, Screen");
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
| }
|
|
|
| TEST_F(PowerPolicyControllerTest, WakeLocks) {
|
| @@ -176,7 +176,7 @@
|
| expected_policy.set_reason(kSystemWakeLockReason);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| const char kScreenWakeLockReason[] = "screen";
|
| const int screen_id = policy_controller_->AddScreenWakeLock(
|
| @@ -191,19 +191,27 @@
|
| std::string(kScreenWakeLockReason) + ", " + kSystemWakeLockReason);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| policy_controller_->RemoveWakeLock(system_id);
|
| expected_policy.set_reason(kScreenWakeLockReason);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
|
|
| policy_controller_->RemoveWakeLock(screen_id);
|
| expected_policy.Clear();
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_->get_policy()));
|
| + fake_power_client_->policy()));
|
| }
|
|
|
| +TEST_F(PowerPolicyControllerTest, AvoidSendingEmptyPolicies) {
|
| + // Check that empty policies aren't sent when PowerPolicyController is created
|
| + // or destroyed.
|
| + EXPECT_EQ(0, fake_power_client_->num_set_policy_calls());
|
| + policy_controller_.reset();
|
| + EXPECT_EQ(0, fake_power_client_->num_set_policy_calls());
|
| +}
|
| +
|
| } // namespace chromeos
|
|
|