OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/power_monitor/power_monitor.h" |
| 7 #include "base/power_monitor/power_monitor_source.h" |
| 8 |
| 9 namespace base { |
| 10 |
| 11 class BASE_EXPORT PowerMonitorTestSource : public PowerMonitorSource { |
| 12 public: |
| 13 PowerMonitorTestSource(); |
| 14 virtual ~PowerMonitorTestSource(); |
| 15 |
| 16 void GeneratePowerStateEvent(bool on_battery_power); |
| 17 void GenerateSuspendEvent(); |
| 18 void GenerateResumeEvent(); |
| 19 |
| 20 protected: |
| 21 virtual bool IsOnBatteryPowerImpl() OVERRIDE; |
| 22 |
| 23 bool test_on_battery_power_; |
| 24 MessageLoop message_loop_; |
| 25 }; |
| 26 |
| 27 class BASE_EXPORT PowerMonitorTestObserver : public PowerObserver { |
| 28 public: |
| 29 PowerMonitorTestObserver(); |
| 30 virtual ~PowerMonitorTestObserver(); |
| 31 |
| 32 // PowerObserver callbacks. |
| 33 virtual void OnPowerStateChange(bool on_battery_power) OVERRIDE; |
| 34 virtual void OnSuspend() OVERRIDE; |
| 35 virtual void OnResume() OVERRIDE; |
| 36 |
| 37 // Test status counts. |
| 38 bool last_power_state() { return last_power_state_; } |
| 39 int power_state_changes() { return power_state_changes_; } |
| 40 int suspends() { return suspends_; } |
| 41 int resumes() { return resumes_; } |
| 42 |
| 43 private: |
| 44 bool last_power_state_; // Last power state we were notified of. |
| 45 int power_state_changes_; // Count of OnPowerStateChange notifications. |
| 46 int suspends_; // Count of OnSuspend notifications. |
| 47 int resumes_; // Count of OnResume notifications. |
| 48 }; |
| 49 |
| 50 } // namespace base |
OLD | NEW |