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

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: 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..b0941ed7a318e1910655d6c07bec95b862d04962 100644
--- a/tools/json_schema_compiler/test/crossref_unittest.cc
+++ b/tools/json_schema_compiler/test/crossref_unittest.cc
@@ -22,6 +22,18 @@ static scoped_ptr<DictionaryValue> CreateTestTypeDictionary() {
} // namespace
+TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) {
+ scoped_ptr<CrossrefType> crossref_type(new CrossrefType());
+ scoped_ptr<DictionaryValue> test_type_value = CreateTestTypeDictionary();
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+ value->Set("testType", test_type_value.release());
not at google - send to devlin 2012/02/24 03:53:05 inline CreateTestTypeDictionary()?
calamity 2012/02/24 15:10:40 Done.
+ 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();
@@ -53,3 +65,52 @@ 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> test_type_value = CreateTestTypeDictionary();
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("testType", test_type_value.release());
not at google - send to devlin 2012/02/24 03:53:05 ditto (and everywhere else)
calamity 2012/02/24 15:10:40 Done.
+ 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> test_type_value = CreateTestTypeDictionary();
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->Set("testType", test_type_value.release());
+ params_value->Append(param_object_value.release());
+ scoped_ptr<TestTypeInObject::Params> params(
+ TestTypeInObject::Params::Create(*params_value));
+ EXPECT_FALSE(params.get());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698