OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "chromeos/dbus/power_manager/policy.pb.h" | 12 #include "chromeos/dbus/power_manager/policy.pb.h" |
13 #include "chromeos/dbus/power_manager/suspend.pb.h" | 13 #include "chromeos/dbus/power_manager/suspend.pb.h" |
14 #include "chromeos/dbus/power_manager_client.h" | 14 #include "chromeos/dbus/power_manager_client.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 // A fake implementation of PowerManagerClient. This remembers the policy passed | 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 | 19 // to SetPolicy() and the user of this class can inspect the last set policy by |
20 // get_policy(). | 20 // get_policy(). |
21 class FakePowerManagerClient : public PowerManagerClient { | 21 class FakePowerManagerClient : public PowerManagerClient { |
22 public: | 22 public: |
23 FakePowerManagerClient(); | 23 FakePowerManagerClient(); |
24 virtual ~FakePowerManagerClient(); | 24 virtual ~FakePowerManagerClient(); |
25 | 25 |
26 power_manager::PowerManagementPolicy& policy() { return policy_; } | 26 power_manager::PowerManagementPolicy& policy() { return policy_; } |
27 int num_request_restart_calls() const { | 27 int num_request_restart_calls() const { return num_request_restart_calls_; } |
28 return num_request_restart_calls_; | 28 int num_request_shutdown_calls() const { return num_request_shutdown_calls_; } |
29 } | 29 int num_set_policy_calls() const { return num_set_policy_calls_; } |
30 int num_set_policy_calls() const { | |
31 return num_set_policy_calls_; | |
32 } | |
33 int num_set_is_projecting_calls() const { | 30 int num_set_is_projecting_calls() const { |
34 return num_set_is_projecting_calls_; | 31 return num_set_is_projecting_calls_; |
35 } | 32 } |
36 bool is_projecting() const { | 33 bool is_projecting() const { return is_projecting_; } |
37 return is_projecting_; | |
38 } | |
39 | 34 |
40 // PowerManagerClient overrides | 35 // PowerManagerClient overrides |
41 virtual void Init(dbus::Bus* bus) OVERRIDE; | 36 virtual void Init(dbus::Bus* bus) OVERRIDE; |
42 virtual void AddObserver(Observer* observer) OVERRIDE; | 37 virtual void AddObserver(Observer* observer) OVERRIDE; |
43 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 38 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
44 virtual bool HasObserver(Observer* observer) OVERRIDE; | 39 virtual bool HasObserver(Observer* observer) OVERRIDE; |
45 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE; | 40 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE; |
46 virtual void IncreaseScreenBrightness() OVERRIDE; | 41 virtual void IncreaseScreenBrightness() OVERRIDE; |
47 virtual void SetScreenBrightnessPercent( | 42 virtual void SetScreenBrightnessPercent( |
48 double percent, bool gradual) OVERRIDE; | 43 double percent, bool gradual) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
61 virtual void SetIsProjecting(bool is_projecting) OVERRIDE; | 56 virtual void SetIsProjecting(bool is_projecting) OVERRIDE; |
62 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE; | 57 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE; |
63 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE; | 58 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE; |
64 | 59 |
65 // Emulates the power manager announcing that the system is starting or | 60 // Emulates the power manager announcing that the system is starting or |
66 // completing a suspend attempt. | 61 // completing a suspend attempt. |
67 void SendSuspendImminent(); | 62 void SendSuspendImminent(); |
68 void SendSuspendDone(); | 63 void SendSuspendDone(); |
69 void SendDarkSuspendImminent(); | 64 void SendDarkSuspendImminent(); |
70 | 65 |
| 66 // Notifies observers that the power button has been pressed or released. |
| 67 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 68 |
71 private: | 69 private: |
72 ObserverList<Observer> observers_; | 70 ObserverList<Observer> observers_; |
73 | 71 |
74 // Last policy passed to SetPolicy(). | 72 // Last policy passed to SetPolicy(). |
75 power_manager::PowerManagementPolicy policy_; | 73 power_manager::PowerManagementPolicy policy_; |
76 | 74 |
77 // Number of times that RequestRestart() has been called. | 75 // Number of times that various methods have been called. |
78 int num_request_restart_calls_; | 76 int num_request_restart_calls_; |
79 | 77 int num_request_shutdown_calls_; |
80 // Number of times that SetPolicy() has been called. | |
81 int num_set_policy_calls_; | 78 int num_set_policy_calls_; |
82 | |
83 // Count the number of times SetIsProjecting() has been called. | |
84 int num_set_is_projecting_calls_; | 79 int num_set_is_projecting_calls_; |
85 | 80 |
86 // Last projecting state set in SetIsProjecting(). | 81 // Last projecting state set in SetIsProjecting(). |
87 bool is_projecting_; | 82 bool is_projecting_; |
88 | 83 |
89 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); | 84 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); |
90 }; | 85 }; |
91 | 86 |
92 } // namespace chromeos | 87 } // namespace chromeos |
93 | 88 |
94 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 89 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |