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