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

Side by Side Diff: chromeos/dbus/fake_power_manager_client.cc

Issue 2521103002: Ignore OnKeyEvent for VKEY_POWER because it is handled by PowerButtonEvent (Closed)
Patch Set: add tests Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chromeos/dbus/fake_power_manager_client.h" 5 #include "chromeos/dbus/fake_power_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 12
13 namespace chromeos { 13 namespace chromeos {
14 14
15 namespace { 15 namespace {
16 // Minimum power for a USB power source to be classified as AC. 16 // Minimum power for a USB power source to be classified as AC.
17 constexpr double kUsbMinAcWatts = 24; 17 constexpr double kUsbMinAcWatts = 24;
18 } 18 }
19 19
20 FakePowerManagerClient::FakePowerManagerClient() 20 FakePowerManagerClient::FakePowerManagerClient()
21 : num_request_restart_calls_(0), 21 : num_request_restart_calls_(0),
22 num_request_shutdown_calls_(0), 22 num_request_shutdown_calls_(0),
23 num_set_policy_calls_(0), 23 num_set_policy_calls_(0),
24 num_set_is_projecting_calls_(0), 24 num_set_is_projecting_calls_(0),
25 num_set_backlights_forced_off_calls_(0),
25 num_pending_suspend_readiness_callbacks_(0), 26 num_pending_suspend_readiness_callbacks_(0),
26 is_projecting_(false), 27 is_projecting_(false),
27 backlights_forced_off_(false), 28 backlights_forced_off_(false),
28 weak_ptr_factory_(this) { 29 weak_ptr_factory_(this) {}
29 }
Qiang(Joe) Xu 2016/11/22 00:35:47 changed by git cl format
30 30
31 FakePowerManagerClient::~FakePowerManagerClient() { 31 FakePowerManagerClient::~FakePowerManagerClient() {
32 } 32 }
33 33
34 void FakePowerManagerClient::Init(dbus::Bus* bus) { 34 void FakePowerManagerClient::Init(dbus::Bus* bus) {
35 props_.set_battery_percent(50); 35 props_.set_battery_percent(50);
36 props_.set_is_calculating_battery_time(false); 36 props_.set_is_calculating_battery_time(false);
37 props_.set_battery_state( 37 props_.set_battery_state(
38 power_manager::PowerSupplyProperties_BatteryState_DISCHARGING); 38 power_manager::PowerSupplyProperties_BatteryState_DISCHARGING);
39 props_.set_external_power( 39 props_.set_external_power(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 : power_manager::PowerSupplyProperties_ExternalPower_AC); 130 : power_manager::PowerSupplyProperties_ExternalPower_AC);
131 break; 131 break;
132 } 132 }
133 } 133 }
134 134
135 NotifyObservers(); 135 NotifyObservers();
136 } 136 }
137 137
138 void FakePowerManagerClient::SetBacklightsForcedOff(bool forced_off) { 138 void FakePowerManagerClient::SetBacklightsForcedOff(bool forced_off) {
139 backlights_forced_off_ = forced_off; 139 backlights_forced_off_ = forced_off;
140 ++num_set_backlights_forced_off_calls_;
140 } 141 }
141 142
142 void FakePowerManagerClient::GetBacklightsForcedOff( 143 void FakePowerManagerClient::GetBacklightsForcedOff(
143 const GetBacklightsForcedOffCallback& callback) { 144 const GetBacklightsForcedOffCallback& callback) {
144 base::ThreadTaskRunnerHandle::Get()->PostTask( 145 base::ThreadTaskRunnerHandle::Get()->PostTask(
145 FROM_HERE, base::Bind(callback, backlights_forced_off_)); 146 FROM_HERE, base::Bind(callback, backlights_forced_off_));
146 } 147 }
147 148
148 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() { 149 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() {
149 ++num_pending_suspend_readiness_callbacks_; 150 ++num_pending_suspend_readiness_callbacks_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 observer.PowerChanged(props_); 208 observer.PowerChanged(props_);
208 } 209 }
209 210
210 void FakePowerManagerClient::HandleSuspendReadiness() { 211 void FakePowerManagerClient::HandleSuspendReadiness() {
211 CHECK(num_pending_suspend_readiness_callbacks_ > 0); 212 CHECK(num_pending_suspend_readiness_callbacks_ > 0);
212 213
213 --num_pending_suspend_readiness_callbacks_; 214 --num_pending_suspend_readiness_callbacks_;
214 } 215 }
215 216
216 } // namespace chromeos 217 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698