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/test/power_monitor_test_base.h" | 5 #include "base/test/power_monitor_test_base.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/power_monitor/power_monitor.h" | 8 #include "base/power_monitor/power_monitor.h" |
9 #include "base/power_monitor/power_monitor_source.h" | 9 #include "base/power_monitor/power_monitor_source.h" |
| 10 #include "base/run_loop.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 | 13 |
13 PowerMonitorTestSource::PowerMonitorTestSource() | 14 PowerMonitorTestSource::PowerMonitorTestSource() |
14 : test_on_battery_power_(false) { | 15 : test_on_battery_power_(false) { |
15 } | 16 } |
16 | 17 |
17 PowerMonitorTestSource::~PowerMonitorTestSource() { | 18 PowerMonitorTestSource::~PowerMonitorTestSource() { |
18 } | 19 } |
19 | 20 |
20 void PowerMonitorTestSource::GeneratePowerStateEvent(bool on_battery_power) { | 21 void PowerMonitorTestSource::GeneratePowerStateEvent(bool on_battery_power) { |
21 test_on_battery_power_ = on_battery_power; | 22 test_on_battery_power_ = on_battery_power; |
22 ProcessPowerEvent(POWER_STATE_EVENT); | 23 ProcessPowerEvent(POWER_STATE_EVENT); |
23 message_loop_.RunUntilIdle(); | 24 RunLoop().RunUntilIdle(); |
24 } | 25 } |
25 | 26 |
26 void PowerMonitorTestSource::GenerateSuspendEvent() { | 27 void PowerMonitorTestSource::GenerateSuspendEvent() { |
27 ProcessPowerEvent(SUSPEND_EVENT); | 28 ProcessPowerEvent(SUSPEND_EVENT); |
28 message_loop_.RunUntilIdle(); | 29 RunLoop().RunUntilIdle(); |
29 } | 30 } |
30 | 31 |
31 void PowerMonitorTestSource::GenerateResumeEvent() { | 32 void PowerMonitorTestSource::GenerateResumeEvent() { |
32 ProcessPowerEvent(RESUME_EVENT); | 33 ProcessPowerEvent(RESUME_EVENT); |
33 message_loop_.RunUntilIdle(); | 34 RunLoop().RunUntilIdle(); |
34 } | 35 } |
35 | 36 |
36 bool PowerMonitorTestSource::IsOnBatteryPowerImpl() { | 37 bool PowerMonitorTestSource::IsOnBatteryPowerImpl() { |
37 return test_on_battery_power_; | 38 return test_on_battery_power_; |
38 }; | 39 }; |
39 | 40 |
40 PowerMonitorTestObserver::PowerMonitorTestObserver() | 41 PowerMonitorTestObserver::PowerMonitorTestObserver() |
41 : last_power_state_(false), | 42 : last_power_state_(false), |
42 power_state_changes_(0), | 43 power_state_changes_(0), |
43 suspends_(0), | 44 suspends_(0), |
(...skipping 11 matching lines...) Expand all Loading... |
55 | 56 |
56 void PowerMonitorTestObserver::OnSuspend() { | 57 void PowerMonitorTestObserver::OnSuspend() { |
57 suspends_++; | 58 suspends_++; |
58 } | 59 } |
59 | 60 |
60 void PowerMonitorTestObserver::OnResume() { | 61 void PowerMonitorTestObserver::OnResume() { |
61 resumes_++; | 62 resumes_++; |
62 } | 63 } |
63 | 64 |
64 } // namespace base | 65 } // namespace base |
OLD | NEW |