OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 | |
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" | |
18 | |
19 namespace chromeos { | |
20 | |
21 class FakeSupervisedUserManager; | |
22 | |
23 class MockUserManager : public UserManager { | |
24 public: | |
25 MockUserManager(); | |
26 virtual ~MockUserManager(); | |
27 | |
28 MOCK_METHOD0(Shutdown, void(void)); | |
29 MOCK_CONST_METHOD0(GetUsersAdmittedForMultiProfile, UserList(void)); | |
30 MOCK_CONST_METHOD0(GetLoggedInUsers, const UserList&(void)); | |
31 MOCK_METHOD0(GetLRULoggedInUsers, const UserList&(void)); | |
32 MOCK_METHOD3(UserLoggedIn, void( | |
33 const std::string&, const std::string&, bool)); | |
34 MOCK_METHOD1(SwitchActiveUser, void(const std::string& email)); | |
35 MOCK_METHOD0(SessionStarted, void(void)); | |
36 MOCK_METHOD0(RestoreActiveSessions, void(void)); | |
37 MOCK_METHOD2(RemoveUser, void(const std::string&, RemoveUserDelegate*)); | |
38 MOCK_METHOD1(RemoveUserFromList, void(const std::string&)); | |
39 MOCK_CONST_METHOD1(IsKnownUser, bool(const std::string&)); | |
40 MOCK_CONST_METHOD1(FindUser, const User*(const std::string&)); | |
41 MOCK_METHOD1(FindUserAndModify, User*(const std::string&)); | |
42 MOCK_METHOD2(SaveUserOAuthStatus, void(const std::string&, | |
43 User::OAuthTokenStatus)); | |
44 MOCK_CONST_METHOD1(GetProfileByUser, Profile*(const User*)); | |
45 MOCK_METHOD2(SaveForceOnlineSignin, void(const std::string&, bool)); | |
46 MOCK_METHOD2(SaveUserDisplayName, void(const std::string&, | |
47 const base::string16&)); | |
48 MOCK_METHOD2(UpdateUserAccountData, | |
49 void(const std::string&, const UserAccountData&)); | |
50 MOCK_CONST_METHOD1(GetUserDisplayName, base::string16(const std::string&)); | |
51 MOCK_METHOD2(SaveUserDisplayEmail, void(const std::string&, | |
52 const std::string&)); | |
53 MOCK_CONST_METHOD1(GetUserDisplayEmail, std::string(const std::string&)); | |
54 MOCK_CONST_METHOD0(IsCurrentUserOwner, bool(void)); | |
55 MOCK_CONST_METHOD0(IsCurrentUserNew, bool(void)); | |
56 MOCK_CONST_METHOD0(IsCurrentUserNonCryptohomeDataEphemeral, bool(void)); | |
57 MOCK_CONST_METHOD0(CanCurrentUserLock, bool(void)); | |
58 MOCK_CONST_METHOD0(IsUserLoggedIn, bool(void)); | |
59 MOCK_CONST_METHOD0(IsLoggedInAsRegularUser, bool(void)); | |
60 MOCK_CONST_METHOD0(IsLoggedInAsDemoUser, bool(void)); | |
61 MOCK_CONST_METHOD0(IsLoggedInAsPublicAccount, bool(void)); | |
62 MOCK_CONST_METHOD0(IsLoggedInAsGuest, bool(void)); | |
63 MOCK_CONST_METHOD0(IsLoggedInAsLocallyManagedUser, bool(void)); | |
64 MOCK_CONST_METHOD0(IsLoggedInAsKioskApp, bool(void)); | |
65 MOCK_CONST_METHOD0(IsLoggedInAsStub, bool(void)); | |
66 MOCK_CONST_METHOD0(IsSessionStarted, bool(void)); | |
67 MOCK_CONST_METHOD0(UserSessionsRestored, bool(void)); | |
68 MOCK_CONST_METHOD0(HasBrowserRestarted, bool(void)); | |
69 MOCK_CONST_METHOD1(IsUserNonCryptohomeDataEphemeral, | |
70 bool(const std::string&)); | |
71 MOCK_METHOD1(AddObserver, void(UserManager::Observer*)); | |
72 MOCK_METHOD1(RemoveObserver, void(UserManager::Observer*)); | |
73 MOCK_METHOD1(AddSessionStateObserver, | |
74 void(UserManager::UserSessionStateObserver*)); | |
75 MOCK_METHOD1(RemoveSessionStateObserver, | |
76 void(UserManager::UserSessionStateObserver*)); | |
77 MOCK_METHOD0(NotifyLocalStateChanged, void(void)); | |
78 MOCK_METHOD2(SetUserFlow, void(const std::string&, UserFlow*)); | |
79 MOCK_METHOD1(ResetUserFlow, void(const std::string&)); | |
80 | |
81 MOCK_METHOD2(GetAppModeChromeClientOAuthInfo, bool(std::string*, | |
82 std::string*)); | |
83 MOCK_METHOD2(SetAppModeChromeClientOAuthInfo, void(const std::string&, | |
84 const std::string&)); | |
85 MOCK_CONST_METHOD0(AreLocallyManagedUsersAllowed, bool(void)); | |
86 MOCK_CONST_METHOD1(GetUserProfileDir, | |
87 base::FilePath(const std::string& email)); | |
88 | |
89 // You can't mock these functions easily because nobody can create | |
90 // User objects but the UserManagerImpl and us. | |
91 virtual const UserList& GetUsers() const OVERRIDE; | |
92 virtual const User* GetLoggedInUser() const OVERRIDE; | |
93 virtual UserList GetUnlockUsers() const OVERRIDE; | |
94 virtual const std::string& GetOwnerEmail() OVERRIDE; | |
95 virtual User* GetLoggedInUser() OVERRIDE; | |
96 virtual const User* GetActiveUser() const OVERRIDE; | |
97 virtual User* GetActiveUser() OVERRIDE; | |
98 virtual const User* GetPrimaryUser() const OVERRIDE; | |
99 virtual User* GetUserByProfile(Profile* profile) const OVERRIDE; | |
100 | |
101 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE; | |
102 virtual UserImageManager* GetUserImageManager( | |
103 const std::string& user_id) OVERRIDE; | |
104 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE; | |
105 | |
106 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; | |
107 virtual UserFlow* GetUserFlow(const std::string&) const OVERRIDE; | |
108 virtual bool RespectLocalePreference( | |
109 Profile* profile, | |
110 const User* user, | |
111 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const OVERRIDE; | |
112 | |
113 // Sets a new User instance. Users previously created by this MockUserManager | |
114 // become invalid. | |
115 void SetActiveUser(const std::string& email); | |
116 | |
117 // Creates a new public session user. Users previously created by this | |
118 // MockUserManager become invalid. | |
119 User* CreatePublicAccountUser(const std::string& email); | |
120 | |
121 // Adds a new User instance to the back of the user list. Users previously | |
122 // created by this MockUserManager remain valid. | |
123 void AddUser(const std::string& email); | |
124 | |
125 // Clears the user list and the active user. Users previously created by this | |
126 // MockUserManager become invalid. | |
127 void ClearUserList(); | |
128 | |
129 scoped_ptr<UserFlow> user_flow_; | |
130 scoped_ptr<MockUserImageManager> user_image_manager_; | |
131 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; | |
132 UserList user_list_; | |
133 }; | |
134 | |
135 } // namespace chromeos | |
136 | |
137 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | |
OLD | NEW |