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

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

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Killing Nits Created 7 years, 5 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/power_monitor/power_monitor_test_base.h"
6
7 #include "base/message_loop.h"
8 #include "base/power_monitor/power_monitor.h"
9 #include "base/power_monitor/power_monitor_source.h"
10
11 namespace base {
12
13 PowerMonitorTestSource::PowerMonitorTestSource()
14 : test_on_battery_power_(false) {
15 }
16
17 PowerMonitorTestSource::~PowerMonitorTestSource() {
18 }
19
20 void PowerMonitorTestSource::GeneratePowerStateEvent(bool on_battery_power) {
21 test_on_battery_power_ = on_battery_power;
22 ProcessPowerEvent(POWER_STATE_EVENT);
23 message_loop_.RunUntilIdle();
24 }
25
26 void PowerMonitorTestSource::GenerateSuspendEvent() {
27 ProcessPowerEvent(SUSPEND_EVENT);
28 message_loop_.RunUntilIdle();
29 }
30
31 void PowerMonitorTestSource::GenerateResumeEvent() {
32 ProcessPowerEvent(RESUME_EVENT);
33 message_loop_.RunUntilIdle();
34 }
35
36 bool PowerMonitorTestSource::IsOnBatteryPowerImpl() {
jar (doing other things) 2013/07/16 17:15:33 nit: undent
37 return test_on_battery_power_;
38 };
39
40 PowerMonitorTestObserver::PowerMonitorTestObserver()
41 : last_power_state_(false),
42 power_state_changes_(0),
43 suspends_(0),
44 resumes_(0) {
45 }
46
47 PowerMonitorTestObserver::~PowerMonitorTestObserver() {
48 }
49
50 // PowerObserver callbacks.
51 void PowerMonitorTestObserver::OnPowerStateChange(bool on_battery_power) {
52 last_power_state_ = on_battery_power;
53 power_state_changes_++;
54 }
55
56 void PowerMonitorTestObserver::OnSuspend() {
57 suspends_++;
58 }
59
60 void PowerMonitorTestObserver::OnResume() {
61 resumes_++;
62 }
63
64 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698