| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/test/power_monitor_test_base.h" | 6 #include "base/test/power_monitor_test_base.h" |
| 7 #include "content/child/power_monitor_broadcast_source.h" | 7 #include "content/child/power_monitor_broadcast_source.h" |
| 8 #include "content/common/power_monitor_messages.h" | 8 #include "content/common/power_monitor_messages.h" |
| 9 #include "ipc/message_filter.h" | 9 #include "ipc/message_filter.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class PowerMonitorBroadcastSourceTest : public testing::Test { | 14 class PowerMonitorBroadcastSourceTest : public testing::Test { |
| 15 protected: | 15 protected: |
| 16 PowerMonitorBroadcastSourceTest() { | 16 PowerMonitorBroadcastSourceTest() { |
| 17 power_monitor_source_ = new PowerMonitorBroadcastSource(); | 17 power_monitor_source_ = new PowerMonitorBroadcastSource(); |
| 18 power_monitor_.reset(new base::PowerMonitor( | 18 power_monitor_.reset(new base::PowerMonitor( |
| 19 scoped_ptr<base::PowerMonitorSource>(power_monitor_source_))); | 19 scoped_ptr<base::PowerMonitorSource>(power_monitor_source_))); |
| 20 } | 20 } |
| 21 virtual ~PowerMonitorBroadcastSourceTest() {} | 21 ~PowerMonitorBroadcastSourceTest() override {} |
| 22 | 22 |
| 23 PowerMonitorBroadcastSource* source() { return power_monitor_source_; } | 23 PowerMonitorBroadcastSource* source() { return power_monitor_source_; } |
| 24 base::PowerMonitor* monitor() { return power_monitor_.get(); } | 24 base::PowerMonitor* monitor() { return power_monitor_.get(); } |
| 25 | 25 |
| 26 base::MessageLoop message_loop_; | 26 base::MessageLoop message_loop_; |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 PowerMonitorBroadcastSource* power_monitor_source_; | 29 PowerMonitorBroadcastSource* power_monitor_source_; |
| 30 scoped_ptr<base::PowerMonitor> power_monitor_; | 30 scoped_ptr<base::PowerMonitor> power_monitor_; |
| 31 | 31 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 EXPECT_EQ(observer.power_state_changes(), 2); | 86 EXPECT_EQ(observer.power_state_changes(), 2); |
| 87 EXPECT_EQ(observer.last_power_state(), false); | 87 EXPECT_EQ(observer.last_power_state(), false); |
| 88 | 88 |
| 89 // Repeated indications the device is off battery power should be suppressed. | 89 // Repeated indications the device is off battery power should be suppressed. |
| 90 message_filter->OnMessageReceived(off_battery_msg); | 90 message_filter->OnMessageReceived(off_battery_msg); |
| 91 message_loop_.RunUntilIdle(); | 91 message_loop_.RunUntilIdle(); |
| 92 EXPECT_EQ(observer.power_state_changes(), 2); | 92 EXPECT_EQ(observer.power_state_changes(), 2); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace base | 95 } // namespace base |
| OLD | NEW |