Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromeos / dbus / fake_power_manager_client.h
blobf4b9af59b45a6978d0370ca647a628335312bf01
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12 #include "chromeos/dbus/power_manager/policy.pb.h"
13 #include "chromeos/dbus/power_manager/suspend.pb.h"
14 #include "chromeos/dbus/power_manager_client.h"
16 namespace chromeos {
18 // A fake implementation of PowerManagerClient. This remembers the policy passed
19 // to SetPolicy() and the user of this class can inspect the last set policy by
20 // get_policy().
21 class FakePowerManagerClient : public PowerManagerClient {
22 public:
23 FakePowerManagerClient();
24 virtual ~FakePowerManagerClient();
26 power_manager::PowerManagementPolicy& policy() { return policy_; }
27 int num_request_restart_calls() const { return num_request_restart_calls_; }
28 int num_request_shutdown_calls() const { return num_request_shutdown_calls_; }
29 int num_set_policy_calls() const { return num_set_policy_calls_; }
30 int num_set_is_projecting_calls() const {
31 return num_set_is_projecting_calls_;
33 bool is_projecting() const { return is_projecting_; }
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 the power manager announcing that the system is starting or
61 // completing a suspend attempt.
62 void SendSuspendImminent();
63 void SendSuspendDone();
64 void SendDarkSuspendImminent();
66 // Notifies observers that the power button has been pressed or released.
67 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
69 private:
70 ObserverList<Observer> observers_;
72 // Last policy passed to SetPolicy().
73 power_manager::PowerManagementPolicy policy_;
75 // Number of times that various methods have been called.
76 int num_request_restart_calls_;
77 int num_request_shutdown_calls_;
78 int num_set_policy_calls_;
79 int num_set_is_projecting_calls_;
81 // Last projecting state set in SetIsProjecting().
82 bool is_projecting_;
84 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient);
87 } // namespace chromeos
89 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_