| 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 ea7630cf48f608cfe39a8cf20ab94edfba5c6973..ec108d622be74819cd66ffc472f329536aeece19 100644
|
| --- a/chromeos/dbus/power_policy_controller_unittest.cc
|
| +++ b/chromeos/dbus/power_policy_controller_unittest.cc
|
| @@ -23,10 +23,13 @@ class PowerPolicyControllerTest : public testing::Test {
|
|
|
| virtual void SetUp() OVERRIDE {
|
| dbus_manager_ = new FakeDBusThreadManager;
|
| + fake_power_client_ = new FakePowerManagerClient;
|
| + dbus_manager_->SetPowerManagerClient(
|
| + scoped_ptr<PowerManagerClient>(fake_power_client_));
|
| DBusThreadManager::InitializeForTesting(dbus_manager_); // Takes ownership.
|
|
|
| - policy_controller_.reset(
|
| - new PowerPolicyController(dbus_manager_, &fake_power_client_));
|
| + policy_controller_.reset(new PowerPolicyController);
|
| + policy_controller_->Init(dbus_manager_);
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -36,7 +39,7 @@ class PowerPolicyControllerTest : public testing::Test {
|
|
|
| protected:
|
| FakeDBusThreadManager* dbus_manager_; // Not owned.
|
| - FakePowerManagerClient fake_power_client_;
|
| + FakePowerManagerClient* fake_power_client_;
|
| scoped_ptr<PowerPolicyController> policy_controller_;
|
| };
|
|
|
| @@ -84,7 +87,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| expected_policy.set_reason("Prefs");
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_policy()));
|
|
|
| // Change some prefs and check that an updated policy is sent.
|
| prefs.ac_idle_warning_delay_ms = 700000;
|
| @@ -97,7 +100,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| power_manager::PowerManagementPolicy_Action_SUSPEND);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_policy()));
|
|
|
| // The enable-screen-lock pref should force the screen-lock delays to
|
| // match the screen-off delays plus a constant value.
|
| @@ -109,7 +112,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| 360000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_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
|
| @@ -121,7 +124,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| 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_->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
|
| @@ -139,7 +142,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| 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_->get_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
|
| @@ -152,7 +155,7 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
|
| expected_policy.set_reason("Prefs, Screen");
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_policy()));
|
| }
|
|
|
| TEST_F(PowerPolicyControllerTest, WakeLocks) {
|
| @@ -167,7 +170,7 @@ TEST_F(PowerPolicyControllerTest, WakeLocks) {
|
| expected_policy.set_reason(kSystemWakeLockReason);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_policy()));
|
|
|
| const char kScreenWakeLockReason[] = "screen";
|
| const int screen_id = policy_controller_->AddScreenWakeLock(
|
| @@ -182,19 +185,19 @@ TEST_F(PowerPolicyControllerTest, WakeLocks) {
|
| std::string(kScreenWakeLockReason) + ", " + kSystemWakeLockReason);
|
| EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
|
| PowerPolicyController::GetPolicyDebugString(
|
| - fake_power_client_.get_policy()));
|
| + fake_power_client_->get_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_->get_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_->get_policy()));
|
| }
|
|
|
| } // namespace chromeos
|
|
|