Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 "subject", "issuer", base::Time(), base::Time())); | 222 "subject", "issuer", base::Time(), base::Time())); |
| 223 service->OnTrustAnchorsChanged(certificates); | 223 service->OnTrustAnchorsChanged(certificates); |
| 224 EXPECT_TRUE(service->has_policy_certificates()); | 224 EXPECT_TRUE(service->has_policy_certificates()); |
| 225 EXPECT_FALSE( | 225 EXPECT_FALSE( |
| 226 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy()); | 226 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy()); |
| 227 | 227 |
| 228 // Flush tasks posted to IO. | 228 // Flush tasks posted to IO. |
| 229 base::RunLoop().RunUntilIdle(); | 229 base::RunLoop().RunUntilIdle(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Make sure adding users to multiprofiles disabled by reaching maximum | |
| 233 // number of users in sessions. | |
| 234 TEST_F(SessionStateDelegateChromeOSTest, | |
| 235 AddUserToMultiprofileDisallowedByMaximumUsers) { | |
| 236 InitForMultiProfile(); | |
| 237 ash::SessionStateDelegate::MultiProfileAddUserError add_user_error; | |
| 238 | |
| 239 EXPECT_TRUE( | |
| 240 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 241 const std::string user_email(kUser); | |
| 242 user_manager()->LoginUser(user_email); | |
| 243 while (session_state_delegate()->NumberOfLoggedInUsers() < | |
| 244 session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) { | |
| 245 UserAddedToSession("bb@b.b"); | |
| 246 } | |
| 247 EXPECT_FALSE( | |
| 248 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 249 EXPECT_EQ(ash::SessionStateDelegate:: | |
| 250 MULTIPROFILE_ADD_USER_ERROR_MAXIMUM_OF_USERS_REACHED, | |
| 251 add_user_error); | |
| 252 } | |
| 253 | |
| 254 // Make sure adding users to multiprofiles disabled by logging all possible | |
|
James Cook
2014/09/23 16:02:12
nit: "logging" -> "logging in"
Roman Sorokin (ftl)
2014/09/24 08:30:47
Done.
| |
| 255 // users. | |
| 256 TEST_F(SessionStateDelegateChromeOSTest, | |
| 257 AddUserToMultiprofileDisallowedByAllUsersLogged) { | |
| 258 InitForMultiProfile(); | |
| 259 ash::SessionStateDelegate::MultiProfileAddUserError add_user_error; | |
| 260 | |
| 261 EXPECT_TRUE( | |
| 262 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 263 const std::string user_email(kUser); | |
| 264 user_manager()->LoginUser(user_email); | |
| 265 UserAddedToSession("bb@b.b"); | |
| 266 EXPECT_FALSE( | |
| 267 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 268 EXPECT_EQ(ash::SessionStateDelegate::MULTIPROFILE_ADD_USER_ERROR_OUT_OF_USERS, | |
| 269 add_user_error); | |
| 270 } | |
| 271 | |
| 272 // Make sure adding users to multiprofiles disabled by primary user policy. | |
| 273 TEST_F(SessionStateDelegateChromeOSTest, | |
| 274 AddUserToMultiprofileDisallowedByPrimaryUserPolicy) { | |
| 275 InitForMultiProfile(); | |
| 276 ash::SessionStateDelegate::MultiProfileAddUserError add_user_error; | |
| 277 | |
| 278 EXPECT_TRUE( | |
| 279 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 280 const std::string user_email(kUser); | |
| 281 user_manager()->LoginUser(user_email); | |
| 282 user_profile_->GetPrefs()->SetString( | |
| 283 prefs::kMultiProfileUserBehavior, | |
| 284 chromeos::MultiProfileUserController::kBehaviorNotAllowed); | |
| 285 user_manager()->AddUser("bb@b.b"); | |
| 286 EXPECT_FALSE( | |
| 287 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | |
| 288 EXPECT_EQ(ash::SessionStateDelegate:: | |
| 289 MULTIPROFILE_ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, | |
| 290 add_user_error); | |
| 291 } | |
|
James Cook
2014/09/23 16:02:12
Nice test suite!
Roman Sorokin (ftl)
2014/09/24 08:30:47
Acknowledged.
| |
| 292 | |
| 232 } // namespace chromeos | 293 } // namespace chromeos |
| OLD | NEW |