// 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 "tools/json_schema_compiler/test/generated_schemas.h"

#include <optional>

#include "base/json/json_reader.h"
#include "extensions/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"

static_assert(BUILDFLAG(ENABLE_EXTENSIONS_CORE));

namespace {

// Ensure 'manifest_keys' are excluded from the generated schema.
TEST(GeneratedSchemaTest, ManifestKeysExcluded) {
  using GeneratedSchemas = ::test::api::GeneratedSchemas;
  constexpr char kApiName[] = "simple_api";

  ASSERT_TRUE(GeneratedSchemas::IsGenerated(kApiName));

  // The schema string must be in json format.
  std::optional<base::DictValue> json_schema = base::JSONReader::ReadDict(
      GeneratedSchemas::Get(kApiName), base::JSON_PARSE_CHROMIUM_EXTENSIONS);
  ASSERT_TRUE(json_schema);
  EXPECT_FALSE(json_schema->Find("manifest_keys"));
}

}  // namespace
