Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / users / mock_user_manager.h
blobc7545bc6b6e7dcfbf8a7c085e3fb82fc20e23868
1 // Copyright 2014 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_USERS_MOCK_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MOCK_USER_MANAGER_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/login/user_flow.h"
13 #include "chrome/browser/chromeos/login/users/avatar/mock_user_image_manager.h"
14 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
15 #include "components/user_manager/user.h"
16 #include "components/user_manager/user_image/user_image.h"
17 #include "testing/gmock/include/gmock/gmock.h"
19 namespace chromeos {
21 class FakeSupervisedUserManager;
23 class MockUserManager : public ChromeUserManager {
24 public:
25 MockUserManager();
26 virtual ~MockUserManager();
28 MOCK_METHOD0(Shutdown, void(void));
29 MOCK_CONST_METHOD0(GetUsersAllowedForMultiProfile,
30 user_manager::UserList(void));
31 MOCK_CONST_METHOD0(GetUsersAllowedForSupervisedUsersCreation,
32 user_manager::UserList(void));
33 MOCK_CONST_METHOD0(GetLoggedInUsers, const user_manager::UserList&(void));
34 MOCK_CONST_METHOD0(GetLRULoggedInUsers, const user_manager::UserList&(void));
35 MOCK_METHOD3(UserLoggedIn, void(
36 const std::string&, const std::string&, bool));
37 MOCK_METHOD1(SwitchActiveUser, void(const std::string& email));
38 MOCK_METHOD0(SessionStarted, void(void));
39 MOCK_METHOD2(RemoveUser,
40 void(const std::string&, user_manager::RemoveUserDelegate*));
41 MOCK_METHOD1(RemoveUserFromList, void(const std::string&));
42 MOCK_CONST_METHOD1(IsKnownUser, bool(const std::string&));
43 MOCK_CONST_METHOD1(FindUser, const user_manager::User*(const std::string&));
44 MOCK_METHOD1(FindUserAndModify, user_manager::User*(const std::string&));
45 MOCK_METHOD2(SaveUserOAuthStatus,
46 void(const std::string&, user_manager::User::OAuthTokenStatus));
47 MOCK_METHOD2(SaveForceOnlineSignin, void(const std::string&, bool));
48 MOCK_METHOD2(SaveUserDisplayName, void(const std::string&,
49 const base::string16&));
50 MOCK_METHOD2(UpdateUserAccountData,
51 void(const std::string&, const UserAccountData&));
52 MOCK_CONST_METHOD1(GetUserDisplayName, base::string16(const std::string&));
53 MOCK_METHOD2(SaveUserDisplayEmail, void(const std::string&,
54 const std::string&));
55 MOCK_CONST_METHOD1(GetUserDisplayEmail, std::string(const std::string&));
56 MOCK_CONST_METHOD0(IsCurrentUserOwner, bool(void));
57 MOCK_CONST_METHOD0(IsCurrentUserNew, bool(void));
58 MOCK_CONST_METHOD0(IsCurrentUserNonCryptohomeDataEphemeral, bool(void));
59 MOCK_CONST_METHOD0(CanCurrentUserLock, bool(void));
60 MOCK_CONST_METHOD0(IsUserLoggedIn, bool(void));
61 MOCK_CONST_METHOD0(IsLoggedInAsUserWithGaiaAccount, bool(void));
62 MOCK_CONST_METHOD0(IsLoggedInAsPublicAccount, bool(void));
63 MOCK_CONST_METHOD0(IsLoggedInAsGuest, bool(void));
64 MOCK_CONST_METHOD0(IsLoggedInAsSupervisedUser, bool(void));
65 MOCK_CONST_METHOD0(IsLoggedInAsKioskApp, bool(void));
66 MOCK_CONST_METHOD0(IsLoggedInAsStub, bool(void));
67 MOCK_CONST_METHOD0(IsSessionStarted, bool(void));
68 MOCK_CONST_METHOD1(IsUserNonCryptohomeDataEphemeral,
69 bool(const std::string&));
70 MOCK_METHOD1(AddObserver, void(UserManager::Observer*));
71 MOCK_METHOD1(RemoveObserver, void(UserManager::Observer*));
72 MOCK_METHOD1(AddSessionStateObserver,
73 void(UserManager::UserSessionStateObserver*));
74 MOCK_METHOD1(RemoveSessionStateObserver,
75 void(UserManager::UserSessionStateObserver*));
76 MOCK_METHOD0(NotifyLocalStateChanged, void(void));
77 MOCK_CONST_METHOD0(AreSupervisedUsersAllowed, bool(void));
79 // UserManagerBase overrides:
80 MOCK_CONST_METHOD0(AreEphemeralUsersEnabled, bool(void));
81 MOCK_CONST_METHOD0(GetApplicationLocale, const std::string&(void));
82 MOCK_CONST_METHOD0(GetLocalState, PrefService*(void));
83 MOCK_CONST_METHOD2(HandleUserOAuthTokenStatusChange,
84 void(const std::string&,
85 user_manager::User::OAuthTokenStatus status));
86 MOCK_CONST_METHOD0(IsEnterpriseManaged, bool(void));
87 MOCK_METHOD1(LoadPublicAccounts, void(std::set<std::string>*));
88 MOCK_METHOD0(PerformPreUserListLoadingActions, void(void));
89 MOCK_METHOD0(PerformPostUserListLoadingActions, void(void));
90 MOCK_METHOD1(PerformPostUserLoggedInActions, void(bool));
91 MOCK_CONST_METHOD1(IsDemoApp, bool(const std::string&));
92 MOCK_CONST_METHOD1(IsKioskApp, bool(const std::string&));
93 MOCK_CONST_METHOD1(IsPublicAccountMarkedForRemoval, bool(const std::string&));
94 MOCK_METHOD0(DemoAccountLoggedIn, void(void));
95 MOCK_METHOD1(KioskAppLoggedIn, void(const std::string&));
96 MOCK_METHOD1(PublicAccountUserLoggedIn, void(user_manager::User*));
97 MOCK_METHOD1(SupervisedUserLoggedIn, void(const std::string&));
99 // You can't mock these functions easily because nobody can create
100 // User objects but the ChromeUserManager and us.
101 const user_manager::UserList& GetUsers() const override;
102 const user_manager::User* GetLoggedInUser() const override;
103 user_manager::UserList GetUnlockUsers() const override;
104 const std::string& GetOwnerEmail() const override;
105 user_manager::User* GetLoggedInUser() override;
106 const user_manager::User* GetActiveUser() const override;
107 user_manager::User* GetActiveUser() override;
108 const user_manager::User* GetPrimaryUser() const override;
110 // ChromeUserManager overrides:
111 BootstrapManager* GetBootstrapManager() override;
112 MultiProfileUserController* GetMultiProfileUserController() override;
113 UserImageManager* GetUserImageManager(const std::string& user_id) override;
114 SupervisedUserManager* GetSupervisedUserManager() override;
115 MOCK_METHOD2(SetUserFlow, void(const std::string&, UserFlow*));
116 MOCK_METHOD1(ResetUserFlow, void(const std::string&));
117 UserFlow* GetCurrentUserFlow() const override;
118 UserFlow* GetUserFlow(const std::string&) const override;
120 // Sets a new User instance. Users previously created by this MockUserManager
121 // become invalid.
122 void SetActiveUser(const std::string& email);
124 // Creates a new public session user. Users previously created by this
125 // MockUserManager become invalid.
126 user_manager::User* CreatePublicAccountUser(const std::string& email);
128 // Creates a new kiosk app user. Users previously created by this
129 // MockUserManager become invalid.
130 user_manager::User* CreateKioskAppUser(const std::string& user_id);
132 // Adds a new User instance to the back of the user list. Users previously
133 // created by this MockUserManager remain valid.
134 void AddUser(const std::string& email);
136 // Clears the user list and the active user. Users previously created by this
137 // MockUserManager become invalid.
138 void ClearUserList();
140 scoped_ptr<UserFlow> user_flow_;
141 scoped_ptr<MockUserImageManager> user_image_manager_;
142 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_;
143 user_manager::UserList user_list_;
146 } // namespace chromeos
148 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MOCK_USER_MANAGER_H_