1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file. 4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/test/test_session_state_delegate.h" 6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <algorithm> 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <string> 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ash/shell.h" 11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ash/system/user/login_status.h" 125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "base/stl_util.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/user_manager/user_info.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liunamespace ash { 195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liunamespace test { 205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace { 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// The the "canonicalized" user ID from a given |email| address. 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)std::string GetUserIDFromEmail(const std::string& email) { 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) std::string user_id = email; 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) std::transform(user_id.begin(), user_id.end(), user_id.begin(), ::tolower); 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return user_id; 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass MockUserInfo : public user_manager::UserInfo { 335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu public: 345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu explicit MockUserInfo(const std::string& id) : email_(id) {} 355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual ~MockUserInfo() {} 365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu void SetUserImage(const gfx::ImageSkia& user_image) { 385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_image_ = user_image; 395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual base::string16 GetDisplayName() const OVERRIDE { 425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return base::UTF8ToUTF16("Über tray Über tray Über tray Über tray"); 435c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 445c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 455c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual base::string16 GetGivenName() const OVERRIDE { 465c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return base::UTF8ToUTF16("Über Über Über Über"); 475c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 485c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 495c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual std::string GetEmail() const OVERRIDE { return email_; } 505c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 515c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual std::string GetUserID() const OVERRIDE { 525c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return GetUserIDFromEmail(GetEmail()); 535c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 545c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 555c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual const gfx::ImageSkia& GetImage() const OVERRIDE { 565c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return user_image_; 575c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 585c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 595c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // A test user image. 605c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu gfx::ImageSkia user_image_; 615c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 625c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu std::string email_; 635c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 645c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu DISALLOW_COPY_AND_ASSIGN(MockUserInfo); 655c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}; 66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TestSessionStateDelegate::TestSessionStateDelegate() 68eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch : has_active_user_(false), 69eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch active_user_session_started_(false), 70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) can_lock_screen_(true), 711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) should_lock_screen_before_suspending_(false), 7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) screen_locked_(false), 73bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch user_adding_screen_running_(false), 745c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu logged_in_users_(1), 755c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu active_user_index_(0) { 765c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_.push_back( 775c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu new MockUserInfo("First@tray")); // This is intended to be capitalized. 785c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_.push_back( 795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu new MockUserInfo("Second@tray")); // This is intended to be capitalized. 805c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_.push_back(new MockUserInfo("third@tray")); 815c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_.push_back(new MockUserInfo("someone@tray")); 82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TestSessionStateDelegate::~TestSessionStateDelegate() { 855c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu STLDeleteElements(&user_list_); 865c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 875c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid TestSessionStateDelegate::AddUser(const std::string user_id) { 895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_.push_back(new MockUserInfo(user_id)); 905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 915c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 92116680a4aac90f2aa7413d9095a592090648e557Ben Murdochconst user_manager::UserInfo* TestSessionStateDelegate::GetActiveUserInfo() 93116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const { 945c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return user_list_[active_user_index_]; 95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)content::BrowserContext* 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TestSessionStateDelegate::GetBrowserContextByIndex( 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MultiProfileIndex index) { 100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return NULL; 101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 103effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochcontent::BrowserContext* 104effb81e5f8246d0db0270817048dc992db66e9fbBen MurdochTestSessionStateDelegate::GetBrowserContextForWindow( 105effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch aura::Window* window) { 106effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch return NULL; 107effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch} 108effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int TestSessionStateDelegate::GetMaximumNumberOfLoggedInUsers() const { 11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return 3; 11190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int TestSessionStateDelegate::NumberOfLoggedInUsers() const { 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // TODO(skuhne): Add better test framework to test multiple profiles. 11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return has_active_user_ ? logged_in_users_ : 0; 116c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 117c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool TestSessionStateDelegate::IsActiveUserSessionStarted() const { 119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return active_user_session_started_; 120c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 121c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 122c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool TestSessionStateDelegate::CanLockScreen() const { 123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return has_active_user_ && can_lock_screen_; 124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool TestSessionStateDelegate::IsScreenLocked() const { 127c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return screen_locked_; 128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 129c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)bool TestSessionStateDelegate::ShouldLockScreenBeforeSuspending() const { 1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return should_lock_screen_before_suspending_; 1324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 1334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void TestSessionStateDelegate::LockScreen() { 135c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (CanLockScreen()) 136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) screen_locked_ = true; 137c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void TestSessionStateDelegate::UnlockScreen() { 140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) screen_locked_ = false; 141c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 143bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdochbool TestSessionStateDelegate::IsUserSessionBlocked() const { 144bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch return !IsActiveUserSessionStarted() || IsScreenLocked() || 145bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch user_adding_screen_running_; 146bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch} 147bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 148a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochSessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() 149a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const { 150a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch if (user_adding_screen_running_) 151a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch return SESSION_STATE_LOGIN_SECONDARY; 152a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 153a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Assuming that if session is not active we're at login. 154a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch return IsActiveUserSessionStarted() ? 155a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY; 156a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 157a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) has_active_user_ = has_active_user; 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (!has_active_user) 161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) active_user_session_started_ = false; 162eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch else 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shell::GetInstance()->ShowShelf(); 164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void TestSessionStateDelegate::SetActiveUserSessionStarted( 167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool active_user_session_started) { 168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) active_user_session_started_ = active_user_session_started; 169eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (active_user_session_started) { 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) has_active_user_ = true; 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shell::GetInstance()->CreateShelf(); 172eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch Shell::GetInstance()->UpdateAfterLoginStatusChange( 173eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch user::LOGGED_IN_USER); 174eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) can_lock_screen_ = can_lock_screen; 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( 1821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) bool should_lock) { 1831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) should_lock_screen_before_suspending_ = should_lock; 1841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 1851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 186bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdochvoid TestSessionStateDelegate::SetUserAddingScreenRunning( 187bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch bool user_adding_screen_running) { 188bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch user_adding_screen_running_ = user_adding_screen_running; 189bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch} 190bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 191effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid TestSessionStateDelegate::SetUserImage( 192effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch const gfx::ImageSkia& user_image) { 1935c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu user_list_[active_user_index_]->SetUserImage(user_image); 19490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 19590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 196116680a4aac90f2aa7413d9095a592090648e557Ben Murdochconst user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( 197a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch MultiProfileIndex index) const { 1985c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu int max = static_cast<int>(user_list_.size()); 1995c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return user_list_[index < max ? index : max - 1]; 200a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 201a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 202116680a4aac90f2aa7413d9095a592090648e557Ben Murdochconst user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( 203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::BrowserContext* context) const { 2045c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return user_list_[active_user_index_]; 20590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 20690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2075c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liubool TestSessionStateDelegate::ShouldShowAvatar(aura::Window* window) const { 2085c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return !GetActiveUserInfo()->GetImage().isNull(); 20990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 21090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void TestSessionStateDelegate::SwitchActiveUser(const std::string& user_id) { 2128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Make sure this is a user id and not an email address. 2138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ(user_id, GetUserIDFromEmail(user_id)); 2145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu active_user_index_ = 0; 2155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu for (std::vector<MockUserInfo*>::iterator iter = user_list_.begin(); 2165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu iter != user_list_.end(); 2175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu ++iter) { 2185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu if ((*iter)->GetUserID() == user_id) { 2195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu active_user_index_ = iter - user_list_.begin(); 2205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return; 2215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 2225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 2235c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu NOTREACHED() << "Unknown user:" << user_id; 22490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 22590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 226a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void TestSessionStateDelegate::CycleActiveUser(CycleUser cycle_user) { 2275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu SwitchActiveUser("someone@tray"); 22868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)} 22968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 2306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool TestSessionStateDelegate::IsMultiProfileAllowedByPrimaryUserPolicy() 2316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const { 2326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return true; 2336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 2346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void TestSessionStateDelegate::AddSessionStateObserver( 236eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch SessionStateObserver* observer) { 237868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 238868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 239868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void TestSessionStateDelegate::RemoveSessionStateObserver( 240eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch SessionStateObserver* observer) { 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 24290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 243c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} // namespace test 244c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} // namespace ash 245