1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/login/mock_user_manager.h"
7 #include "chrome/browser/chromeos/login/fake_supervised_user_manager.h"
11 MockUserManager::MockUserManager()
12 : user_flow_(new DefaultUserFlow()),
13 supervised_user_manager_(new FakeSupervisedUserManager()) {}
15 MockUserManager::~MockUserManager() {
19 const UserList
& MockUserManager::GetUsers() const {
23 const User
* MockUserManager::GetLoggedInUser() const {
24 return user_list_
.empty() ? NULL
: user_list_
.front();
27 User
* MockUserManager::GetLoggedInUser() {
28 return user_list_
.empty() ? NULL
: user_list_
.front();
31 UserList
MockUserManager::GetUnlockUsers() const {
35 const std::string
& MockUserManager::GetOwnerEmail() {
36 return GetLoggedInUser()->email();
39 const User
* MockUserManager::GetActiveUser() const {
40 return GetLoggedInUser();
43 User
* MockUserManager::GetActiveUser() {
44 return GetLoggedInUser();
47 const User
* MockUserManager::GetPrimaryUser() const {
48 return GetLoggedInUser();
51 User
* MockUserManager::GetUserByProfile(Profile
* profile
) const {
52 return user_list_
.empty() ? NULL
: user_list_
.front();
55 UserImageManager
* MockUserManager::GetUserImageManager(
56 const std::string
& user_id
) {
60 SupervisedUserManager
* MockUserManager::GetSupervisedUserManager() {
61 return supervised_user_manager_
.get();
64 // Creates a new User instance.
65 void MockUserManager::SetActiveUser(const std::string
& email
) {
70 UserFlow
* MockUserManager::GetCurrentUserFlow() const {
71 return user_flow_
.get();
74 UserFlow
* MockUserManager::GetUserFlow(const std::string
&) const {
75 return user_flow_
.get();
78 User
* MockUserManager::CreatePublicAccountUser(const std::string
& email
) {
80 user_list_
.push_back(User::CreatePublicAccountUser(email
));
81 return user_list_
.back();
84 void MockUserManager::AddUser(const std::string
& email
) {
85 user_list_
.push_back(User::CreateRegularUser(email
));
88 void MockUserManager::ClearUserList() {
89 // Can't use STLDeleteElements because of the protected destructor of User.
90 UserList::iterator user
;
91 for (user
= user_list_
.begin(); user
!= user_list_
.end(); ++user
)
96 bool MockUserManager::RespectLocalePreference(
99 scoped_ptr
<locale_util::SwitchLanguageCallback
> callback
) const {
103 } // namespace chromeos