#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_extensions_delegate_impl.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/supervised_user/parent_permission_dialog_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/mixin_based_in_process_browser_test.h"
#include "chrome/test/supervised_user/supervision_mixin.h"
#include "components/supervised_user/core/browser/supervised_user_preferences.h"
#include "components/supervised_user/core/browser/supervised_user_utils.h"
#include "components/supervised_user/core/common/features.h"
#include "components/supervised_user/core/common/pref_names.h"
#include "components/supervised_user/core/common/supervised_user_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_launcher.h"
#include "content/public/test/web_contents_tester.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/supervised_user_extensions_delegate.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/supervised_user/chromeos/parent_access_extension_approvals_manager.h"
#include "chromeos/crosapi/mojom/parent_access.mojom.h"
#endif
namespace {
constexpr char kGoodCrxId[] = …;
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
constexpr char kSimpleWithIconCrxId[] = …;
#endif
}
namespace extensions {
enum class ExtensionsParentalControlState : int { … };
enum class ExtensionManagementSwitch : int { … };
std::string CreateTestSuffixFromParam(const auto& info) {
return std::string(std::get<0>(info.param) ==
ExtensionsParentalControlState::kEnabled
? "WithParentalControlsOnExtensions"
: "WithoutParentalControlsOnExtensions") +
std::string(std::get<1>(info.param) ==
ExtensionManagementSwitch::kManagedByExtensions
? "ManagedByExtensions"
: "ManagedByPermissions");
}
SupervisionMixinSigninModeCallback;
class SupervisionExtensionTestBase
: public ExtensionBrowserTest,
public ::testing::WithParamInterface<
std::tuple<ExtensionsParentalControlState,
ExtensionManagementSwitch,
SupervisionMixinSigninModeCallback>> { … };
class SupervisionRemovalExtensionTest : public SupervisionExtensionTestBase { … };
IN_PROC_BROWSER_TEST_P(SupervisionRemovalExtensionTest,
PRE_RemoveCustodianApprovalRequirement) { … }
IN_PROC_BROWSER_TEST_P(SupervisionRemovalExtensionTest,
RemoveCustodianApprovalRequirement) { … }
INSTANTIATE_TEST_SUITE_P(…);
class UserGellerizationExtensionTest : public SupervisionExtensionTestBase { … };
IN_PROC_BROWSER_TEST_P(UserGellerizationExtensionTest,
PRE_UserGellerizationDisablesExistingExtensions) { … }
IN_PROC_BROWSER_TEST_P(UserGellerizationExtensionTest,
UserGellerizationDisablesExistingExtensions) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ParentApprovalHandlingByExtensionSwitchTest
: public SupervisionExtensionTestBase { … };
IN_PROC_BROWSER_TEST_P(
ParentApprovalHandlingByExtensionSwitchTest,
PRE_GrantParentApprovalWhenExtensionSwitchBecomesEnabled) { … }
IN_PROC_BROWSER_TEST_P(ParentApprovalHandlingByExtensionSwitchTest,
GrantParentApprovalWhenExtensionSwitchBecomesEnabled) { … }
IN_PROC_BROWSER_TEST_P(
ParentApprovalHandlingByExtensionSwitchTest,
GrantParentParentApprovalOnInstallationIfExtensionSwitchEnabled) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ParentApprovalRequestTest
: public SupervisionExtensionTestBase,
#if BUILDFLAG(IS_CHROMEOS)
public TestExtensionApprovalsManagerObserver,
#endif
public TestParentPermissionDialogViewObserver { … };
IN_PROC_BROWSER_TEST_P(ParentApprovalRequestTest,
RequestToInstallApprovedExtension) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
class SupervisedUserSkipParentalApprovalModeReleaseTest
: public SupervisionExtensionTestBase { … };
IN_PROC_BROWSER_TEST_P(SupervisedUserSkipParentalApprovalModeReleaseTest,
PRE_OnFeatureReleaseForSupervisedUserWithExtensions) { … }
IN_PROC_BROWSER_TEST_P(SupervisedUserSkipParentalApprovalModeReleaseTest,
OnFeatureReleaseForSupervisedUserWithExtensions) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
}