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 // PowerManagerClient overrides
28 virtual void Init(dbus::Bus* bus) OVERRIDE;
29 virtual void AddObserver(Observer* observer) OVERRIDE;
30 virtual void RemoveObserver(Observer* observer) OVERRIDE;
31 virtual bool HasObserver(Observer* observer) OVERRIDE;
32 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE;
33 virtual void IncreaseScreenBrightness() OVERRIDE;
34 virtual void SetScreenBrightnessPercent(
35 double percent, bool gradual) OVERRIDE;
36 virtual void GetScreenBrightnessPercent(
37 const GetScreenBrightnessPercentCallback& callback) OVERRIDE;
38 virtual void DecreaseKeyboardBrightness() OVERRIDE;
39 virtual void IncreaseKeyboardBrightness() OVERRIDE;
40 virtual void RequestStatusUpdate() OVERRIDE;
41 virtual void RequestRestart() OVERRIDE;
42 virtual void RequestShutdown() OVERRIDE;
43 virtual void NotifyUserActivity(
44 power_manager::UserActivityType type) OVERRIDE;
45 virtual void NotifyVideoActivity(bool is_fullscreen) OVERRIDE;
46 virtual void SetPolicy(
47 const power_manager::PowerManagementPolicy& policy) OVERRIDE;
48 virtual void SetIsProjecting(bool is_projecting) OVERRIDE;
49 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE;
50 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE;
52 power_manager::PowerManagementPolicy& get_policy() { return policy_; }
54 // Returns how many times RequestRestart() was called.
55 int request_restart_call_count() const {
56 return request_restart_call_count_;
59 // Emulates that the dbus server sends a message "SuspendImminent" to the
61 void SendSuspendImminent();
63 // Emulates that the dbus server sends a message "SuspendStateChanged" to the
65 void SendSuspendStateChanged(
66 const power_manager::SuspendState& suspend_state);
69 power_manager::PowerManagementPolicy policy_;
70 base::Time last_suspend_wall_time_;
71 ObserverList<Observer> observers_;
72 int request_restart_call_count_;
74 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient);
77 } // namespace chromeos
79 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_