chromium/components/policy/core/common/policy_map_unittest.cc

// Copyright 2013 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/common/policy_map.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/common/external_data_manager.h"
#include "components/policy/core/common/features.h"
#include "components/policy/core/common/policy_details.h"
#include "components/policy/core/common/policy_merger.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/strings/grit/components_strings.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace policy {

namespace {

// Dummy policy names.
const char kTestPolicyName1[] =;
const char kTestPolicyName2[] =;
const char kTestPolicyName3[] =;
const char kTestPolicyName4[] =;
const char kTestPolicyName5[] =;
const char kTestPolicyName6[] =;
const char kTestPolicyName7[] =;
const char kTestPolicyName8[] =;

// Dummy error message.
const char16_t kTestError[] =;

const PolicyDetails kExternalDetails_ =;
const PolicyDetails kNonExternalDetails_ =;
#if !BUILDFLAG(IS_CHROMEOS)
const PolicyDetails kUserCloudDetails =;
#endif

// Utility functions for the tests.
void SetPolicy(PolicyMap* map, const char* name, base::Value value) {}

void SetPolicy(PolicyMap* map,
               const char* name,
               std::unique_ptr<ExternalDataFetcher> external_data_fetcher) {}

template <class T>
base::Value::List GetList(const std::vector<T>& entry) {}

}  // namespace

class PolicyMapTestBase {};

std::unique_ptr<ExternalDataFetcher>
PolicyMapTestBase::CreateExternalDataFetcher(const std::string& policy) const {}

class PolicyMapTest : public PolicyMapTestBase, public testing::Test {};

TEST_F(PolicyMapTest, SetAndGet) {}

TEST_F(PolicyMapTest, AddMessage_Error) {}

TEST_F(PolicyMapTest, AddMessage_Warning) {}

TEST_F(PolicyMapTest, AddMessage_Info) {}

TEST_F(PolicyMapTest, Equals) {}

TEST_F(PolicyMapTest, Swap) {}

#if !BUILDFLAG(IS_CHROMEOS)
// Policy precedence changes are not supported on Chrome OS.
TEST_F(PolicyMapTest, MergeFrom_CloudMetapolicies) {}
#endif  // BUILDFLAG(IS_CHROMEOS)

TEST_F(PolicyMapTest, MergeValuesList) {}

TEST_F(PolicyMapTest, MergeValuesDictionary) {}

TEST_F(PolicyMapTest, MergeValuesGroup) {}

TEST_F(PolicyMapTest, LoadFromSetsLevelScopeAndSource) {}

TEST_F(PolicyMapTest, LoadFromCheckForExternalPolicy) {}

bool IsMandatory(PolicyMap::const_reference entry) {}

TEST_F(PolicyMapTest, CloneIf) {}

TEST_F(PolicyMapTest, EntryAddConflict) {}

TEST_F(PolicyMapTest, BlockedEntry) {}

TEST_F(PolicyMapTest, InvalidEntry) {}

TEST_F(PolicyMapTest, Affiliation) {}

#if !BUILDFLAG(IS_CHROMEOS)
class PolicyMapMergeTest
    : public PolicyMapTestBase,
      public testing::TestWithParam<
          std::tuple</*cloud_policy_overrides_platform_policy=*/bool,
                     /*cloud_user_policy_overrides_cloud_machine_policy=*/bool,
                     /*is_user_affiliated=*/bool,
                     /*metapolicies_are_incoming=*/bool>> {};

TEST_P(PolicyMapMergeTest, MergeFrom) {}

TEST_P(PolicyMapMergeTest, MergeFrom_Metapolicies) {}

INSTANTIATE_TEST_SUITE_P();

class PolicyMapPriorityTest
    : public testing::TestWithParam<
          std::tuple</*cloud_policy_overrides_platform_policy=*/bool,
                     /*cloud_user_policy_overrides_cloud_machine_policy=*/bool,
                     /*is_user_affiliated=*/bool>> {};

TEST_P(PolicyMapPriorityTest, PriorityCheck) {}

TEST_P(PolicyMapPriorityTest, SingleProfilePolicy) {}

TEST_P(PolicyMapPriorityTest, SingleProfilePolicyWithMissingDetails) {}

INSTANTIATE_TEST_SUITE_P();
#endif  // !BUILDFLAG(IS_CHROMEOS)

}  // namespace policy