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 #ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12 #include "base/time/time.h"
13 #include "chromeos/dbus/power_manager/policy.pb.h"
14 #include "chromeos/dbus/power_manager/suspend.pb.h"
15 #include "chromeos/dbus/power_manager_client.h"
19 // A fake implementation of PowerManagerClient. This remembers the policy passed
20 // to SetPolicy() and the user of this class can inspect the last set policy by
22 class FakePowerManagerClient
: public PowerManagerClient
{
24 FakePowerManagerClient();
25 virtual ~FakePowerManagerClient();
27 power_manager::PowerManagementPolicy
& policy() { return policy_
; }
28 int num_request_restart_calls() const {
29 return num_request_restart_calls_
;
31 int num_set_policy_calls() const {
32 return num_set_policy_calls_
;
35 // PowerManagerClient overrides
36 virtual void Init(dbus::Bus
* bus
) OVERRIDE
;
37 virtual void AddObserver(Observer
* observer
) OVERRIDE
;
38 virtual void RemoveObserver(Observer
* observer
) OVERRIDE
;
39 virtual bool HasObserver(Observer
* observer
) OVERRIDE
;
40 virtual void DecreaseScreenBrightness(bool allow_off
) OVERRIDE
;
41 virtual void IncreaseScreenBrightness() OVERRIDE
;
42 virtual void SetScreenBrightnessPercent(
43 double percent
, bool gradual
) OVERRIDE
;
44 virtual void GetScreenBrightnessPercent(
45 const GetScreenBrightnessPercentCallback
& callback
) OVERRIDE
;
46 virtual void DecreaseKeyboardBrightness() OVERRIDE
;
47 virtual void IncreaseKeyboardBrightness() OVERRIDE
;
48 virtual void RequestStatusUpdate() OVERRIDE
;
49 virtual void RequestRestart() OVERRIDE
;
50 virtual void RequestShutdown() OVERRIDE
;
51 virtual void NotifyUserActivity(
52 power_manager::UserActivityType type
) OVERRIDE
;
53 virtual void NotifyVideoActivity(bool is_fullscreen
) OVERRIDE
;
54 virtual void SetPolicy(
55 const power_manager::PowerManagementPolicy
& policy
) OVERRIDE
;
56 virtual void SetIsProjecting(bool is_projecting
) OVERRIDE
;
57 virtual base::Closure
GetSuspendReadinessCallback() OVERRIDE
;
58 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE
;
60 // Emulates that the dbus server sends a message "SuspendImminent" to the
62 void SendSuspendImminent();
64 // Emulates that the dbus server sends a message "SuspendStateChanged" to the
66 void SendSuspendStateChanged(
67 const power_manager::SuspendState
& suspend_state
);
70 ObserverList
<Observer
> observers_
;
72 // Last policy passed to SetPolicy().
73 power_manager::PowerManagementPolicy policy_
;
75 // Last time passed to a SUSPEND_TO_MEMORY call to SendSuspendStateChanged().
76 base::Time last_suspend_wall_time_
;
78 // Number of times that RequestRestart() has been called.
79 int num_request_restart_calls_
;
81 // Number of times that SetPolicy() has been called.
82 int num_set_policy_calls_
;
84 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient
);
87 } // namespace chromeos
89 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_