Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc

Issue 2512693003: ash: Replace SessionStateDelegate::CanAddUserToMultiProfile (Closed)
Patch Set: for #2 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/session_state_delegate_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 // Flush tasks posted to IO. 238 // Flush tasks posted to IO.
239 base::RunLoop().RunUntilIdle(); 239 base::RunLoop().RunUntilIdle();
240 } 240 }
241 241
242 // Make sure adding users to multiprofiles disabled by reaching maximum 242 // Make sure adding users to multiprofiles disabled by reaching maximum
243 // number of users in sessions. 243 // number of users in sessions.
244 TEST_F(SessionStateDelegateChromeOSTest, 244 TEST_F(SessionStateDelegateChromeOSTest,
245 AddUserToMultiprofileDisallowedByMaximumUsers) { 245 AddUserToMultiprofileDisallowedByMaximumUsers) {
246 InitForMultiProfile(); 246 InitForMultiProfile();
247 ash::SessionStateDelegate::AddUserError add_user_error;
248 247
249 EXPECT_TRUE( 248 EXPECT_EQ(ash::AddUserSessionPolicy::ALLOWED,
250 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 249 session_state_delegate()->GetAddUserSessionPolicy());
251 const AccountId account_id(AccountId::FromUserEmail(kUser)); 250 const AccountId account_id(AccountId::FromUserEmail(kUser));
252 user_manager()->LoginUser(account_id); 251 user_manager()->LoginUser(account_id);
253 while (session_state_delegate()->NumberOfLoggedInUsers() < 252 while (session_state_delegate()->NumberOfLoggedInUsers() <
254 session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) { 253 session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) {
255 UserAddedToSession("bb@b.b"); 254 UserAddedToSession("bb@b.b");
256 } 255 }
257 EXPECT_FALSE( 256 EXPECT_EQ(ash::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED,
258 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 257 session_state_delegate()->GetAddUserSessionPolicy());
259 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_MAXIMUM_USERS_REACHED,
260 add_user_error);
261 } 258 }
262 259
263 // Make sure adding users to multiprofiles disabled by logging in all possible 260 // Make sure adding users to multiprofiles disabled by logging in all possible
264 // users. 261 // users.
265 TEST_F(SessionStateDelegateChromeOSTest, 262 TEST_F(SessionStateDelegateChromeOSTest,
266 AddUserToMultiprofileDisallowedByAllUsersLogged) { 263 AddUserToMultiprofileDisallowedByAllUsersLogged) {
267 InitForMultiProfile(); 264 InitForMultiProfile();
268 ash::SessionStateDelegate::AddUserError add_user_error;
269 265
270 EXPECT_TRUE( 266 EXPECT_EQ(ash::AddUserSessionPolicy::ALLOWED,
271 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 267 session_state_delegate()->GetAddUserSessionPolicy());
272 const AccountId account_id(AccountId::FromUserEmail(kUser)); 268 const AccountId account_id(AccountId::FromUserEmail(kUser));
273 user_manager()->LoginUser(account_id); 269 user_manager()->LoginUser(account_id);
274 UserAddedToSession("bb@b.b"); 270 UserAddedToSession("bb@b.b");
275 EXPECT_FALSE( 271 EXPECT_EQ(ash::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS,
276 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 272 session_state_delegate()->GetAddUserSessionPolicy());
277 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_OUT_OF_USERS,
278 add_user_error);
279 } 273 }
280 274
281 // Make sure adding users to multiprofiles disabled by primary user policy. 275 // Make sure adding users to multiprofiles disabled by primary user policy.
282 TEST_F(SessionStateDelegateChromeOSTest, 276 TEST_F(SessionStateDelegateChromeOSTest,
283 AddUserToMultiprofileDisallowedByPrimaryUserPolicy) { 277 AddUserToMultiprofileDisallowedByPrimaryUserPolicy) {
284 InitForMultiProfile(); 278 InitForMultiProfile();
285 ash::SessionStateDelegate::AddUserError add_user_error;
286 279
287 EXPECT_TRUE( 280 EXPECT_EQ(ash::AddUserSessionPolicy::ALLOWED,
288 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 281 session_state_delegate()->GetAddUserSessionPolicy());
289 const AccountId account_id(AccountId::FromUserEmail(kUser)); 282 const AccountId account_id(AccountId::FromUserEmail(kUser));
290 user_manager()->LoginUser(account_id); 283 user_manager()->LoginUser(account_id);
291 user_profile_->GetPrefs()->SetString( 284 user_profile_->GetPrefs()->SetString(
292 prefs::kMultiProfileUserBehavior, 285 prefs::kMultiProfileUserBehavior,
293 chromeos::MultiProfileUserController::kBehaviorNotAllowed); 286 chromeos::MultiProfileUserController::kBehaviorNotAllowed);
294 user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b")); 287 user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b"));
295 EXPECT_FALSE( 288 EXPECT_EQ(ash::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER,
296 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 289 session_state_delegate()->GetAddUserSessionPolicy());
297 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER,
298 add_user_error);
299 } 290 }
300 291
301 } // namespace chromeos 292 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/session_state_delegate_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698