| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/power_policy_controller.h" | 5 #include "chromeos/dbus/power_policy_controller.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 #include "chromeos/dbus/fake_power_manager_client.h" | 10 #include "chromeos/dbus/fake_power_manager_client.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using ::testing::_; | 14 using ::testing::_; |
| 15 using ::testing::SaveArg; | 15 using ::testing::SaveArg; |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 | 18 |
| 19 class PowerPolicyControllerTest : public testing::Test { | 19 class PowerPolicyControllerTest : public testing::Test { |
| 20 public: | 20 public: |
| 21 PowerPolicyControllerTest() {} | 21 PowerPolicyControllerTest() {} |
| 22 virtual ~PowerPolicyControllerTest() {} | 22 virtual ~PowerPolicyControllerTest() {} |
| 23 | 23 |
| 24 virtual void SetUp() OVERRIDE { | 24 virtual void SetUp() override { |
| 25 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 25 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
| 26 chromeos::DBusThreadManager::GetSetterForTesting(); | 26 chromeos::DBusThreadManager::GetSetterForTesting(); |
| 27 fake_power_client_ = new FakePowerManagerClient; | 27 fake_power_client_ = new FakePowerManagerClient; |
| 28 dbus_setter->SetPowerManagerClient( | 28 dbus_setter->SetPowerManagerClient( |
| 29 scoped_ptr<PowerManagerClient>(fake_power_client_)); | 29 scoped_ptr<PowerManagerClient>(fake_power_client_)); |
| 30 | 30 |
| 31 policy_controller_.reset(new PowerPolicyController); | 31 policy_controller_.reset(new PowerPolicyController); |
| 32 policy_controller_->Init(DBusThreadManager::Get()); | 32 policy_controller_->Init(DBusThreadManager::Get()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void TearDown() OVERRIDE { | 35 virtual void TearDown() override { |
| 36 policy_controller_.reset(); | 36 policy_controller_.reset(); |
| 37 DBusThreadManager::Shutdown(); | 37 DBusThreadManager::Shutdown(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 FakePowerManagerClient* fake_power_client_; | 41 FakePowerManagerClient* fake_power_client_; |
| 42 scoped_ptr<PowerPolicyController> policy_controller_; | 42 scoped_ptr<PowerPolicyController> policy_controller_; |
| 43 base::MessageLoop message_loop_; | 43 base::MessageLoop message_loop_; |
| 44 }; | 44 }; |
| 45 | 45 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 TEST_F(PowerPolicyControllerTest, AvoidSendingEmptyPolicies) { | 209 TEST_F(PowerPolicyControllerTest, AvoidSendingEmptyPolicies) { |
| 210 // Check that empty policies aren't sent when PowerPolicyController is created | 210 // Check that empty policies aren't sent when PowerPolicyController is created |
| 211 // or destroyed. | 211 // or destroyed. |
| 212 EXPECT_EQ(0, fake_power_client_->num_set_policy_calls()); | 212 EXPECT_EQ(0, fake_power_client_->num_set_policy_calls()); |
| 213 policy_controller_.reset(); | 213 policy_controller_.reset(); |
| 214 EXPECT_EQ(0, fake_power_client_->num_set_policy_calls()); | 214 EXPECT_EQ(0, fake_power_client_->num_set_policy_calls()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace chromeos | 217 } // namespace chromeos |
| OLD | NEW |