| Index: tools/json_schema_compiler/test/additional_properties_unittest.cc
|
| diff --git a/tools/json_schema_compiler/test/additional_properties_unittest.cc b/tools/json_schema_compiler/test/additional_properties_unittest.cc
|
| index ef0ab296eec650c9b29211f50170745b67f18cbf..02676310070ce1fc3a53c4c1e2707a6fbb6ceb35 100644
|
| --- a/tools/json_schema_compiler/test/additional_properties_unittest.cc
|
| +++ b/tools/json_schema_compiler/test/additional_properties_unittest.cc
|
| @@ -4,61 +4,58 @@
|
|
|
| #include "tools/json_schema_compiler/test/additional_properties.h"
|
|
|
| +#include "chrome/common/extensions/value_builder.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using namespace test::api::additional_properties;
|
| +using namespace extensions;
|
|
|
| TEST(JsonSchemaCompilerAdditionalPropertiesTest,
|
| AdditionalPropertiesTypePopulate) {
|
| {
|
| - scoped_ptr<ListValue> list_value(new ListValue());
|
| - list_value->Append(Value::CreateStringValue("asdf"));
|
| - list_value->Append(Value::CreateIntegerValue(4));
|
| - scoped_ptr<DictionaryValue> type_value(new DictionaryValue());
|
| - type_value->SetString("string", "value");
|
| - type_value->SetInteger("other", 9);
|
| - type_value->Set("another", list_value.release());
|
| - scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType());
|
| - EXPECT_TRUE(AdditionalPropertiesType::Populate(*type_value, type.get()));
|
| - EXPECT_EQ("value", type->string);
|
| + scoped_ptr<DictionaryValue> type_value(DictionaryBuilder()
|
| + .Set("string", "value")
|
| + .Set("other", 9)
|
| + .Set("another", ListBuilder().Append("asdf").Append(4))
|
| + .Build());
|
| + AdditionalPropertiesType type;
|
| + EXPECT_TRUE(AdditionalPropertiesType::Populate(*type_value, &type));
|
| + EXPECT_EQ("value", type.string);
|
| EXPECT_TRUE(type_value->Remove("string", NULL));
|
| - EXPECT_TRUE(type->additional_properties.Equals(type_value.get()));
|
| + EXPECT_TRUE(type.additional_properties.Equals(type_value.get()));
|
| }
|
| {
|
| - scoped_ptr<DictionaryValue> type_value(new DictionaryValue());
|
| - type_value->SetInteger("string", 3);
|
| - scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType());
|
| - EXPECT_FALSE(AdditionalPropertiesType::Populate(*type_value, type.get()));
|
| + scoped_ptr<DictionaryValue> type_value(
|
| + DictionaryBuilder().Set("string", 3).Build());
|
| + AdditionalPropertiesType type;
|
| + EXPECT_FALSE(AdditionalPropertiesType::Populate(*type_value, &type));
|
| }
|
| }
|
|
|
| TEST(JsonSchemaCompilerAdditionalPropertiesTest,
|
| AdditionalPropertiesParamsCreate) {
|
| - scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
|
| - param_object_value->SetString("str", "a");
|
| - param_object_value->SetInteger("num", 1);
|
| - scoped_ptr<ListValue> params_value(new ListValue());
|
| - params_value->Append(param_object_value->DeepCopy());
|
| + scoped_ptr<ListValue> params_value(ListBuilder().Append(
|
| + DictionaryBuilder().Set("str", "a").Set("num", 1)).Build());
|
| + DictionaryValue* object_value = NULL;
|
| + ASSERT_TRUE(params_value->GetDictionary(0, &object_value));
|
| +
|
| scoped_ptr<AdditionalProperties::Params> params(
|
| AdditionalProperties::Params::Create(*params_value));
|
| EXPECT_TRUE(params.get());
|
| - EXPECT_TRUE(params->param_object.additional_properties.Equals(
|
| - param_object_value.get()));
|
| + EXPECT_TRUE(params->param_object.additional_properties.Equals(object_value));
|
| }
|
|
|
| TEST(JsonSchemaCompilerAdditionalPropertiesTest,
|
| ReturnAdditionalPropertiesResultCreate) {
|
| - scoped_ptr<DictionaryValue> result_object_value(new DictionaryValue());
|
| - result_object_value->SetString("key", "value");
|
| - scoped_ptr<ReturnAdditionalProperties::Result::ResultObject> result_object(
|
| - new ReturnAdditionalProperties::Result::ResultObject());
|
| - result_object->integer = 5;
|
| - result_object->additional_properties.MergeDictionary(
|
| - result_object_value.get());
|
| - scoped_ptr<Value> result(
|
| - ReturnAdditionalProperties::Result::Create(*result_object));
|
| + scoped_ptr<DictionaryValue> additional(
|
| + DictionaryBuilder().Set("key", "value").Build());
|
| + ReturnAdditionalProperties::Result::ResultObject result_object;
|
| + result_object.integer = 5;
|
| + result_object.additional_properties.MergeDictionary(additional.get());
|
| + scoped_ptr<ListValue> results(
|
| + ReturnAdditionalProperties::Result::Create(result_object));
|
| DictionaryValue* result_dict = NULL;
|
| - EXPECT_TRUE(result->GetAsDictionary(&result_dict));
|
| + ASSERT_TRUE(results->GetDictionary(0, &result_dict));
|
|
|
| Value* int_temp_value_out = NULL;
|
| int int_temp = 0;
|
| @@ -67,5 +64,5 @@ TEST(JsonSchemaCompilerAdditionalPropertiesTest,
|
| EXPECT_TRUE(int_temp_value->GetAsInteger(&int_temp));
|
| EXPECT_EQ(5, int_temp);
|
|
|
| - EXPECT_TRUE(result_dict->Equals(result_object_value.get()));
|
| + EXPECT_TRUE(result_dict->Equals(additional.get()));
|
| }
|
|
|