| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef ASH_COMMON_TEST_TEST_SESSION_STATE_DELEGATE_H_ | |
| 6 #define ASH_COMMON_TEST_TEST_SESSION_STATE_DELEGATE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "ash/common/session/session_state_delegate.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "ui/gfx/image/image_skia.h" | |
| 15 | |
| 16 class AccountId; | |
| 17 | |
| 18 namespace ash { | |
| 19 namespace test { | |
| 20 | |
| 21 class MockUserInfo; | |
| 22 | |
| 23 class TestSessionStateDelegate : public SessionStateDelegate { | |
| 24 public: | |
| 25 TestSessionStateDelegate(); | |
| 26 ~TestSessionStateDelegate() override; | |
| 27 | |
| 28 void set_logged_in_users(int users) { logged_in_users_ = users; } | |
| 29 void set_session_state(session_manager::SessionState session_state) { | |
| 30 session_state_ = session_state; | |
| 31 } | |
| 32 void AddUser(const AccountId& account_id); | |
| 33 const user_manager::UserInfo* GetActiveUserInfo() const; | |
| 34 | |
| 35 // SessionStateDelegate: | |
| 36 int GetMaximumNumberOfLoggedInUsers() const override; | |
| 37 int NumberOfLoggedInUsers() const override; | |
| 38 bool IsActiveUserSessionStarted() const override; | |
| 39 bool CanLockScreen() const override; | |
| 40 bool IsScreenLocked() const override; | |
| 41 bool ShouldLockScreenAutomatically() const override; | |
| 42 void LockScreen() override; | |
| 43 void UnlockScreen() override; | |
| 44 bool IsUserSessionBlocked() const override; | |
| 45 session_manager::SessionState GetSessionState() const override; | |
| 46 const user_manager::UserInfo* GetUserInfo( | |
| 47 ash::UserIndex index) const override; | |
| 48 bool ShouldShowAvatar(WmWindow* window) const override; | |
| 49 gfx::ImageSkia GetAvatarImageForWindow(WmWindow* window) const override; | |
| 50 void SwitchActiveUser(const AccountId& account_id) override; | |
| 51 void CycleActiveUser(CycleUserDirection direction) override; | |
| 52 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override; | |
| 53 void AddSessionStateObserver(ash::SessionStateObserver* observer) override; | |
| 54 void RemoveSessionStateObserver(ash::SessionStateObserver* observer) override; | |
| 55 | |
| 56 // TODO(oshima): Use state machine instead of using boolean variables. | |
| 57 | |
| 58 // Updates the internal state that indicates whether a session is in progress | |
| 59 // and there is an active user. If |has_active_user| is |false|, | |
| 60 // |active_user_session_started_| is reset to |false| as well (see below for | |
| 61 // the difference between these two flags). | |
| 62 void SetHasActiveUser(bool has_active_user); | |
| 63 | |
| 64 // Updates the internal state that indicates whether the session has been | |
| 65 // fully started for the active user. If |active_user_session_started| is | |
| 66 // |true|, |has_active_user_| is set to |true| as well (see below for the | |
| 67 // difference between these two flags). | |
| 68 void SetActiveUserSessionStarted(bool active_user_session_started); | |
| 69 | |
| 70 // Updates the internal state that indicates whether the screen can be locked. | |
| 71 // Locking will only actually be allowed when this value is |true| and there | |
| 72 // is an active user. | |
| 73 static void SetCanLockScreen(bool can_lock_screen); | |
| 74 | |
| 75 // Updates |should_lock_screen_automatically_|. | |
| 76 void SetShouldLockScreenAutomatically(bool should_lock); | |
| 77 | |
| 78 // Updates the internal state that indicates whether user adding screen is | |
| 79 // running now. | |
| 80 void SetUserAddingScreenRunning(bool user_adding_screen_running); | |
| 81 | |
| 82 // Setting non NULL image enables avatar icon. | |
| 83 void SetUserImage(const gfx::ImageSkia& user_image); | |
| 84 | |
| 85 private: | |
| 86 class TestUserManager; | |
| 87 | |
| 88 // Whether the screen can be locked. Locking will only actually be allowed | |
| 89 // when this is |true| and there is an active user. | |
| 90 bool can_lock_screen_; | |
| 91 | |
| 92 // Return value for ShouldLockScreenAutomatically(). | |
| 93 bool should_lock_screen_automatically_; | |
| 94 | |
| 95 // Whether the screen is currently locked. | |
| 96 bool screen_locked_; | |
| 97 | |
| 98 // Whether user addding screen is running now. | |
| 99 bool user_adding_screen_running_; | |
| 100 | |
| 101 // The number of users logged in. | |
| 102 int logged_in_users_; | |
| 103 | |
| 104 // The index for the activated user. | |
| 105 int active_user_index_; | |
| 106 | |
| 107 std::vector<std::unique_ptr<MockUserInfo>> user_list_; | |
| 108 | |
| 109 // The user manager to be used instead of the system instance. | |
| 110 std::unique_ptr<TestUserManager> user_manager_; | |
| 111 | |
| 112 // The current state of the login screen. |session_state_| becomes active | |
| 113 // before the profile and browser UI are available. | |
| 114 session_manager::SessionState session_state_; | |
| 115 | |
| 116 DISALLOW_COPY_AND_ASSIGN(TestSessionStateDelegate); | |
| 117 }; | |
| 118 | |
| 119 } // namespace test | |
| 120 } // namespace ash | |
| 121 | |
| 122 #endif // ASH_COMMON_TEST_TEST_SESSION_STATE_DELEGATE_H_ | |
| OLD | NEW |