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

Unified Diff: chromeos/dbus/power_policy_controller_unittest.cc

Issue 129303003: Revert of Revert of chromeos: Don't send empty power management policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « 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
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
« 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