| OLD | NEW |
| 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 #include "ash/test/test_session_state_delegate.h" | 5 #include "ash/test/test_session_state_delegate.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 TestSessionStateDelegate::TestSessionStateDelegate() | 65 TestSessionStateDelegate::TestSessionStateDelegate() |
| 66 : has_active_user_(false), | 66 : has_active_user_(false), |
| 67 active_user_session_started_(false), | 67 active_user_session_started_(false), |
| 68 can_lock_screen_(true), | 68 can_lock_screen_(true), |
| 69 should_lock_screen_before_suspending_(false), | 69 should_lock_screen_before_suspending_(false), |
| 70 screen_locked_(false), | 70 screen_locked_(false), |
| 71 user_adding_screen_running_(false), | 71 user_adding_screen_running_(false), |
| 72 logged_in_users_(1), | 72 logged_in_users_(1), |
| 73 active_user_index_(0) { | 73 active_user_index_(0), |
| 74 session_state_(SESSION_STATE_LOGIN_PRIMARY) { |
| 74 user_list_.push_back( | 75 user_list_.push_back( |
| 75 new MockUserInfo("First@tray")); // This is intended to be capitalized. | 76 new MockUserInfo("First@tray")); // This is intended to be capitalized. |
| 76 user_list_.push_back( | 77 user_list_.push_back( |
| 77 new MockUserInfo("Second@tray")); // This is intended to be capitalized. | 78 new MockUserInfo("Second@tray")); // This is intended to be capitalized. |
| 78 user_list_.push_back(new MockUserInfo("third@tray")); | 79 user_list_.push_back(new MockUserInfo("third@tray")); |
| 79 user_list_.push_back(new MockUserInfo("someone@tray")); | 80 user_list_.push_back(new MockUserInfo("someone@tray")); |
| 80 } | 81 } |
| 81 | 82 |
| 82 TestSessionStateDelegate::~TestSessionStateDelegate() { | 83 TestSessionStateDelegate::~TestSessionStateDelegate() { |
| 83 STLDeleteElements(&user_list_); | 84 STLDeleteElements(&user_list_); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 screen_locked_ = false; | 139 screen_locked_ = false; |
| 139 } | 140 } |
| 140 | 141 |
| 141 bool TestSessionStateDelegate::IsUserSessionBlocked() const { | 142 bool TestSessionStateDelegate::IsUserSessionBlocked() const { |
| 142 return !IsActiveUserSessionStarted() || IsScreenLocked() || | 143 return !IsActiveUserSessionStarted() || IsScreenLocked() || |
| 143 user_adding_screen_running_; | 144 user_adding_screen_running_; |
| 144 } | 145 } |
| 145 | 146 |
| 146 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() | 147 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() |
| 147 const { | 148 const { |
| 148 if (user_adding_screen_running_) | 149 return session_state_; |
| 149 return SESSION_STATE_LOGIN_SECONDARY; | |
| 150 | |
| 151 // Assuming that if session is not active we're at login. | |
| 152 return IsActiveUserSessionStarted() ? | |
| 153 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY; | |
| 154 } | 150 } |
| 155 | 151 |
| 156 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { | 152 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { |
| 157 has_active_user_ = has_active_user; | 153 has_active_user_ = has_active_user; |
| 158 if (!has_active_user) | 154 if (!has_active_user) { |
| 159 active_user_session_started_ = false; | 155 active_user_session_started_ = false; |
| 160 else | 156 session_state_ = SESSION_STATE_LOGIN_PRIMARY; |
| 157 } else { |
| 161 Shell::GetInstance()->ShowShelf(); | 158 Shell::GetInstance()->ShowShelf(); |
| 159 } |
| 162 } | 160 } |
| 163 | 161 |
| 164 void TestSessionStateDelegate::SetActiveUserSessionStarted( | 162 void TestSessionStateDelegate::SetActiveUserSessionStarted( |
| 165 bool active_user_session_started) { | 163 bool active_user_session_started) { |
| 166 active_user_session_started_ = active_user_session_started; | 164 active_user_session_started_ = active_user_session_started; |
| 167 if (active_user_session_started) { | 165 if (active_user_session_started) { |
| 166 session_state_ = SESSION_STATE_ACTIVE; |
| 168 has_active_user_ = true; | 167 has_active_user_ = true; |
| 169 Shell::GetInstance()->CreateShelf(); | 168 Shell::GetInstance()->CreateShelf(); |
| 170 Shell::GetInstance()->UpdateAfterLoginStatusChange( | 169 Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 171 user::LOGGED_IN_USER); | 170 user::LOGGED_IN_USER); |
| 171 } else { |
| 172 session_state_ = SESSION_STATE_LOGIN_PRIMARY; |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 | 175 |
| 175 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { | 176 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { |
| 176 can_lock_screen_ = can_lock_screen; | 177 can_lock_screen_ = can_lock_screen; |
| 177 } | 178 } |
| 178 | 179 |
| 179 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( | 180 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( |
| 180 bool should_lock) { | 181 bool should_lock) { |
| 181 should_lock_screen_before_suspending_ = should_lock; | 182 should_lock_screen_before_suspending_ = should_lock; |
| 182 } | 183 } |
| 183 | 184 |
| 184 void TestSessionStateDelegate::SetUserAddingScreenRunning( | 185 void TestSessionStateDelegate::SetUserAddingScreenRunning( |
| 185 bool user_adding_screen_running) { | 186 bool user_adding_screen_running) { |
| 186 user_adding_screen_running_ = user_adding_screen_running; | 187 user_adding_screen_running_ = user_adding_screen_running; |
| 188 if (user_adding_screen_running_) |
| 189 session_state_ = SESSION_STATE_LOGIN_SECONDARY; |
| 187 } | 190 } |
| 188 | 191 |
| 189 void TestSessionStateDelegate::SetUserImage( | 192 void TestSessionStateDelegate::SetUserImage( |
| 190 const gfx::ImageSkia& user_image) { | 193 const gfx::ImageSkia& user_image) { |
| 191 user_list_[active_user_index_]->SetUserImage(user_image); | 194 user_list_[active_user_index_]->SetUserImage(user_image); |
| 192 } | 195 } |
| 193 | 196 |
| 197 void TestSessionStateDelegate::SetSessionState(SessionState session_state) { |
| 198 session_state_ = session_state; |
| 199 } |
| 200 |
| 194 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( | 201 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( |
| 195 MultiProfileIndex index) const { | 202 MultiProfileIndex index) const { |
| 196 int max = static_cast<int>(user_list_.size()); | 203 int max = static_cast<int>(user_list_.size()); |
| 197 return user_list_[index < max ? index : max - 1]; | 204 return user_list_[index < max ? index : max - 1]; |
| 198 } | 205 } |
| 199 | 206 |
| 200 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( | 207 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( |
| 201 content::BrowserContext* context) const { | 208 content::BrowserContext* context) const { |
| 202 return user_list_[active_user_index_]; | 209 return user_list_[active_user_index_]; |
| 203 } | 210 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 233 void TestSessionStateDelegate::AddSessionStateObserver( | 240 void TestSessionStateDelegate::AddSessionStateObserver( |
| 234 SessionStateObserver* observer) { | 241 SessionStateObserver* observer) { |
| 235 } | 242 } |
| 236 | 243 |
| 237 void TestSessionStateDelegate::RemoveSessionStateObserver( | 244 void TestSessionStateDelegate::RemoveSessionStateObserver( |
| 238 SessionStateObserver* observer) { | 245 SessionStateObserver* observer) { |
| 239 } | 246 } |
| 240 | 247 |
| 241 } // namespace test | 248 } // namespace test |
| 242 } // namespace ash | 249 } // namespace ash |
| OLD | NEW |