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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_
10 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/login/mock_user_image_manager.h"
13 #include "chrome/browser/chromeos/login/user.h"
14 #include "chrome/browser/chromeos/login/user_flow.h"
15 #include "chrome/browser/chromeos/login/user_image.h"
16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "testing/gmock/include/gmock/gmock.h"
21 class MockUserManager
: public UserManager
{
24 virtual ~MockUserManager();
26 MOCK_METHOD0(Shutdown
, void(void));
27 MOCK_CONST_METHOD0(GetUsersAdmittedForMultiProfile
, UserList(void));
28 MOCK_CONST_METHOD0(GetLoggedInUsers
, const UserList
&(void));
29 MOCK_METHOD0(GetLRULoggedInUsers
, const UserList
&(void));
30 MOCK_METHOD3(UserLoggedIn
, void(
31 const std::string
&, const std::string
&, bool));
32 MOCK_METHOD1(SwitchActiveUser
, void(const std::string
& email
));
33 MOCK_METHOD0(SessionStarted
, void(void));
34 MOCK_METHOD0(RestoreActiveSessions
, void(void));
35 MOCK_METHOD2(RemoveUser
, void(const std::string
&, RemoveUserDelegate
*));
36 MOCK_METHOD1(RemoveUserFromList
, void(const std::string
&));
37 MOCK_CONST_METHOD1(IsKnownUser
, bool(const std::string
&));
38 MOCK_CONST_METHOD1(FindUser
, const User
*(const std::string
&));
39 MOCK_CONST_METHOD1(FindLocallyManagedUser
, const User
*(const string16
&));
40 MOCK_METHOD2(SaveUserOAuthStatus
, void(const std::string
&,
41 User::OAuthTokenStatus
));
42 MOCK_METHOD2(SaveUserDisplayName
, void(const std::string
&,
44 MOCK_CONST_METHOD1(GetUserDisplayName
, string16(const std::string
&));
45 MOCK_METHOD2(SaveUserDisplayEmail
, void(const std::string
&,
47 MOCK_CONST_METHOD1(GetUserDisplayEmail
, std::string(const std::string
&));
48 MOCK_CONST_METHOD0(IsCurrentUserOwner
, bool(void));
49 MOCK_CONST_METHOD0(IsCurrentUserNew
, bool(void));
50 MOCK_CONST_METHOD0(IsCurrentUserNonCryptohomeDataEphemeral
, bool(void));
51 MOCK_CONST_METHOD0(CanCurrentUserLock
, bool(void));
52 MOCK_CONST_METHOD0(IsUserLoggedIn
, bool(void));
53 MOCK_CONST_METHOD0(IsLoggedInAsRegularUser
, bool(void));
54 MOCK_CONST_METHOD0(IsLoggedInAsDemoUser
, bool(void));
55 MOCK_CONST_METHOD0(IsLoggedInAsPublicAccount
, bool(void));
56 MOCK_CONST_METHOD0(IsLoggedInAsGuest
, bool(void));
57 MOCK_CONST_METHOD0(IsLoggedInAsLocallyManagedUser
, bool(void));
58 MOCK_CONST_METHOD0(IsLoggedInAsKioskApp
, bool(void));
59 MOCK_CONST_METHOD0(IsLoggedInAsStub
, bool(void));
60 MOCK_CONST_METHOD0(IsSessionStarted
, bool(void));
61 MOCK_CONST_METHOD0(UserSessionsRestored
, bool(void));
62 MOCK_CONST_METHOD0(HasBrowserRestarted
, bool(void));
63 MOCK_CONST_METHOD1(IsUserNonCryptohomeDataEphemeral
,
64 bool(const std::string
&));
65 MOCK_METHOD1(AddObserver
, void(UserManager::Observer
*));
66 MOCK_METHOD1(RemoveObserver
, void(UserManager::Observer
*));
67 MOCK_METHOD1(AddSessionStateObserver
,
68 void(UserManager::UserSessionStateObserver
*));
69 MOCK_METHOD1(RemoveSessionStateObserver
,
70 void(UserManager::UserSessionStateObserver
*));
71 MOCK_METHOD0(NotifyLocalStateChanged
, void(void));
72 MOCK_METHOD2(SetUserFlow
, void(const std::string
&, UserFlow
*));
73 MOCK_METHOD1(ResetUserFlow
, void(const std::string
&));
74 MOCK_METHOD4(CreateLocallyManagedUserRecord
, const User
*(
79 MOCK_CONST_METHOD1(GetManagedUserSyncId
, std::string(
80 const std::string
& managed_user_id
));
81 MOCK_CONST_METHOD1(GetManagerDisplayNameForManagedUser
, string16(
83 MOCK_CONST_METHOD1(GetManagerUserIdForManagedUser
, std::string(
85 MOCK_CONST_METHOD1(GetManagerDisplayEmailForManagedUser
, std::string(
87 MOCK_METHOD0(GenerateUniqueLocallyManagedUserId
, std::string(void));
88 MOCK_METHOD1(StartLocallyManagedUserCreationTransaction
,
89 void(const string16
&));
90 MOCK_METHOD1(SetLocallyManagedUserCreationTransactionUserId
,
91 void(const std::string
&));
92 MOCK_METHOD0(CommitLocallyManagedUserCreationTransaction
, void(void));
94 MOCK_METHOD2(GetAppModeChromeClientOAuthInfo
, bool(std::string
*,
96 MOCK_METHOD2(SetAppModeChromeClientOAuthInfo
, void(const std::string
&,
98 MOCK_CONST_METHOD0(AreLocallyManagedUsersAllowed
, bool(void));
99 MOCK_CONST_METHOD1(GetUserProfileDir
,
100 base::FilePath(const std::string
& email
));
102 // You can't mock these functions easily because nobody can create
103 // User objects but the UserManagerImpl and us.
104 virtual const UserList
& GetUsers() const OVERRIDE
;
105 virtual const User
* GetLoggedInUser() const OVERRIDE
;
106 virtual const std::string
& GetOwnerEmail() OVERRIDE
;
107 virtual User
* GetLoggedInUser() OVERRIDE
;
108 virtual const User
* GetActiveUser() const OVERRIDE
;
109 virtual User
* GetActiveUser() OVERRIDE
;
111 virtual UserImageManager
* GetUserImageManager() OVERRIDE
;
113 virtual UserFlow
* GetCurrentUserFlow() const OVERRIDE
;
114 virtual UserFlow
* GetUserFlow(const std::string
&) const OVERRIDE
;
116 // Sets a new User instance.
117 void SetActiveUser(const std::string
& email
);
119 // Creates a new public session user. Users previously created by this
120 // MockUserManager become invalid.
121 User
* CreatePublicAccountUser(const std::string
& email
);
124 scoped_ptr
<MockUserImageManager
> user_image_manager_
;
125 scoped_ptr
<UserFlow
> user_flow_
;
129 } // namespace chromeos
131 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_