#include "chrome/browser/extensions/profile_util.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_service_user_test_base.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/testing_profile.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/account_id/account_id.h"
#include "components/user_manager/user.h"
#endif
ProfileCanUseNonComponentExtensions;
namespace extensions {
class ProfileUtilUnitTest : public ExtensionServiceUserTestBase { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ProfileUtilUnitTest, ProfileCanUseNonComponentExtensions_RegularUser) {
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(
GetFakeUserManager()->AddUser(account_id_), account_id_));
EXPECT_TRUE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
TEST_F(ProfileUtilUnitTest, ProfileCanUseNonComponentExtensions_ChildUser) {
const user_manager::User* user =
GetFakeUserManager()->AddChildUser(account_id_);
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(user, account_id_));
EXPECT_TRUE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
TEST_F(ProfileUtilUnitTest, ProfileCannotUseNonComponentExtensions_GuestUser) {
ASSERT_NO_FATAL_FAILURE(MaybeSetUpTestUser(true));
EXPECT_FALSE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
TEST_F(ProfileUtilUnitTest,
DISABLED_ProfileCannotUseNonComponentExtensions_NotAUserProfile) {}
TEST_F(ProfileUtilUnitTest,
ProfileCannotUseNonComponentExtensions_KioskAppUser) {
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(
GetFakeUserManager()->AddKioskAppUser(account_id_), account_id_));
EXPECT_FALSE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
TEST_F(ProfileUtilUnitTest,
ProfileCannotUseNonComponentExtensions_WebKioskAppUser) {
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(
GetFakeUserManager()->AddWebKioskAppUser(account_id_), account_id_));
EXPECT_FALSE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
TEST_F(ProfileUtilUnitTest, ProfileCannotUseNonComponentExtensions_PublicUser) {
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(
GetFakeUserManager()->AddPublicAccountUser(account_id_), account_id_));
EXPECT_FALSE(ProfileCanUseNonComponentExtensions(testing_profile()));
}
#else
TEST_F(ProfileUtilUnitTest,
ProfileCanUseNonComponentExtensions_RegularProfile) { … }
TEST_F(ProfileUtilUnitTest,
Browser_ProfileCannotUseNonComponentExtensions_NoProfile) { … }
TEST_F(ProfileUtilUnitTest,
ProfileCannotUseNonComponentExtensions_GuestProfile) { … }
TEST_F(ProfileUtilUnitTest,
Browser_ProfileCannotUseNonComponentExtensions_IncognitoProfile) { … }
TEST_F(ProfileUtilUnitTest,
Browser_ProfileCannotUseNonComponentExtensions_OTRProfile) { … }
#endif
}