OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/json_schema_compiler/test/objects.h" | 5 #include "tools/json_schema_compiler/test/objects.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using namespace test::api::objects; | 10 using namespace test::api::objects; |
11 | 11 |
12 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { | 12 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { |
13 { | 13 { |
14 scoped_ptr<base::ListValue> strings(new base::ListValue()); | 14 scoped_ptr<base::ListValue> strings(new base::ListValue()); |
15 strings->Append(base::Value::CreateStringValue("one")); | 15 strings->Append(base::Value::CreateStringValue("one")); |
16 strings->Append(base::Value::CreateStringValue("two")); | 16 strings->Append(base::Value::CreateStringValue("two")); |
17 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); | 17 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); |
18 info_value->Set("strings", strings.release()); | 18 info_value->Set("strings", strings.release()); |
19 info_value->Set("integer", new base::FundamentalValue(5)); | 19 info_value->Set("integer", new base::FundamentalValue(5)); |
20 info_value->Set("boolean", base::Value::CreateBooleanValue(true)); | 20 info_value->Set("boolean", new base::FundamentalValue(true)); |
21 | 21 |
22 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 22 scoped_ptr<base::ListValue> params_value(new base::ListValue()); |
23 params_value->Append(info_value.release()); | 23 params_value->Append(info_value.release()); |
24 scoped_ptr<ObjectParam::Params> params( | 24 scoped_ptr<ObjectParam::Params> params( |
25 ObjectParam::Params::Create(*params_value)); | 25 ObjectParam::Params::Create(*params_value)); |
26 EXPECT_TRUE(params.get()); | 26 EXPECT_TRUE(params.get()); |
27 EXPECT_EQ((size_t) 2, params->info.strings.size()); | 27 EXPECT_EQ((size_t) 2, params->info.strings.size()); |
28 EXPECT_EQ("one", params->info.strings[0]); | 28 EXPECT_EQ("one", params->info.strings[0]); |
29 EXPECT_EQ("two", params->info.strings[1]); | 29 EXPECT_EQ("two", params->info.strings[1]); |
30 EXPECT_EQ(5, params->info.integer); | 30 EXPECT_EQ(5, params->info.integer); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 OnObjectFired::SomeObject object; | 62 OnObjectFired::SomeObject object; |
63 object.state = OnObjectFired::SomeObject::STATE_BAR; | 63 object.state = OnObjectFired::SomeObject::STATE_BAR; |
64 scoped_ptr<base::ListValue> results(OnObjectFired::Create(object)); | 64 scoped_ptr<base::ListValue> results(OnObjectFired::Create(object)); |
65 | 65 |
66 base::DictionaryValue expected; | 66 base::DictionaryValue expected; |
67 expected.SetString("state", "bar"); | 67 expected.SetString("state", "bar"); |
68 base::DictionaryValue* result = NULL; | 68 base::DictionaryValue* result = NULL; |
69 ASSERT_TRUE(results->GetDictionary(0, &result)); | 69 ASSERT_TRUE(results->GetDictionary(0, &result)); |
70 ASSERT_TRUE(result->Equals(&expected)); | 70 ASSERT_TRUE(result->Equals(&expected)); |
71 } | 71 } |
OLD | NEW |