Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: tools/json_schema_compiler/test/objects_unittest.cc

Issue 10701012: JSON Schema Compiler: Added event compilation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Tested GetAllPossibleParameterLists better. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/test/objects_unittest.cc
diff --git a/tools/json_schema_compiler/test/objects_unittest.cc b/tools/json_schema_compiler/test/objects_unittest.cc
index b0ed54f1ceaf32d22635701e086d1dd7b514e933..0555967560a7acc50e216c4d6854a839b0d4a662 100644
--- a/tools/json_schema_compiler/test/objects_unittest.cc
+++ b/tools/json_schema_compiler/test/objects_unittest.cc
@@ -4,25 +4,21 @@
#include "tools/json_schema_compiler/test/objects.h"
+#include "chrome/common/extensions/value_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
using namespace test::api::objects;
+using namespace extensions;
TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
{
- scoped_ptr<ListValue> strings(new ListValue());
- strings->Append(Value::CreateStringValue("one"));
- strings->Append(Value::CreateStringValue("two"));
- scoped_ptr<DictionaryValue> info_value(new DictionaryValue());
- info_value->Set("strings", strings.release());
- info_value->Set("integer", Value::CreateIntegerValue(5));
- info_value->Set("boolean", Value::CreateBooleanValue(true));
-
- scoped_ptr<ListValue> params_value(new ListValue());
- params_value->Append(info_value.release());
+ scoped_ptr<ListValue> params_value(ListBuilder()
+ .Append(DictionaryBuilder()
+ .Set("strings", ListBuilder().Append("one").Append("two"))
+ .Set("integer", 5).SetBoolean("boolean", true)).Build());
scoped_ptr<ObjectParam::Params> params(
ObjectParam::Params::Create(*params_value));
- EXPECT_TRUE(params.get());
+ ASSERT_TRUE(params.get());
EXPECT_EQ((size_t) 2, params->info.strings.size());
EXPECT_EQ("one", params->info.strings[0]);
EXPECT_EQ("two", params->info.strings[1]);
@@ -30,15 +26,10 @@ TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
EXPECT_TRUE(params->info.boolean);
}
{
- scoped_ptr<ListValue> strings(new ListValue());
- strings->Append(Value::CreateStringValue("one"));
- strings->Append(Value::CreateStringValue("two"));
- scoped_ptr<DictionaryValue> info_value(new DictionaryValue());
- info_value->Set("strings", strings.release());
- info_value->Set("integer", Value::CreateIntegerValue(5));
-
- scoped_ptr<ListValue> params_value(new ListValue());
- params_value->Append(info_value.release());
+ scoped_ptr<ListValue> params_value(ListBuilder()
+ .Append(DictionaryBuilder()
+ .Set("strings", ListBuilder().Append("one").Append("two"))
+ .Set("integer", 5)).Build());
scoped_ptr<ObjectParam::Params> params(
ObjectParam::Params::Create(*params_value));
EXPECT_FALSE(params.get());
@@ -46,14 +37,21 @@ TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
}
TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) {
- scoped_ptr<ReturnsObject::Result::Info> info(
- new ReturnsObject::Result::Info());
- info->state = ReturnsObject::Result::Info::STATE_FOO;
- scoped_ptr<Value> result_value(
- ReturnsObject::Result::Create(*info));
- DictionaryValue* result_dict = NULL;
- EXPECT_TRUE(result_value->GetAsDictionary(&result_dict));
- std::string state;
- EXPECT_TRUE(result_dict->GetString("state", &state));
- EXPECT_EQ("foo", state);
+ ReturnsObject::Result::Info info;
+ info.state = ReturnsObject::Result::Info::STATE_FOO;
+ scoped_ptr<ListValue> results(ReturnsObject::Result::Create(info));
+
+ scoped_ptr<ListValue> expected(ListBuilder().Append(DictionaryBuilder()
+ .Set("state", "foo")).Build());
+ ASSERT_TRUE(results->Equals(expected.get()));
+}
+
+TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) {
+ OnObjectFired::SomeObject object;
+ object.state = OnObjectFired::SomeObject::STATE_BAR;
+ scoped_ptr<ListValue> results(OnObjectFired::Create(object));
+
+ scoped_ptr<ListValue> expected(ListBuilder().Append(DictionaryBuilder()
+ .Set("state", "bar")).Build());
+ ASSERT_TRUE(results->Equals(expected.get()));
}

Powered by Google App Engine
This is Rietveld 408576698