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_;
34 int num_set_is_projecting_calls() const {
35 return num_set_is_projecting_calls_;
37 bool is_projecting() const {
38 return is_projecting_;
41 // PowerManagerClient overrides
42 virtual void Init(dbus::Bus* bus) OVERRIDE;
43 virtual void AddObserver(Observer* observer) OVERRIDE;
44 virtual void RemoveObserver(Observer* observer) OVERRIDE;
45 virtual bool HasObserver(Observer* observer) OVERRIDE;
46 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE;
47 virtual void IncreaseScreenBrightness() OVERRIDE;
48 virtual void SetScreenBrightnessPercent(
49 double percent, bool gradual) OVERRIDE;
50 virtual void GetScreenBrightnessPercent(
51 const GetScreenBrightnessPercentCallback& callback) OVERRIDE;
52 virtual void DecreaseKeyboardBrightness() OVERRIDE;
53 virtual void IncreaseKeyboardBrightness() OVERRIDE;
54 virtual void RequestStatusUpdate() OVERRIDE;
55 virtual void RequestRestart() OVERRIDE;
56 virtual void RequestShutdown() OVERRIDE;
57 virtual void NotifyUserActivity(
58 power_manager::UserActivityType type) OVERRIDE;
59 virtual void NotifyVideoActivity(bool is_fullscreen) OVERRIDE;
60 virtual void SetPolicy(
61 const power_manager::PowerManagementPolicy& policy) OVERRIDE;
62 virtual void SetIsProjecting(bool is_projecting) OVERRIDE;
63 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE;
64 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE;
66 // Emulates that the dbus server sends a message "SuspendImminent" to the
68 void SendSuspendImminent();
70 // Emulates that the dbus server sends a message "SuspendStateChanged" to the
72 void SendSuspendStateChanged(
73 const power_manager::SuspendState& suspend_state);
76 ObserverList<Observer> observers_;
78 // Last policy passed to SetPolicy().
79 power_manager::PowerManagementPolicy policy_;
81 // Last time passed to a SUSPEND_TO_MEMORY call to SendSuspendStateChanged().
82 base::Time last_suspend_wall_time_;
84 // Number of times that RequestRestart() has been called.
85 int num_request_restart_calls_;
87 // Number of times that SetPolicy() has been called.
88 int num_set_policy_calls_;
90 // Count the number of times SetIsProjecting() has been called.
91 int num_set_is_projecting_calls_;
93 // Last projecting state set in SetIsProjecting().
96 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient);
99 } // namespace chromeos
101 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_