chromium/components/policy/core/browser/policy_pref_mapping_test.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/policy/core/browser/policy_pref_mapping_test.h"

#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/hash/hash.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "printing/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace policy {

namespace {

enum class PrefLocation {};

PrefLocation GetPrefLocation(const base::Value::Dict& settings) {}

PrefService* GetPrefServiceForLocation(PrefLocation location,
                                       PrefService* local_state,
                                       PrefService* user_prefs,
                                       PrefService* signin_profile_prefs) {}

void CheckPrefHasValue(const PrefService::Preference* pref,
                       const base::Value* expected_value) {}

void CheckPrefHasDefaultValue(const PrefService::Preference* pref,
                              const base::Value* expected_value = nullptr) {}

void CheckPrefHasRecommendedValue(const PrefService::Preference* pref,
                                  const base::Value* expected_value) {}

void CheckPrefHasMandatoryValue(const PrefService::Preference* pref,
                                const base::Value* expected_value) {}

// Contains the testing details for a single pref affected by one or multiple
// policies. Each entry in `prefs` from
// components/policy/test/data/pref_mapping/[PolicyName].json is represented by
// one `PrefTestCase`.
class PrefTestCase {};

// Contains the testing details for a single policy to pref mapping. Each entry
// under `policy_pref_mapping_tests` from
// components/policy/test/data/pref_mapping/[PolicyName].json is represented by
// one `PolicyPrefMappingTest`.
class PolicyPrefMappingTest {};

class SimplePolicyPrefMappingTest {};

// Populates buildflags as strings that policy pref mapping test cases
// can depend on and implements a check if such a test case should run according
// to the buildflags.
bool CheckRequiredBuildFlagsSupported(const PolicyPrefMappingTest* test) {}

// Each file like components/policy/test/data/pref_mapping/[PolicyName].json
// contains one or more `PolicyTestCase` with each of them defining the platform
// they run on. Typically, if a policy has different mappings per platform, it
// would have multiple `PolicyTestCase`s. If the mapping is the same across
// platforms, it would only have one `PolicyTestCase`.
class PolicyTestCase {};

// Parses all policy test cases in components/policy/test/data/pref_mapping/ and
// makes them available in a map.
class PolicyTestCases {};

struct PolicySettings {};

PolicySettings GetPolicySettings(const std::string& policy,
                                 const base::Value::Dict& policies_settings) {}

void SetProviderPolicy(MockConfigurationPolicyProvider* provider,
                       const base::Value::Dict& policies,
                       const base::Value::Dict& policies_settings,
                       PolicyLevel level) {}

std::optional<base::flat_set<std::string>> GetTestFilter() {}

}  // namespace

void VerifyAllPoliciesHaveATestCase(const base::FilePath& test_case_dir) {}

// Verifies that policies make their corresponding preferences become managed,
// and that the user can't override that setting.
void VerifyPolicyToPrefMappings(const base::FilePath& test_case_dir,
                                PrefService* local_state,
                                PrefService* user_prefs,
                                PrefService* signin_profile_prefs,
                                MockConfigurationPolicyProvider* provider,
                                PrefMappingChunkInfo* chunk_info) {}

}  // namespace policy