Index: tools/json_schema_compiler/test/choices_unittest.cc |
diff --git a/tools/json_schema_compiler/test/choices_unittest.cc b/tools/json_schema_compiler/test/choices_unittest.cc |
index b4e76a15e7c42612671812bf79b29783a63f211a..b8bedf4ec3c5dad3dee07359c8c12285828ff858 100644 |
--- a/tools/json_schema_compiler/test/choices_unittest.cc |
+++ b/tools/json_schema_compiler/test/choices_unittest.cc |
@@ -22,9 +22,8 @@ TEST(JsonSchemaCompilerChoicesTest, TakesIntegersParamsCreate) { |
scoped_ptr<TakesIntegers::Params> params( |
TakesIntegers::Params::Create(*params_value)); |
EXPECT_TRUE(params.get()); |
- EXPECT_EQ(TakesIntegers::Params::NUMS_INTEGER, params->nums_type); |
- EXPECT_FALSE(params->nums_array.get()); |
- EXPECT_EQ(6, *params->nums_integer); |
+ EXPECT_FALSE(params->nums.as_array); |
+ EXPECT_EQ(6, *params->nums.as_integer); |
} |
{ |
scoped_ptr<ListValue> params_value(new ListValue()); |
@@ -34,45 +33,41 @@ TEST(JsonSchemaCompilerChoicesTest, TakesIntegersParamsCreate) { |
params_value->Append(integers.release()); |
scoped_ptr<TakesIntegers::Params> params( |
TakesIntegers::Params::Create(*params_value)); |
- EXPECT_TRUE(params.get()); |
- EXPECT_EQ(TakesIntegers::Params::NUMS_ARRAY, params->nums_type); |
- EXPECT_EQ((size_t) 2, (*params->nums_array).size()); |
- EXPECT_EQ(6, (*params->nums_array)[0]); |
- EXPECT_EQ(8, (*params->nums_array)[1]); |
+ ASSERT_TRUE(params); |
+ ASSERT_TRUE(params->nums.as_array); |
+ EXPECT_EQ((size_t) 2, params->nums.as_array->size()); |
+ EXPECT_EQ(6, params->nums.as_array->at(0)); |
+ EXPECT_EQ(8, params->nums.as_array->at(1)); |
} |
} |
TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreate) { |
{ |
scoped_ptr<DictionaryValue> object_param(new DictionaryValue()); |
- object_param->SetWithoutPathExpansion("strings", |
- Value::CreateStringValue("asdf")); |
+ object_param->SetString("strings", "asdf"); |
scoped_ptr<ListValue> params_value(new ListValue()); |
params_value->Append(object_param.release()); |
scoped_ptr<ObjectWithChoices::Params> params( |
ObjectWithChoices::Params::Create(*params_value)); |
- EXPECT_TRUE(params.get()); |
- EXPECT_EQ(ObjectWithChoices::Params::StringInfo::STRINGS_STRING, |
- params->string_info.strings_type); |
- EXPECT_EQ("asdf", *params->string_info.strings_string); |
+ ASSERT_TRUE(params); |
+ EXPECT_FALSE(params->string_info.strings.as_array); |
+ EXPECT_EQ("asdf", *params->string_info.strings.as_string); |
+ EXPECT_FALSE(params->string_info.integers); |
} |
{ |
scoped_ptr<DictionaryValue> object_param(new DictionaryValue()); |
- object_param->SetWithoutPathExpansion("strings", |
- Value::CreateStringValue("asdf")); |
- object_param->SetWithoutPathExpansion("integers", |
- Value::CreateIntegerValue(6)); |
+ object_param->SetString("strings", "asdf"); |
+ object_param->SetInteger("integers", 6); |
scoped_ptr<ListValue> params_value(new ListValue()); |
params_value->Append(object_param.release()); |
scoped_ptr<ObjectWithChoices::Params> params( |
ObjectWithChoices::Params::Create(*params_value)); |
- EXPECT_TRUE(params.get()); |
- EXPECT_EQ(ObjectWithChoices::Params::StringInfo::STRINGS_STRING, |
- params->string_info.strings_type); |
- EXPECT_EQ("asdf", *params->string_info.strings_string); |
- EXPECT_EQ(ObjectWithChoices::Params::StringInfo::INTEGERS_INTEGER, |
- params->string_info.integers_type); |
- EXPECT_EQ(6, *params->string_info.integers_integer); |
+ ASSERT_TRUE(params); |
+ EXPECT_FALSE(params->string_info.strings.as_array); |
+ EXPECT_EQ("asdf", *params->string_info.strings.as_string); |
+ ASSERT_TRUE(params->string_info.integers); |
+ EXPECT_FALSE(params->string_info.integers->as_array); |
+ EXPECT_EQ(6, *params->string_info.integers->as_integer); |
} |
} |
@@ -127,15 +122,13 @@ TEST(JsonSchemaCompilerChoicesTest, PopulateChoiceType) { |
ChoiceType out; |
ASSERT_TRUE(ChoiceType::Populate(value, &out)); |
- EXPECT_EQ(ChoiceType::INTEGERS_INTEGER, out.integers_type); |
- ASSERT_TRUE(out.integers_integer.get()); |
- EXPECT_FALSE(out.integers_array.get()); |
- EXPECT_EQ(4, *out.integers_integer); |
- |
- EXPECT_EQ(ChoiceType::STRINGS_ARRAY, out.strings_type); |
- EXPECT_FALSE(out.strings_string.get()); |
- ASSERT_TRUE(out.strings_array.get()); |
- EXPECT_EQ(strings, *out.strings_array); |
+ ASSERT_TRUE(out.integers.as_integer.get()); |
+ EXPECT_FALSE(out.integers.as_array.get()); |
+ EXPECT_EQ(4, *out.integers.as_integer); |
+ |
+ EXPECT_FALSE(out.strings->as_string.get()); |
+ ASSERT_TRUE(out.strings->as_array.get()); |
+ EXPECT_EQ(strings, *out.strings->as_array); |
} |
TEST(JsonSchemaCompilerChoicesTest, ChoiceTypeToValue) { |
@@ -156,23 +149,29 @@ TEST(JsonSchemaCompilerChoicesTest, ChoiceTypeToValue) { |
TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) { |
{ |
- std::vector<int> integers; |
- integers.push_back(1); |
- integers.push_back(2); |
- scoped_ptr<ListValue> array_results = |
- ReturnChoices::Results::Create(integers); |
- |
- ListValue expected; |
- ListValue* expected_argument = new ListValue(); |
- expected_argument->Append(Value::CreateIntegerValue(1)); |
- expected_argument->Append(Value::CreateIntegerValue(2)); |
- expected.Append(expected_argument); |
- EXPECT_TRUE(array_results->Equals(&expected)); |
+ ReturnChoices::Results::Result results; |
+ results.as_array.reset(new std::vector<int>()); |
+ results.as_array->push_back(1); |
+ results.as_array->push_back(2); |
+ |
+ scoped_ptr<base::Value> results_value = results.ToValue(); |
+ ASSERT_TRUE(results_value); |
+ |
+ base::ListValue expected; |
+ expected.AppendInteger(1); |
+ expected.AppendInteger(2); |
+ |
+ EXPECT_TRUE(expected.Equals(results_value.get())); |
} |
{ |
- scoped_ptr<ListValue> integer_results = ReturnChoices::Results::Create(5); |
- ListValue expected; |
- expected.Append(Value::CreateIntegerValue(5)); |
- EXPECT_TRUE(integer_results->Equals(&expected)); |
+ ReturnChoices::Results::Result results; |
+ results.as_integer.reset(new int(5)); |
+ |
+ scoped_ptr<base::Value> results_value = results.ToValue(); |
+ ASSERT_TRUE(results_value); |
+ |
+ base::FundamentalValue expected(5); |
+ |
+ EXPECT_TRUE(expected.Equals(results_value.get())); |
} |
} |