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"
7 #include "base/time/time.h"
8 #include "chromeos/dbus/power_manager/policy.pb.h"
12 FakePowerManagerClient::FakePowerManagerClient()
13 : num_request_restart_calls_(0),
14 num_request_shutdown_calls_(0),
15 num_set_policy_calls_(0),
16 num_set_is_projecting_calls_(0),
17 is_projecting_(false) {
20 FakePowerManagerClient::~FakePowerManagerClient() {
23 void FakePowerManagerClient::Init(dbus::Bus
* bus
) {
26 void FakePowerManagerClient::AddObserver(Observer
* observer
) {
27 observers_
.AddObserver(observer
);
30 void FakePowerManagerClient::RemoveObserver(Observer
* observer
) {
31 observers_
.RemoveObserver(observer
);
34 bool FakePowerManagerClient::HasObserver(Observer
* observer
) {
38 void FakePowerManagerClient::DecreaseScreenBrightness(bool allow_off
) {
41 void FakePowerManagerClient::IncreaseScreenBrightness() {
44 void FakePowerManagerClient::SetScreenBrightnessPercent(double percent
,
48 void FakePowerManagerClient::GetScreenBrightnessPercent(
49 const GetScreenBrightnessPercentCallback
& callback
) {
52 void FakePowerManagerClient::DecreaseKeyboardBrightness() {
55 void FakePowerManagerClient::IncreaseKeyboardBrightness() {
58 void FakePowerManagerClient::RequestStatusUpdate() {
61 void FakePowerManagerClient::RequestRestart() {
62 ++num_request_restart_calls_
;
65 void FakePowerManagerClient::RequestShutdown() {
66 ++num_request_shutdown_calls_
;
69 void FakePowerManagerClient::NotifyUserActivity(
70 power_manager::UserActivityType type
) {
73 void FakePowerManagerClient::NotifyVideoActivity(bool is_fullscreen
) {
76 void FakePowerManagerClient::SetPolicy(
77 const power_manager::PowerManagementPolicy
& policy
) {
79 ++num_set_policy_calls_
;
82 void FakePowerManagerClient::SetIsProjecting(bool is_projecting
) {
83 ++num_set_is_projecting_calls_
;
84 is_projecting_
= is_projecting
;
87 base::Closure
FakePowerManagerClient::GetSuspendReadinessCallback() {
88 return base::Closure();
91 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
95 void FakePowerManagerClient::SendSuspendImminent() {
96 FOR_EACH_OBSERVER(Observer
, observers_
, SuspendImminent());
99 void FakePowerManagerClient::SendSuspendDone() {
100 FOR_EACH_OBSERVER(Observer
, observers_
, SuspendDone(base::TimeDelta()));
103 void FakePowerManagerClient::SendDarkSuspendImminent() {
104 FOR_EACH_OBSERVER(Observer
, observers_
, DarkSuspendImminent());
107 void FakePowerManagerClient::SendPowerButtonEvent(
109 const base::TimeTicks
& timestamp
) {
110 FOR_EACH_OBSERVER(Observer
, observers_
,
111 PowerButtonEventReceived(down
, timestamp
));
114 } // namespace chromeos