Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: chromeos/dbus/fake_power_manager_client.h

Issue 129303003: Revert of Revert of chromeos: Don't send empty power management policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
27 // PowerManagerClient overrides 35 // PowerManagerClient overrides
28 virtual void Init(dbus::Bus* bus) OVERRIDE; 36 virtual void Init(dbus::Bus* bus) OVERRIDE;
29 virtual void AddObserver(Observer* observer) OVERRIDE; 37 virtual void AddObserver(Observer* observer) OVERRIDE;
30 virtual void RemoveObserver(Observer* observer) OVERRIDE; 38 virtual void RemoveObserver(Observer* observer) OVERRIDE;
31 virtual bool HasObserver(Observer* observer) OVERRIDE; 39 virtual bool HasObserver(Observer* observer) OVERRIDE;
32 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE; 40 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE;
33 virtual void IncreaseScreenBrightness() OVERRIDE; 41 virtual void IncreaseScreenBrightness() OVERRIDE;
34 virtual void SetScreenBrightnessPercent( 42 virtual void SetScreenBrightnessPercent(
35 double percent, bool gradual) OVERRIDE; 43 double percent, bool gradual) OVERRIDE;
36 virtual void GetScreenBrightnessPercent( 44 virtual void GetScreenBrightnessPercent(
37 const GetScreenBrightnessPercentCallback& callback) OVERRIDE; 45 const GetScreenBrightnessPercentCallback& callback) OVERRIDE;
38 virtual void DecreaseKeyboardBrightness() OVERRIDE; 46 virtual void DecreaseKeyboardBrightness() OVERRIDE;
39 virtual void IncreaseKeyboardBrightness() OVERRIDE; 47 virtual void IncreaseKeyboardBrightness() OVERRIDE;
40 virtual void RequestStatusUpdate() OVERRIDE; 48 virtual void RequestStatusUpdate() OVERRIDE;
41 virtual void RequestRestart() OVERRIDE; 49 virtual void RequestRestart() OVERRIDE;
42 virtual void RequestShutdown() OVERRIDE; 50 virtual void RequestShutdown() OVERRIDE;
43 virtual void NotifyUserActivity( 51 virtual void NotifyUserActivity(
44 power_manager::UserActivityType type) OVERRIDE; 52 power_manager::UserActivityType type) OVERRIDE;
45 virtual void NotifyVideoActivity(bool is_fullscreen) OVERRIDE; 53 virtual void NotifyVideoActivity(bool is_fullscreen) OVERRIDE;
46 virtual void SetPolicy( 54 virtual void SetPolicy(
47 const power_manager::PowerManagementPolicy& policy) OVERRIDE; 55 const power_manager::PowerManagementPolicy& policy) OVERRIDE;
48 virtual void SetIsProjecting(bool is_projecting) OVERRIDE; 56 virtual void SetIsProjecting(bool is_projecting) OVERRIDE;
49 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE; 57 virtual base::Closure GetSuspendReadinessCallback() OVERRIDE;
50 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE; 58 virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE;
51 59
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
59 // Emulates that the dbus server sends a message "SuspendImminent" to the 60 // Emulates that the dbus server sends a message "SuspendImminent" to the
60 // client. 61 // client.
61 void SendSuspendImminent(); 62 void SendSuspendImminent();
62 63
63 // Emulates that the dbus server sends a message "SuspendStateChanged" to the 64 // Emulates that the dbus server sends a message "SuspendStateChanged" to the
64 // client. 65 // client.
65 void SendSuspendStateChanged( 66 void SendSuspendStateChanged(
66 const power_manager::SuspendState& suspend_state); 67 const power_manager::SuspendState& suspend_state);
67 68
68 private: 69 private:
70 ObserverList<Observer> observers_;
71
72 // Last policy passed to SetPolicy().
69 power_manager::PowerManagementPolicy policy_; 73 power_manager::PowerManagementPolicy policy_;
74
75 // Last time passed to a SUSPEND_TO_MEMORY call to SendSuspendStateChanged().
70 base::Time last_suspend_wall_time_; 76 base::Time last_suspend_wall_time_;
71 ObserverList<Observer> observers_; 77
72 int request_restart_call_count_; 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_;
73 83
74 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); 84 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient);
75 }; 85 };
76 86
77 } // namespace chromeos 87 } // namespace chromeos
78 88
79 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ 89 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc ('k') | chromeos/dbus/fake_power_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698