OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/arc/arc_util.h" | 5 #include "components/arc/arc_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/shared/app_types.h" | 10 #include "ash/shared/app_types.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 TEST_F(ArcUtilTest, IsArcAllowedForUser) { | 205 TEST_F(ArcUtilTest, IsArcAllowedForUser) { |
206 user_manager::FakeUserManager fake_user_manager; | 206 user_manager::FakeUserManager fake_user_manager; |
207 ScopedUserManager scoped_user_manager(&fake_user_manager); | 207 ScopedUserManager scoped_user_manager(&fake_user_manager); |
208 | 208 |
209 struct { | 209 struct { |
210 user_manager::UserType user_type; | 210 user_manager::UserType user_type; |
211 bool expected_allowed; | 211 bool expected_allowed; |
212 } const kTestCases[] = { | 212 } const kTestCases[] = { |
213 {user_manager::USER_TYPE_REGULAR, true}, | 213 {user_manager::USER_TYPE_REGULAR, true}, |
214 {user_manager::USER_TYPE_GUEST, false}, | 214 {user_manager::USER_TYPE_GUEST, false}, |
215 {user_manager::USER_TYPE_PUBLIC_ACCOUNT, false}, | 215 {user_manager::USER_TYPE_PUBLIC_ACCOUNT, true}, |
216 {user_manager::USER_TYPE_SUPERVISED, false}, | 216 {user_manager::USER_TYPE_SUPERVISED, false}, |
217 {user_manager::USER_TYPE_KIOSK_APP, false}, | 217 {user_manager::USER_TYPE_KIOSK_APP, false}, |
218 {user_manager::USER_TYPE_CHILD, true}, | 218 {user_manager::USER_TYPE_CHILD, true}, |
219 {user_manager::USER_TYPE_ARC_KIOSK_APP, true}, | 219 {user_manager::USER_TYPE_ARC_KIOSK_APP, true}, |
220 {user_manager::USER_TYPE_ACTIVE_DIRECTORY, true}, | 220 {user_manager::USER_TYPE_ACTIVE_DIRECTORY, true}, |
221 }; | 221 }; |
222 for (const auto& test_case : kTestCases) { | 222 for (const auto& test_case : kTestCases) { |
223 const FakeUser user(test_case.user_type); | 223 const FakeUser user(test_case.user_type); |
224 EXPECT_EQ(test_case.expected_allowed, IsArcAllowedForUser(&user)) | 224 EXPECT_EQ(test_case.expected_allowed, IsArcAllowedForUser(&user)) |
225 << "User type=" << test_case.user_type; | 225 << "User type=" << test_case.user_type; |
226 } | 226 } |
227 | 227 |
228 // An ephemeral user is a logged in user but unknown to UserManager when | 228 // An ephemeral user is a logged in user but unknown to UserManager when |
229 // ephemeral policy is set. | 229 // ephemeral policy is set. |
230 fake_user_manager.SetEphemeralUsersEnabled(true); | 230 fake_user_manager.SetEphemeralUsersEnabled(true); |
231 fake_user_manager.UserLoggedIn(AccountId::FromUserEmail("test@test.com"), | 231 fake_user_manager.UserLoggedIn(AccountId::FromUserEmail("test@test.com"), |
232 "test@test.com-hash", false); | 232 "test@test.com-hash", false); |
233 const user_manager::User* ephemeral_user = fake_user_manager.GetActiveUser(); | 233 const user_manager::User* ephemeral_user = fake_user_manager.GetActiveUser(); |
234 ASSERT_TRUE(ephemeral_user); | 234 ASSERT_TRUE(ephemeral_user); |
235 ASSERT_TRUE(fake_user_manager.IsUserCryptohomeDataEphemeral( | 235 ASSERT_TRUE(fake_user_manager.IsUserCryptohomeDataEphemeral( |
236 ephemeral_user->GetAccountId())); | 236 ephemeral_user->GetAccountId())); |
237 | 237 |
238 // Ephemeral user is not allowed for ARC. | 238 // Ephemeral user is also allowed for ARC. |
239 EXPECT_FALSE(IsArcAllowedForUser(ephemeral_user)); | 239 EXPECT_TRUE(IsArcAllowedForUser(ephemeral_user)); |
240 } | 240 } |
241 | 241 |
242 } // namespace | 242 } // namespace |
243 } // namespace arc | 243 } // namespace arc |
OLD | NEW |