1 // Copyright 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_SESSION_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_SESSION_MANAGER_CLIENT_H_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/observer_list.h"
15 #include "chromeos/dbus/session_manager_client.h"
19 // A fake implementation of session_manager. Accepts policy blobs to be set and
20 // returns them unmodified.
21 class FakeSessionManagerClient
: public SessionManagerClient
{
23 FakeSessionManagerClient();
24 ~FakeSessionManagerClient() override
;
26 // SessionManagerClient overrides
27 void Init(dbus::Bus
* bus
) override
;
28 void SetStubDelegate(StubDelegate
* delegate
) override
;
29 void AddObserver(Observer
* observer
) override
;
30 void RemoveObserver(Observer
* observer
) override
;
31 bool HasObserver(const Observer
* observer
) const override
;
32 bool IsScreenLocked() const override
;
33 void EmitLoginPromptVisible() override
;
34 void RestartJob(int pid
, const std::string
& command_line
) override
;
35 void StartSession(const std::string
& user_email
) override
;
36 void StopSession() override
;
37 void NotifySupervisedUserCreationStarted() override
;
38 void NotifySupervisedUserCreationFinished() override
;
39 void StartDeviceWipe() override
;
40 void RequestLockScreen() override
;
41 void NotifyLockScreenShown() override
;
42 void NotifyLockScreenDismissed() override
;
43 void RetrieveActiveSessions(const ActiveSessionsCallback
& callback
) override
;
44 void RetrieveDevicePolicy(const RetrievePolicyCallback
& callback
) override
;
45 void RetrievePolicyForUser(const std::string
& username
,
46 const RetrievePolicyCallback
& callback
) override
;
47 std::string
BlockingRetrievePolicyForUser(
48 const std::string
& username
) override
;
49 void RetrieveDeviceLocalAccountPolicy(
50 const std::string
& account_id
,
51 const RetrievePolicyCallback
& callback
) override
;
52 void StoreDevicePolicy(const std::string
& policy_blob
,
53 const StorePolicyCallback
& callback
) override
;
54 void StorePolicyForUser(const std::string
& username
,
55 const std::string
& policy_blob
,
56 const StorePolicyCallback
& callback
) override
;
57 void StoreDeviceLocalAccountPolicy(
58 const std::string
& account_id
,
59 const std::string
& policy_blob
,
60 const StorePolicyCallback
& callback
) override
;
61 void SetFlagsForUser(const std::string
& username
,
62 const std::vector
<std::string
>& flags
) override
;
63 void GetServerBackedStateKeys(const StateKeysCallback
& callback
) override
;
65 const std::string
& device_policy() const;
66 void set_device_policy(const std::string
& policy_blob
);
68 const std::string
& user_policy(const std::string
& username
) const;
69 void set_user_policy(const std::string
& username
,
70 const std::string
& policy_blob
);
72 const std::string
& device_local_account_policy(
73 const std::string
& account_id
) const;
74 void set_device_local_account_policy(const std::string
& account_id
,
75 const std::string
& policy_blob
);
77 // Notify observers about a property change completion.
78 void OnPropertyChangeComplete(bool success
);
80 // Configures the list of state keys used to satisfy
81 // GetServerBackedStateKeys() requests.
82 void set_server_backed_state_keys(
83 const std::vector
<std::string
>& state_keys
) {
84 server_backed_state_keys_
= state_keys
;
87 int start_device_wipe_call_count() const {
88 return start_device_wipe_call_count_
;
91 // Returns how many times LockScreenShown() was called.
92 int notify_lock_screen_shown_call_count() const {
93 return notify_lock_screen_shown_call_count_
;
96 // Returns how many times LockScreenDismissed() was called.
97 int notify_lock_screen_dismissed_call_count() const {
98 return notify_lock_screen_dismissed_call_count_
;
102 std::string device_policy_
;
103 std::map
<std::string
, std::string
> user_policies_
;
104 std::map
<std::string
, std::string
> device_local_account_policy_
;
105 ObserverList
<Observer
> observers_
;
106 SessionManagerClient::ActiveSessionsMap user_sessions_
;
107 std::vector
<std::string
> server_backed_state_keys_
;
109 int start_device_wipe_call_count_
;
110 int notify_lock_screen_shown_call_count_
;
111 int notify_lock_screen_dismissed_call_count_
;
113 DISALLOW_COPY_AND_ASSIGN(FakeSessionManagerClient
);
116 } // namespace chromeos
118 #endif // CHROMEOS_DBUS_FAKE_SESSION_MANAGER_CLIENT_H_