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/common/login_status.h" | 10 #include "ash/common/login_status.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 void TestSessionStateDelegate::SetUserAddingScreenRunning( | 194 void TestSessionStateDelegate::SetUserAddingScreenRunning( |
195 bool user_adding_screen_running) { | 195 bool user_adding_screen_running) { |
196 user_adding_screen_running_ = user_adding_screen_running; | 196 user_adding_screen_running_ = user_adding_screen_running; |
197 if (user_adding_screen_running_) | 197 if (user_adding_screen_running_) |
198 session_state_ = SESSION_STATE_LOGIN_SECONDARY; | 198 session_state_ = SESSION_STATE_LOGIN_SECONDARY; |
199 else | 199 else |
200 session_state_ = SESSION_STATE_ACTIVE; | 200 session_state_ = SESSION_STATE_ACTIVE; |
201 } | 201 } |
202 | 202 |
203 void TestSessionStateDelegate::SetUserImage( | 203 void TestSessionStateDelegate::SetUserImage(const gfx::ImageSkia& user_image) { |
204 const gfx::ImageSkia& user_image) { | |
205 user_list_[active_user_index_]->SetUserImage(user_image); | 204 user_list_[active_user_index_]->SetUserImage(user_image); |
206 } | 205 } |
207 | 206 |
208 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( | 207 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( |
209 UserIndex index) const { | 208 UserIndex index) const { |
210 int max = static_cast<int>(user_list_.size()); | 209 int max = static_cast<int>(user_list_.size()); |
211 return user_list_[index < max ? index : max - 1]; | 210 return user_list_[index < max ? index : max - 1]; |
212 } | 211 } |
213 | 212 |
214 bool TestSessionStateDelegate::ShouldShowAvatar(WmWindow* window) const { | 213 bool TestSessionStateDelegate::ShouldShowAvatar(WmWindow* window) const { |
215 return !GetActiveUserInfo()->GetImage().isNull(); | 214 return !GetActiveUserInfo()->GetImage().isNull(); |
216 } | 215 } |
217 | 216 |
218 gfx::ImageSkia TestSessionStateDelegate::GetAvatarImageForWindow( | 217 gfx::ImageSkia TestSessionStateDelegate::GetAvatarImageForWindow( |
219 WmWindow* window) const { | 218 WmWindow* window) const { |
220 return gfx::ImageSkia(); | 219 return gfx::ImageSkia(); |
221 } | 220 } |
222 | 221 |
223 void TestSessionStateDelegate::SwitchActiveUser(const AccountId& account_id) { | 222 void TestSessionStateDelegate::SwitchActiveUser(const AccountId& account_id) { |
224 // Make sure this is a user id and not an email address. | 223 // Make sure this is a user id and not an email address. |
225 EXPECT_EQ(account_id.GetUserEmail(), | 224 EXPECT_EQ(account_id.GetUserEmail(), |
226 GetUserIdFromEmail(account_id.GetUserEmail())); | 225 GetUserIdFromEmail(account_id.GetUserEmail())); |
227 active_user_index_ = 0; | 226 active_user_index_ = 0; |
228 for (std::vector<MockUserInfo*>::iterator iter = user_list_.begin(); | 227 for (std::vector<MockUserInfo*>::iterator iter = user_list_.begin(); |
229 iter != user_list_.end(); | 228 iter != user_list_.end(); ++iter) { |
230 ++iter) { | |
231 if ((*iter)->GetAccountId() == account_id) { | 229 if ((*iter)->GetAccountId() == account_id) { |
232 active_user_index_ = iter - user_list_.begin(); | 230 active_user_index_ = iter - user_list_.begin(); |
233 return; | 231 return; |
234 } | 232 } |
235 } | 233 } |
236 NOTREACHED() << "Unknown user:" << account_id.GetUserEmail(); | 234 NOTREACHED() << "Unknown user:" << account_id.GetUserEmail(); |
237 } | 235 } |
238 | 236 |
239 void TestSessionStateDelegate::CycleActiveUser(CycleUser cycle_user) { | 237 void TestSessionStateDelegate::CycleActiveUser(CycleUser cycle_user) { |
240 SwitchActiveUser(AccountId::FromUserEmail("someone@tray")); | 238 SwitchActiveUser(AccountId::FromUserEmail("someone@tray")); |
241 } | 239 } |
242 | 240 |
243 bool TestSessionStateDelegate::IsMultiProfileAllowedByPrimaryUserPolicy() | 241 bool TestSessionStateDelegate::IsMultiProfileAllowedByPrimaryUserPolicy() |
244 const { | 242 const { |
245 return true; | 243 return true; |
246 } | 244 } |
247 | 245 |
248 void TestSessionStateDelegate::AddSessionStateObserver( | 246 void TestSessionStateDelegate::AddSessionStateObserver( |
249 SessionStateObserver* observer) { | 247 SessionStateObserver* observer) {} |
250 } | |
251 | 248 |
252 void TestSessionStateDelegate::RemoveSessionStateObserver( | 249 void TestSessionStateDelegate::RemoveSessionStateObserver( |
253 SessionStateObserver* observer) { | 250 SessionStateObserver* observer) {} |
254 } | |
255 | 251 |
256 } // namespace test | 252 } // namespace test |
257 } // namespace ash | 253 } // namespace ash |
OLD | NEW |