summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/test
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 05:09:28 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 05:09:28 +0000
commit1bf05bc0b67e63fdc6070e8cf5f0180ecff75061 (patch)
treed661e3bdaa2e078432ac92750dcb02a99d31cd36 /tools/json_schema_compiler/test
parent57c177bc892fa4024664d06db2f5a219424e93f5 (diff)
downloadchromium_src-1bf05bc0b67e63fdc6070e8cf5f0180ecff75061.zip
chromium_src-1bf05bc0b67e63fdc6070e8cf5f0180ecff75061.tar.gz
chromium_src-1bf05bc0b67e63fdc6070e8cf5f0180ecff75061.tar.bz2
Fix a bug with the JSON Schema Compiler where it would stop processing function
parameters after seeing the first optional one. BUG=120569 TEST=no Review URL: http://codereview.chromium.org/9837100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/test')
-rw-r--r--tools/json_schema_compiler/test/simple_api.json21
-rw-r--r--tools/json_schema_compiler/test/simple_api_unittest.cc13
2 files changed, 34 insertions, 0 deletions
diff --git a/tools/json_schema_compiler/test/simple_api.json b/tools/json_schema_compiler/test/simple_api.json
index b107fab..068432d 100644
--- a/tools/json_schema_compiler/test/simple_api.json
+++ b/tools/json_schema_compiler/test/simple_api.json
@@ -66,6 +66,27 @@
]
},
{
+ "name": "optionalBeforeRequired",
+ "type": "function",
+ "description": "Takes an optional parameter followed by a required one.",
+ "parameters": [
+ {
+ "name": "first",
+ "type": "string",
+ "optional": true
+ },
+ {
+ "name": "second",
+ "type": "string"
+ },
+ {
+ "name": "callback",
+ "type": "function",
+ "parameters": []
+ }
+ ]
+ },
+ {
"name": "optionalCallbackParams",
"type": "function",
"description": "Gives back a string. Or not.",
diff --git a/tools/json_schema_compiler/test/simple_api_unittest.cc b/tools/json_schema_compiler/test/simple_api_unittest.cc
index 6cc2832..accf32e 100644
--- a/tools/json_schema_compiler/test/simple_api_unittest.cc
+++ b/tools/json_schema_compiler/test/simple_api_unittest.cc
@@ -94,6 +94,19 @@ TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsWrongType) {
}
}
+TEST(JsonSchemaCompilerSimpleTest, OptionalBeforeRequired) {
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(Value::CreateNullValue());
+ params_value->Append(Value::CreateStringValue("asdf"));
+ scoped_ptr<OptionalBeforeRequired::Params> params(
+ OptionalBeforeRequired::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_FALSE(params->first.get());
+ EXPECT_EQ("asdf", params->second);
+ }
+}
+
TEST(JsonSchemaCompilerSimpleTest, NoParamsResultCreate) {
scoped_ptr<Value> result(OptionalString::Result::Create());
scoped_ptr<Value> expected(Value::CreateNullValue());