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 virtual ~FakeSessionManagerClient();
26 // SessionManagerClient overrides
27 virtual void Init(dbus::Bus
* bus
) OVERRIDE
;
28 virtual void SetStubDelegate(StubDelegate
* delegate
) OVERRIDE
;
29 virtual void AddObserver(Observer
* observer
) OVERRIDE
;
30 virtual void RemoveObserver(Observer
* observer
) OVERRIDE
;
31 virtual bool HasObserver(Observer
* observer
) OVERRIDE
;
32 virtual void EmitLoginPromptVisible() OVERRIDE
;
33 virtual void RestartJob(int pid
, const std::string
& command_line
) OVERRIDE
;
34 virtual void StartSession(const std::string
& user_email
) OVERRIDE
;
35 virtual void StopSession() OVERRIDE
;
36 virtual void StartDeviceWipe() OVERRIDE
;
37 virtual void RequestLockScreen() OVERRIDE
;
38 virtual void NotifyLockScreenShown() OVERRIDE
;
39 virtual void NotifyLockScreenDismissed() OVERRIDE
;
40 virtual void RetrieveActiveSessions(
41 const ActiveSessionsCallback
& callback
) OVERRIDE
;
42 virtual void RetrieveDevicePolicy(
43 const RetrievePolicyCallback
& callback
) OVERRIDE
;
44 virtual void RetrievePolicyForUser(
45 const std::string
& username
,
46 const RetrievePolicyCallback
& callback
) OVERRIDE
;
47 virtual std::string
BlockingRetrievePolicyForUser(
48 const std::string
& username
) OVERRIDE
;
49 virtual void RetrieveDeviceLocalAccountPolicy(
50 const std::string
& account_id
,
51 const RetrievePolicyCallback
& callback
) OVERRIDE
;
52 virtual void StoreDevicePolicy(const std::string
& policy_blob
,
53 const StorePolicyCallback
& callback
) OVERRIDE
;
54 virtual void StorePolicyForUser(const std::string
& username
,
55 const std::string
& policy_blob
,
56 const StorePolicyCallback
& callback
) OVERRIDE
;
57 virtual void StoreDeviceLocalAccountPolicy(
58 const std::string
& account_id
,
59 const std::string
& policy_blob
,
60 const StorePolicyCallback
& callback
) OVERRIDE
;
61 virtual void SetFlagsForUser(const std::string
& username
,
62 const std::vector
<std::string
>& flags
) OVERRIDE
;
63 virtual void GetServerBackedStateKeys(const StateKeysCallback
& callback
)
66 const std::string
& device_policy() const;
67 void set_device_policy(const std::string
& policy_blob
);
69 const std::string
& user_policy(const std::string
& username
) const;
70 void set_user_policy(const std::string
& username
,
71 const std::string
& policy_blob
);
73 const std::string
& device_local_account_policy(
74 const std::string
& account_id
) const;
75 void set_device_local_account_policy(const std::string
& account_id
,
76 const std::string
& policy_blob
);
78 // Notify observers about a property change completion.
79 void OnPropertyChangeComplete(bool success
);
81 // Configures the list of state keys used to satisfy
82 // GetServerBackedStateKeys() requests.
83 void set_server_backed_state_keys(
84 const std::vector
<std::string
>& state_keys
) {
85 server_backed_state_keys_
= state_keys
;
88 void set_first_boot(bool first_boot
) { first_boot_
= first_boot
; }
90 int start_device_wipe_call_count() const {
91 return start_device_wipe_call_count_
;
94 // Returns how many times LockScreenShown() was called.
95 int notify_lock_screen_shown_call_count() const {
96 return notify_lock_screen_shown_call_count_
;
99 // Returns how many times LockScreenDismissed() was called.
100 int notify_lock_screen_dismissed_call_count() const {
101 return notify_lock_screen_dismissed_call_count_
;
105 std::string device_policy_
;
106 std::map
<std::string
, std::string
> user_policies_
;
107 std::map
<std::string
, std::string
> device_local_account_policy_
;
108 ObserverList
<Observer
> observers_
;
109 SessionManagerClient::ActiveSessionsMap user_sessions_
;
110 std::vector
<std::string
> server_backed_state_keys_
;
113 int start_device_wipe_call_count_
;
114 int notify_lock_screen_shown_call_count_
;
115 int notify_lock_screen_dismissed_call_count_
;
117 DISALLOW_COPY_AND_ASSIGN(FakeSessionManagerClient
);
120 } // namespace chromeos
122 #endif // CHROMEOS_DBUS_FAKE_SESSION_MANAGER_CLIENT_H_