| Index: tools/json_schema_compiler/test/simple_api_unittest.cc
|
| diff --git a/tools/json_schema_compiler/test/simple_api_unittest.cc b/tools/json_schema_compiler/test/simple_api_unittest.cc
|
| index accf32ea1f605630cd255dc0a7bdc774a2be3d5b..00e95b82b50e0717abd1e411eb613e1679696df7 100644
|
| --- a/tools/json_schema_compiler/test/simple_api_unittest.cc
|
| +++ b/tools/json_schema_compiler/test/simple_api_unittest.cc
|
| @@ -4,33 +4,31 @@
|
|
|
| #include "tools/json_schema_compiler/test/simple_api.h"
|
|
|
| +#include "chrome/common/extensions/value_builder.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using namespace test::api::simple_api;
|
| +using namespace extensions;
|
|
|
| namespace {
|
|
|
| static scoped_ptr<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));
|
| + scoped_ptr<DictionaryValue> value(DictionaryBuilder()
|
| + .Set("number", 1.1).Set("integer", 4).Set("string", "bling")
|
| + .SetBoolean("boolean", true).Build());
|
| return value.Pass();
|
| }
|
|
|
| } // namespace
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, IncrementIntegerResultCreate) {
|
| - scoped_ptr<Value> result(IncrementInteger::Result::Create(5));
|
| - int temp = 0;
|
| - EXPECT_TRUE(result->GetAsInteger(&temp));
|
| - EXPECT_EQ(5, temp);
|
| + scoped_ptr<ListValue> results(IncrementInteger::Result::Create(5));
|
| + scoped_ptr<ListValue> expected(ListBuilder().Append(5).Build());
|
| + EXPECT_TRUE(results->Equals(expected.get()));
|
| }
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, IncrementIntegerParamsCreate) {
|
| - scoped_ptr<ListValue> params_value(new ListValue());
|
| - params_value->Append(Value::CreateIntegerValue(6));
|
| + scoped_ptr<ListValue> params_value(ListBuilder().Append(6).Build());
|
| scoped_ptr<IncrementInteger::Params> params(
|
| IncrementInteger::Params::Create(*params_value));
|
| EXPECT_TRUE(params.get());
|
| @@ -39,9 +37,8 @@ TEST(JsonSchemaCompilerSimpleTest, IncrementIntegerParamsCreate) {
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, NumberOfParams) {
|
| {
|
| - scoped_ptr<ListValue> params_value(new ListValue());
|
| - params_value->Append(Value::CreateStringValue("text"));
|
| - params_value->Append(Value::CreateStringValue("text"));
|
| + scoped_ptr<ListValue> params_value(
|
| + ListBuilder().Append("text").Append("text").Build());
|
| scoped_ptr<OptionalString::Params> params(
|
| OptionalString::Params::Create(*params_value));
|
| EXPECT_FALSE(params.get());
|
| @@ -63,8 +60,7 @@ TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsCreate) {
|
| EXPECT_FALSE(params->str.get());
|
| }
|
| {
|
| - scoped_ptr<ListValue> params_value(new ListValue());
|
| - params_value->Append(Value::CreateStringValue("asdf"));
|
| + scoped_ptr<ListValue> params_value(ListBuilder().Append("asdf").Build());
|
| scoped_ptr<OptionalString::Params> params(
|
| OptionalString::Params::Create(*params_value));
|
| EXPECT_TRUE(params.get());
|
| @@ -86,8 +82,7 @@ TEST(JsonSchemaCompilerSimpleTest, OptionalParamsTakingNull) {
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsWrongType) {
|
| {
|
| - scoped_ptr<ListValue> params_value(new ListValue());
|
| - params_value->Append(Value::CreateIntegerValue(5));
|
| + scoped_ptr<ListValue> params_value(ListBuilder().Append(5).Build());
|
| scoped_ptr<OptionalString::Params> params(
|
| OptionalString::Params::Create(*params_value));
|
| EXPECT_FALSE(params.get());
|
| @@ -108,9 +103,9 @@ TEST(JsonSchemaCompilerSimpleTest, OptionalBeforeRequired) {
|
| }
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, NoParamsResultCreate) {
|
| - scoped_ptr<Value> result(OptionalString::Result::Create());
|
| - scoped_ptr<Value> expected(Value::CreateNullValue());
|
| - EXPECT_TRUE(Value::Equals(result.get(), expected.get()));
|
| + scoped_ptr<ListValue> results(OptionalString::Result::Create());
|
| + ListValue expected;
|
| + EXPECT_TRUE(results->Equals(&expected));
|
| }
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, TestTypePopulate) {
|
| @@ -133,10 +128,46 @@ TEST(JsonSchemaCompilerSimpleTest, TestTypePopulate) {
|
| }
|
|
|
| TEST(JsonSchemaCompilerSimpleTest, GetTestType) {
|
| - scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary();
|
| - scoped_ptr<TestType> test_type(new TestType());
|
| - EXPECT_TRUE(TestType::Populate(*value, test_type.get()));
|
| - scoped_ptr<Value> result(GetTestType::Result::Create(*test_type));
|
| - EXPECT_TRUE(value->Equals(result.get()));
|
| + {
|
| + scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary();
|
| + scoped_ptr<TestType> test_type(new TestType());
|
| + EXPECT_TRUE(TestType::Populate(*value, test_type.get()));
|
| + scoped_ptr<ListValue> results(GetTestType::Result::Create(*test_type));
|
| +
|
| + DictionaryValue* result = NULL;
|
| + ASSERT_TRUE(results->GetDictionary(0, &result));
|
| + EXPECT_TRUE(result->Equals(value.get()));
|
| + }
|
| }
|
|
|
| +TEST(JsonSchemaCompilerSimpleTest, OnIntegerFiredCreate) {
|
| + {
|
| + scoped_ptr<ListValue> results(OnIntegerFired::Create(5));
|
| + scoped_ptr<ListValue> expected(ListBuilder().Append(5).Build());
|
| + EXPECT_TRUE(results->Equals(expected.get()));
|
| + }
|
| +}
|
| +
|
| +TEST(JsonSchemaCompilerSimpleTest, OnStringFiredCreate) {
|
| + {
|
| + scoped_ptr<ListValue> results(OnStringFired::Create("yo dawg"));
|
| + scoped_ptr<ListValue> expected(ListBuilder().Append("yo dawg").Build());
|
| + EXPECT_TRUE(results->Equals(expected.get()));
|
| + }
|
| +}
|
| +
|
| +TEST(JsonSchemaCompilerSimpleTest, OnTestTypeFiredCreate) {
|
| + {
|
| + TestType some_test_type;
|
| + scoped_ptr<DictionaryValue> expected = CreateTestTypeDictionary();
|
| + ASSERT_TRUE(expected->GetDouble("number", &some_test_type.number));
|
| + ASSERT_TRUE(expected->GetString("string", &some_test_type.string));
|
| + ASSERT_TRUE(expected->GetInteger("integer", &some_test_type.integer));
|
| + ASSERT_TRUE(expected->GetBoolean("boolean", &some_test_type.boolean));
|
| +
|
| + scoped_ptr<ListValue> results(OnTestTypeFired::Create(some_test_type));
|
| + DictionaryValue* result = NULL;
|
| + ASSERT_TRUE(results->GetDictionary(0, &result));
|
| + EXPECT_TRUE(result->Equals(expected.get()));
|
| + }
|
| +}
|
|
|