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
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_power_manager_client.h"
6 #include "chromeos/dbus/power_manager/policy.pb.h"
10 FakePowerManagerClient::FakePowerManagerClient()
11 : num_request_restart_calls_(0),
12 num_set_policy_calls_(0) {
15 FakePowerManagerClient::~FakePowerManagerClient() {
18 void FakePowerManagerClient::Init(dbus::Bus
* bus
) {
21 void FakePowerManagerClient::AddObserver(Observer
* observer
) {
22 observers_
.AddObserver(observer
);
25 void FakePowerManagerClient::RemoveObserver(Observer
* observer
) {
26 observers_
.RemoveObserver(observer
);
29 void FakePowerManagerClient::RequestStatusUpdate() {
32 void FakePowerManagerClient::SetPolicy(
33 const power_manager::PowerManagementPolicy
& policy
) {
35 ++num_set_policy_calls_
;
38 void FakePowerManagerClient::RequestShutdown() {
41 void FakePowerManagerClient::DecreaseScreenBrightness(bool allow_off
) {
44 void FakePowerManagerClient::SetScreenBrightnessPercent(double percent
,
48 void FakePowerManagerClient::GetScreenBrightnessPercent(
49 const GetScreenBrightnessPercentCallback
& callback
) {
52 base::Closure
FakePowerManagerClient::GetSuspendReadinessCallback() {
53 return base::Closure();
56 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
60 bool FakePowerManagerClient::HasObserver(Observer
* observer
) {
64 void FakePowerManagerClient::RequestRestart() {
65 ++num_request_restart_calls_
;
68 void FakePowerManagerClient::IncreaseKeyboardBrightness() {
71 void FakePowerManagerClient::IncreaseScreenBrightness() {
74 void FakePowerManagerClient::NotifyVideoActivity(bool is_fullscreen
) {
77 void FakePowerManagerClient::DecreaseKeyboardBrightness() {
80 void FakePowerManagerClient::SetIsProjecting(bool is_projecting
) {
83 void FakePowerManagerClient::NotifyUserActivity(
84 power_manager::UserActivityType type
) {
87 void FakePowerManagerClient::SendSuspendImminent() {
88 FOR_EACH_OBSERVER(Observer
, observers_
, SuspendImminent());
91 void FakePowerManagerClient::SendSuspendStateChanged(
92 const power_manager::SuspendState
& suspend_state
) {
93 base::Time wall_time
=
94 base::Time::FromInternalValue(suspend_state
.wall_time());
95 switch (suspend_state
.type()) {
96 case power_manager::SuspendState_Type_SUSPEND_TO_MEMORY
:
97 last_suspend_wall_time_
= wall_time
;
99 case power_manager::SuspendState_Type_RESUME
:
100 FOR_EACH_OBSERVER(Observer
, observers_
,
101 SystemResumed(wall_time
- last_suspend_wall_time_
));
106 } // namespace chromeos