Commit b4c37d0e authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Commit Bot

JsonSchemaCompiler: Exclude 'manifest_keys' from generated schema strings.

Generated schema strings are primarily used by the renderers to generate
bindings. Exclude 'manifest_keys' since the renderers wouldn't need
these.

BUG=1113513

TEST=Verify that the generated schema strings don't include
'manifest_keys'.

Change-Id: Ibf750b27155b0f851bccb54d80a6093c6ed33458
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369418
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Auto-Submit: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801634}
parent f3af03b9
......@@ -42,6 +42,7 @@ def _RemoveUnneededFields(schema):
_RemoveKey(ret, 'nocompile', bool)
_RemoveKey(ret, 'noinline_doc', bool)
_RemoveKey(ret, 'jsexterns', object)
_RemoveKey(ret, 'manifest_keys', object)
return ret
def _PrefixSchemaWithNamespace(schema):
......
......@@ -9,36 +9,45 @@ import("//tools/json_schema_compiler/json_schema_api.gni")
assert(enable_extensions)
sources_ = [
"additional_properties.json",
"any.json",
"arrays.json",
"callbacks.json",
"choices.json",
"crossref.json",
"enums.json",
"error_generation.json",
"functions_as_parameters.json",
"functions_on_types.json",
"idl_basics.idl",
"idl_object_types.idl",
"idl_other_namespace.idl",
"idl_other_namespace_sub_namespace.idl",
"idl_properties.idl",
"objects.json",
"objects_movable.idl",
"objects_movable_json.json",
"simple_api.json",
]
generated_types("generated_types") {
visibility = [ ":*" ]
sources = [
"additional_properties.json",
"any.json",
"arrays.json",
"callbacks.json",
"choices.json",
"crossref.json",
"enums.json",
"error_generation.json",
"functions_as_parameters.json",
"functions_on_types.json",
"idl_basics.idl",
"idl_object_types.idl",
"idl_other_namespace.idl",
"idl_other_namespace_sub_namespace.idl",
"idl_properties.idl",
"objects.json",
"objects_movable.idl",
"objects_movable_json.json",
"simple_api.json",
]
sources = sources_
root_namespace = "test::api::%(namespace)s"
deps = [ "//extensions/buildflags" ]
}
generated_json_strings("generated_api_json_strings") {
sources = sources_
bundle_name = ""
visibility = [ ":*" ]
root_namespace = "test::api::%(namespace)s"
}
json_features("features_compiler_test") {
feature_type = "APIFeature"
method_name = "CompilerTestAddFeaturesMethod"
......@@ -61,6 +70,7 @@ source_set("unit_tests") {
"error_generation_unittest.cc",
"functions_as_parameters_unittest.cc",
"functions_on_types_unittest.cc",
"generated_schemas_unittest.cc",
"idl_schemas_unittest.cc",
"objects_unittest.cc",
"simple_api_unittest.cc",
......@@ -74,6 +84,7 @@ source_set("unit_tests") {
public_deps = [ ":features_compiler_test" ]
deps = [
":generated_api_json_strings",
":generated_types",
"//base",
"//testing/gmock",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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 "base/json/json_reader.h"
#include "base/optional.h"
#include "testing/gtest/include/gtest/gtest.h"
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.
base::Optional<base::Value> json_schema =
base::JSONReader::Read(GeneratedSchemas::Get(kApiName));
ASSERT_TRUE(json_schema);
ASSERT_TRUE(json_schema->is_dict());
EXPECT_FALSE(json_schema->FindPath("manifest_keys"));
}
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment