chromium/components/enterprise/data_controls/core/browser/data_controls_policy_handler_unittest.cc

// Copyright 2023 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/enterprise/data_controls/core/browser/data_controls_policy_handler.h"

#include <memory>
#include <optional>

#include "base/json/json_reader.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/prefs/pref_value_map.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace data_controls {

namespace {

constexpr char kTestPref[] =;

constexpr char kPolicyName[] =;

// Schema copied from out/Default/gen/chrome/app/policy/policy_templates.json
constexpr char kSchema[] =;

constexpr char kValidPolicy[] =;

// Only the first entry is valid, the second one is not a dict, the third one
// has an invalid condition and the fourth one has an unsupported restriction.
constexpr char kPartiallyValidPolicy[] =;

constexpr policy::PolicySource kCloudSources[] =;

constexpr policy::PolicySource kNonCloudSources[] =;

constexpr char kInvalidPolicy[] =;

constexpr std::pair<const char*, const char16_t*> kInvalidTestCases[] =;

class DataControlsPolicyHandlerTest : public testing::Test {};

// Tests polices with a valid schema, but invalid key usages.
class DataControlsPolicyHandlerInvalidKeysTest
    : public testing::WithParamInterface<
          std::pair<const char*, const char16_t*>>,
      public DataControlsPolicyHandlerTest {};

INSTANTIATE_TEST_SUITE_P();

}  // namespace

TEST_F(DataControlsPolicyHandlerTest, AllowsCloudSources) {}

TEST_F(DataControlsPolicyHandlerTest, BlocksNonCloudSources) {}

TEST_F(DataControlsPolicyHandlerTest, WarnInvalidSchema) {}

TEST_F(DataControlsPolicyHandlerTest, AllowsPartiallyValidRules) {}

TEST_P(DataControlsPolicyHandlerInvalidKeysTest, Test) {}

}  // namespace data_controls