#include "components/policy/core/common/policy_service_impl.h"
#include <memory>
#include <utility>
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/common/external_data_fetcher.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/mock_policy_service.h"
#include "components/policy/core/common/policy_migrator.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/buildflags/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
AnyNumber;
Invoke;
IsEmpty;
Mock;
Return;
namespace policy {
namespace {
const char kExtension[] = …;
const char kSameLevelPolicy[] = …;
const char kDiffLevelPolicy[] = …;
const std::string kUrl1 = …;
const std::string kUrl2 = …;
const std::string kUrl3 = …;
#if !BUILDFLAG(IS_IOS)
const std::string kUrl4 = …;
#endif
const std::string kAffiliationId1 = …;
const std::string kAffiliationId2 = …;
MATCHER_P(PolicyEquals, expected, "") { … }
MATCHER_P(ValueEquals, expected, "") { … }
void AddTestPolicies(PolicyBundle* bundle,
const char* value,
PolicyLevel level,
PolicyScope scope) { … }
class ChangePolicyObserver : public PolicyService::Observer { … };
class MockPolicyMigrator : public PolicyMigrator { … };
}
class PolicyServiceTest : public testing::Test { … };
TEST_F(PolicyServiceTest, LoadsPoliciesBeforeProvidersRefresh) { … }
TEST_F(PolicyServiceTest, NotifyObservers) { … }
TEST_F(PolicyServiceTest, NotifyObserversInMultipleNamespaces) { … }
TEST_F(PolicyServiceTest, ObserverChangesPolicy) { … }
TEST_F(PolicyServiceTest, HasProvider) { … }
TEST_F(PolicyServiceTest, NotifyProviderUpdateObserver) { … }
TEST_F(PolicyServiceTest, Priorities) { … }
TEST_F(PolicyServiceTest, PolicyChangeRegistrar) { … }
TEST_F(PolicyServiceTest, RefreshPolicies) { … }
TEST_F(PolicyServiceTest, NamespaceMerge) { … }
TEST_F(PolicyServiceTest, IsInitializationComplete) { … }
DomainParameters;
ObserverTestParameters;
class PolicyServiceTestForObservers
: public testing::Test,
public testing::WithParamInterface<ObserverTestParameters> { … };
TEST_P(PolicyServiceTestForObservers, MaybeNotifyPolicyDomainStatusChange) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(PolicyServiceTest, IsInitializationCompleteMightDestroyThis) { … }
TEST_F(PolicyServiceTest, InitializationThrottled) { … }
TEST_F(PolicyServiceTest, InitializationThrottledProvidersAlreadyInitialized) { … }
TEST_F(PolicyServiceTest, IsFirstPolicyLoadComplete) { … }
#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(PolicyServiceTest, DictionaryPoliciesMerging) { … }
TEST_F(PolicyServiceTest, DictionaryPoliciesMerging_InvalidType) { … }
TEST_F(PolicyServiceTest, DictionaryPoliciesMerging_PrecedenceChange) { … }
#endif
TEST_F(PolicyServiceTest, ListsPoliciesMerging) { … }
TEST_F(PolicyServiceTest, ListsPoliciesMerging_InvalidType) { … }
#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_IOS)
TEST_F(PolicyServiceTest, ListsPoliciesMerging_CloudMetapolicy) { … }
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
TEST_F(PolicyServiceTest, GroupPoliciesMergingDisabledForCloudUsers) { … }
TEST_F(PolicyServiceTest, GroupPoliciesMergingEnabled) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_IOS)
TEST_F(PolicyServiceTest, CloudUserListPolicyMerge_Successful) { … }
TEST_F(PolicyServiceTest, CloudUserListPolicyMerge_Unaffiliated) { … }
TEST_F(PolicyServiceTest, CloudUserListPolicyMerge_FalsePolicy) { … }
TEST_F(PolicyServiceTest, PlatformUserListPolicyMerge_Affiliated) { … }
TEST_F(PolicyServiceTest, PlatformUserListPolicyMerge_Unaffiliated) { … }
TEST_F(PolicyServiceTest, IgnoreUserCloudPrecedencePolicies) { … }
TEST_F(PolicyServiceTest, PolicyMessages) { … }
#endif
struct PolicyServiceInitTimeTestParams { … } kInitTimeTestParams[] = …;
class PolicyServiceInitTimeTest
: public testing::TestWithParam<PolicyServiceInitTimeTestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(PolicyServiceInitTimeTest, HistogramsRecorded) { … }
class PolicyServiceUserAffiliationMetricsTest
: public PolicyServiceTest,
public testing::WithParamInterface<
testing::tuple<std::string, std::string>> { … };
TEST_P(PolicyServiceUserAffiliationMetricsTest, Histograms) { … }
INSTANTIATE_TEST_SUITE_P(…);
}