OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/power_monitor/power_monitor.h" | 6 #include "base/power_monitor/power_monitor.h" |
7 #include "base/test/power_monitor_test_base.h" | 7 #include "base/test/power_monitor_test_base.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 | 11 |
12 class PowerMonitorTest : public testing::Test { | 12 class PowerMonitorTest : public testing::Test { |
13 protected: | 13 protected: |
14 PowerMonitorTest() { | 14 PowerMonitorTest() { |
15 power_monitor_source_ = new PowerMonitorTestSource(); | 15 power_monitor_source_ = new PowerMonitorTestSource(); |
16 power_monitor_.reset(new PowerMonitor( | 16 power_monitor_.reset(new PowerMonitor( |
17 scoped_ptr<PowerMonitorSource>(power_monitor_source_))); | 17 std::unique_ptr<PowerMonitorSource>(power_monitor_source_))); |
18 } | 18 } |
19 ~PowerMonitorTest() override{}; | 19 ~PowerMonitorTest() override{}; |
20 | 20 |
21 PowerMonitorTestSource* source() { return power_monitor_source_; } | 21 PowerMonitorTestSource* source() { return power_monitor_source_; } |
22 PowerMonitor* monitor() { return power_monitor_.get(); } | 22 PowerMonitor* monitor() { return power_monitor_.get(); } |
23 | 23 |
24 private: | 24 private: |
25 PowerMonitorTestSource* power_monitor_source_; | 25 PowerMonitorTestSource* power_monitor_source_; |
26 scoped_ptr<PowerMonitor> power_monitor_; | 26 std::unique_ptr<PowerMonitor> power_monitor_; |
27 | 27 |
28 DISALLOW_COPY_AND_ASSIGN(PowerMonitorTest); | 28 DISALLOW_COPY_AND_ASSIGN(PowerMonitorTest); |
29 }; | 29 }; |
30 | 30 |
31 // PowerMonitorSource is tightly coupled with the PowerMonitor, so this test | 31 // PowerMonitorSource is tightly coupled with the PowerMonitor, so this test |
32 // Will cover both classes | 32 // Will cover both classes |
33 TEST_F(PowerMonitorTest, PowerNotifications) { | 33 TEST_F(PowerMonitorTest, PowerNotifications) { |
34 const int kObservers = 5; | 34 const int kObservers = 5; |
35 | 35 |
36 PowerMonitorTestObserver observers[kObservers]; | 36 PowerMonitorTestObserver observers[kObservers]; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 source()->GeneratePowerStateEvent(false); | 72 source()->GeneratePowerStateEvent(false); |
73 EXPECT_EQ(observers[0].power_state_changes(), 2); | 73 EXPECT_EQ(observers[0].power_state_changes(), 2); |
74 EXPECT_EQ(observers[0].last_power_state(), false); | 74 EXPECT_EQ(observers[0].last_power_state(), false); |
75 | 75 |
76 // Repeated indications the device is off battery power should be suppressed. | 76 // Repeated indications the device is off battery power should be suppressed. |
77 source()->GeneratePowerStateEvent(false); | 77 source()->GeneratePowerStateEvent(false); |
78 EXPECT_EQ(observers[0].power_state_changes(), 2); | 78 EXPECT_EQ(observers[0].power_state_changes(), 2); |
79 } | 79 } |
80 | 80 |
81 } // namespace base | 81 } // namespace base |
OLD | NEW |