Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: tools/json_schema_compiler/test/crossref_unittest.cc

Issue 9456007: Add wider support to json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/test/crossref_unittest.cc
diff --git a/tools/json_schema_compiler/test/crossref_unittest.cc b/tools/json_schema_compiler/test/crossref_unittest.cc
index ab39f39ed34451862edfcb6f8564d53488d34741..cf7189e55c200962ed5aeb078991c7f8ca3a3201 100644
--- a/tools/json_schema_compiler/test/crossref_unittest.cc
+++ b/tools/json_schema_compiler/test/crossref_unittest.cc
@@ -22,10 +22,20 @@ static scoped_ptr<DictionaryValue> CreateTestTypeDictionary() {
} // namespace
+TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) {
+ scoped_ptr<CrossrefType> crossref_type(new CrossrefType());
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+ value->Set("testType", CreateTestTypeDictionary().release());
+ EXPECT_TRUE(CrossrefType::Populate(*value, crossref_type.get()));
+ EXPECT_TRUE(crossref_type->test_type.get());
+ EXPECT_TRUE(CreateTestTypeDictionary()->Equals(
+ crossref_type->test_type->ToValue().get()));
+ EXPECT_TRUE(value->Equals(crossref_type->ToValue().get()));
+}
+
TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamCreate) {
scoped_ptr<ListValue> params_value(new ListValue());
- scoped_ptr<DictionaryValue> test_type_value = CreateTestTypeDictionary();
- params_value->Append(test_type_value.release());
+ params_value->Append(CreateTestTypeDictionary().release());
scoped_ptr<TestTypeOptionalParam::Params> params(
TestTypeOptionalParam::Params::Create(*params_value));
EXPECT_TRUE(params.get());
@@ -53,3 +63,50 @@ TEST(JsonSchemaCompilerCrossrefTest, GetTestType) {
scoped_ptr<Value> result(GetTestType::Result::Create(*test_type));
EXPECT_TRUE(value->Equals(result.get()));
}
+
+TEST(JsonSchemaCompilerCrossrefTest, TestTypeInObjectParamsCreate) {
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("testType", CreateTestTypeDictionary().release());
+ param_object_value->Set("boolean", Value::CreateBooleanValue(true));
+ params_value->Append(param_object_value.release());
+ scoped_ptr<TestTypeInObject::Params> params(
+ TestTypeInObject::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_TRUE(params->param_object.test_type.get());
+ EXPECT_TRUE(params->param_object.boolean);
+ EXPECT_TRUE(CreateTestTypeDictionary()->Equals(
+ params->param_object.test_type->ToValue().get()));
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("boolean", Value::CreateBooleanValue(true));
+ params_value->Append(param_object_value.release());
+ scoped_ptr<TestTypeInObject::Params> params(
+ TestTypeInObject::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_FALSE(params->param_object.test_type.get());
+ EXPECT_TRUE(params->param_object.boolean);
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("testType", Value::CreateStringValue("invalid"));
+ param_object_value->Set("boolean", Value::CreateBooleanValue(true));
+ params_value->Append(param_object_value.release());
+ scoped_ptr<TestTypeInObject::Params> params(
+ TestTypeInObject::Params::Create(*params_value));
+ EXPECT_FALSE(params.get());
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("testType", CreateTestTypeDictionary().release());
+ params_value->Append(param_object_value.release());
+ scoped_ptr<TestTypeInObject::Params> params(
+ TestTypeInObject::Params::Create(*params_value));
+ EXPECT_FALSE(params.get());
+ }
+}
« no previous file with comments | « tools/json_schema_compiler/test/crossref.json ('k') | tools/json_schema_compiler/test/json_schema_compiler_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698