Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: base/power_monitor/power_monitor_test_base.h

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows unit test errors Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW
« no previous file with comments | « base/power_monitor/power_monitor_source.cc ('k') | base/power_monitor/power_monitor_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698