Roll tools/swarming_client/ to b61a1802f5ef4bb8c7b81060cc80add47e6cf302.
[chromium-blink-merge.git] / ash / test / test_session_state_delegate.h
blobb35f8642d1a60dbaf11901b8345216901c95fb12
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
3 // found in the LICENSE file.
5 #ifndef ASH_TEST_TEST_SESSION_STATE_DELEGATE_H_
6 #define ASH_TEST_TEST_SESSION_STATE_DELEGATE_H_
8 #include <vector>
10 #include "ash/session/session_state_delegate.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ui/gfx/image/image_skia.h"
15 namespace ash {
16 namespace test {
18 class MockUserInfo;
20 class TestSessionStateDelegate : public SessionStateDelegate {
21 public:
22 TestSessionStateDelegate();
23 ~TestSessionStateDelegate() override;
25 void set_logged_in_users(int users) { logged_in_users_ = users; }
26 void set_session_state(SessionState session_state) {
27 session_state_ = session_state;
29 void AddUser(const std::string user_id);
30 const user_manager::UserInfo* GetActiveUserInfo() const;
32 // SessionStateDelegate:
33 content::BrowserContext* GetBrowserContextByIndex(
34 MultiProfileIndex index) override;
35 content::BrowserContext* GetBrowserContextForWindow(
36 aura::Window* window) override;
37 int GetMaximumNumberOfLoggedInUsers() const override;
38 int NumberOfLoggedInUsers() const override;
39 bool IsActiveUserSessionStarted() const override;
40 bool CanLockScreen() const override;
41 bool IsScreenLocked() const override;
42 bool ShouldLockScreenBeforeSuspending() const override;
43 void LockScreen() override;
44 void UnlockScreen() override;
45 bool IsUserSessionBlocked() const override;
46 SessionState GetSessionState() const override;
47 const user_manager::UserInfo* GetUserInfo(
48 ash::MultiProfileIndex index) const override;
49 const user_manager::UserInfo* GetUserInfo(
50 content::BrowserContext* context) const override;
51 bool ShouldShowAvatar(aura::Window* window) const override;
52 void SwitchActiveUser(const std::string& user_id) override;
53 void CycleActiveUser(CycleUser cycle_user) override;
54 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override;
55 void AddSessionStateObserver(ash::SessionStateObserver* observer) override;
56 void RemoveSessionStateObserver(ash::SessionStateObserver* observer) override;
58 // TODO(oshima): Use state machine instead of using boolean variables.
60 // Updates the internal state that indicates whether a session is in progress
61 // and there is an active user. If |has_active_user| is |false|,
62 // |active_user_session_started_| is reset to |false| as well (see below for
63 // the difference between these two flags).
64 void SetHasActiveUser(bool has_active_user);
66 // Updates the internal state that indicates whether the session has been
67 // fully started for the active user. If |active_user_session_started| is
68 // |true|, |has_active_user_| is set to |true| as well (see below for the
69 // difference between these two flags).
70 void SetActiveUserSessionStarted(bool active_user_session_started);
72 // Updates the internal state that indicates whether the screen can be locked.
73 // Locking will only actually be allowed when this value is |true| and there
74 // is an active user.
75 void SetCanLockScreen(bool can_lock_screen);
77 // Updates |should_lock_screen_before_suspending_|.
78 void SetShouldLockScreenBeforeSuspending(bool should_lock);
80 // Updates the internal state that indicates whether user adding screen is
81 // running now.
82 void SetUserAddingScreenRunning(bool user_adding_screen_running);
84 // Setting non NULL image enables avatar icon.
85 void SetUserImage(const gfx::ImageSkia& user_image);
87 private:
88 // Whether a session is in progress and there is an active user.
89 bool has_active_user_;
91 // When a user becomes active, the profile and browser UI are not immediately
92 // available. Only once this flag becomes |true| is the browser startup
93 // complete and both profile and UI are fully available.
94 bool active_user_session_started_;
96 // Whether the screen can be locked. Locking will only actually be allowed
97 // when this is |true| and there is an active user.
98 bool can_lock_screen_;
100 // Return value for ShouldLockScreenBeforeSuspending().
101 bool should_lock_screen_before_suspending_;
103 // Whether the screen is currently locked.
104 bool screen_locked_;
106 // Whether user addding screen is running now.
107 bool user_adding_screen_running_;
109 // The number of users logged in.
110 int logged_in_users_;
112 // The index for the activated user.
113 int active_user_index_;
115 std::vector<MockUserInfo*> user_list_;
117 // The current state of the login screen. |session_state_| becomes active
118 // before the profile and browser UI are available.
119 SessionState session_state_;
121 DISALLOW_COPY_AND_ASSIGN(TestSessionStateDelegate);
124 } // namespace test
125 } // namespace ash
127 #endif // ASH_TEST_TEST_SESSION_STATE_DELEGATE_H_