Chromium Code Reviews| Index: tools/json_schema_compiler/test/crossref_test.cc |
| diff --git a/tools/json_schema_compiler/test/crossref_test.cc b/tools/json_schema_compiler/test/crossref_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c8d2e0951c50f16a2a8d21e07872e5667640b290 |
| --- /dev/null |
| +++ b/tools/json_schema_compiler/test/crossref_test.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 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/simple_api.h" |
| +#include "tools/json_schema_compiler/test/crossref.h" |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +using namespace test::api::crossref; |
| + |
| +namespace { |
| + |
| +static DictionaryValue* CreateTestTypeDictionary() { |
| + scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| + value->SetWithoutPathExpansion("number", Value::CreateDoubleValue(1.1)); |
| + value->SetWithoutPathExpansion("integer", Value::CreateIntegerValue(4)); |
| + value->SetWithoutPathExpansion("string", Value::CreateStringValue("bling")); |
| + value->SetWithoutPathExpansion("boolean", Value::CreateBooleanValue(true)); |
| + return value.release(); |
|
not at google - send to devlin
2012/02/19 23:19:59
.Pass()
calamity
2012/02/20 05:03:37
Done.
|
| +} |
| + |
| +} // namespace |
| + |
| +TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamCreate) { |
| + scoped_ptr<ListValue> params_value(new ListValue()); |
| + DictionaryValue* test_type_value = CreateTestTypeDictionary(); |
| + params_value->Append(test_type_value); |
| + scoped_ptr<TestTypeOptionalParam::Params> params( |
| + TestTypeOptionalParam::Params::Create(*params_value)); |
| + EXPECT_TRUE(params.get()); |
| + EXPECT_TRUE(params->test_type.get()); |
| + EXPECT_TRUE(test_type_value->Equals(params->test_type->ToValue().get())); |
| +} |
| + |
| +TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamFail) { |
| + scoped_ptr<ListValue> params_value(new ListValue()); |
| + DictionaryValue* test_type_value = CreateTestTypeDictionary(); |
| + test_type_value->RemoveWithoutPathExpansion("number", NULL); |
| + params_value->Append(test_type_value); |
| + scoped_ptr<TestTypeOptionalParam::Params> params( |
| + TestTypeOptionalParam::Params::Create(*params_value)); |
| + EXPECT_FALSE(params.get()); |
| +} |
| + |
| +TEST(JsonSchemaCompilerCrossrefTest, GetTestType) { |
| + scoped_ptr<DictionaryValue> value(CreateTestTypeDictionary()); |
| + scoped_ptr<test::api::simple_api::TestType> test_type( |
| + new test::api::simple_api::TestType()); |
| + EXPECT_TRUE( |
| + test::api::simple_api::TestType::Populate(*value, test_type.get())); |
| + scoped_ptr<Value> result(GetTestType::Result::Create(*test_type)); |
| + EXPECT_TRUE(value->Equals(result.get())); |
| +} |
| + |
| + |
|
not at google - send to devlin
2012/02/19 23:19:59
unnecessary blank lines
calamity
2012/02/20 05:03:37
Done.
|