| 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/any.h" | 5 #include "tools/json_schema_compiler/test/any.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/value_builder.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 using namespace test::api::any; | 10 using namespace test::api::any; |
| 11 using namespace extensions; |
| 10 | 12 |
| 11 TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) { | 13 TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) { |
| 12 { | 14 { |
| 13 AnyType any_type; | 15 AnyType any_type; |
| 14 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); | 16 scoped_ptr<DictionaryValue> any_type_value( |
| 15 any_type_value->SetString("any", "value"); | 17 DictionaryBuilder().Set("any", "value").Build()); |
| 16 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); | 18 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); |
| 17 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); | 19 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); |
| 18 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); | 20 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); |
| 19 } | 21 } |
| 20 { | 22 { |
| 21 AnyType any_type; | 23 AnyType any_type; |
| 22 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); | 24 scoped_ptr<DictionaryValue> any_type_value( |
| 23 any_type_value->SetInteger("any", 5); | 25 DictionaryBuilder().Set("any", 5).Build()); |
| 24 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); | 26 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); |
| 25 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); | 27 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); |
| 26 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); | 28 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); |
| 27 } | 29 } |
| 28 } | 30 } |
| 29 | 31 |
| 30 TEST(JsonSchemaCompilerAnyTest, OptionalAnyParamsCreate) { | 32 TEST(JsonSchemaCompilerAnyTest, OptionalAnyParamsCreate) { |
| 31 { | 33 { |
| 32 scoped_ptr<ListValue> params_value(new ListValue()); | 34 scoped_ptr<ListValue> params_value(new ListValue()); |
| 33 scoped_ptr<OptionalAny::Params> params( | 35 scoped_ptr<OptionalAny::Params> params( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 scoped_ptr<Value> param(Value::CreateBooleanValue(true)); | 52 scoped_ptr<Value> param(Value::CreateBooleanValue(true)); |
| 51 params_value->Append(param->DeepCopy()); | 53 params_value->Append(param->DeepCopy()); |
| 52 scoped_ptr<OptionalAny::Params> params( | 54 scoped_ptr<OptionalAny::Params> params( |
| 53 OptionalAny::Params::Create(*params_value)); | 55 OptionalAny::Params::Create(*params_value)); |
| 54 EXPECT_TRUE(params.get()); | 56 EXPECT_TRUE(params.get()); |
| 55 EXPECT_TRUE(params->any_name.get()); | 57 EXPECT_TRUE(params->any_name.get()); |
| 56 EXPECT_TRUE(params->any_name.get()); | 58 EXPECT_TRUE(params->any_name.get()); |
| 57 EXPECT_TRUE(params->any_name->value().Equals(param.get())); | 59 EXPECT_TRUE(params->any_name->value().Equals(param.get())); |
| 58 } | 60 } |
| 59 } | 61 } |
| OLD | NEW |