Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "tools/json_schema_compiler/test/simple_api.h" | |
| 6 #include "tools/json_schema_compiler/test/crossref.h" | |
| 7 | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 using namespace test::api::crossref; | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 static DictionaryValue* CreateTestTypeDictionary() { | |
| 15 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | |
| 16 value->SetWithoutPathExpansion("number", Value::CreateDoubleValue(1.1)); | |
| 17 value->SetWithoutPathExpansion("integer", Value::CreateIntegerValue(4)); | |
| 18 value->SetWithoutPathExpansion("string", Value::CreateStringValue("bling")); | |
| 19 value->SetWithoutPathExpansion("boolean", Value::CreateBooleanValue(true)); | |
| 20 return value.release(); | |
|
not at google - send to devlin
2012/02/19 23:19:59
.Pass()
calamity
2012/02/20 05:03:37
Done.
| |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamCreate) { | |
| 26 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 27 DictionaryValue* test_type_value = CreateTestTypeDictionary(); | |
| 28 params_value->Append(test_type_value); | |
| 29 scoped_ptr<TestTypeOptionalParam::Params> params( | |
| 30 TestTypeOptionalParam::Params::Create(*params_value)); | |
| 31 EXPECT_TRUE(params.get()); | |
| 32 EXPECT_TRUE(params->test_type.get()); | |
| 33 EXPECT_TRUE(test_type_value->Equals(params->test_type->ToValue().get())); | |
| 34 } | |
| 35 | |
| 36 TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamFail) { | |
| 37 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 38 DictionaryValue* test_type_value = CreateTestTypeDictionary(); | |
| 39 test_type_value->RemoveWithoutPathExpansion("number", NULL); | |
| 40 params_value->Append(test_type_value); | |
| 41 scoped_ptr<TestTypeOptionalParam::Params> params( | |
| 42 TestTypeOptionalParam::Params::Create(*params_value)); | |
| 43 EXPECT_FALSE(params.get()); | |
| 44 } | |
| 45 | |
| 46 TEST(JsonSchemaCompilerCrossrefTest, GetTestType) { | |
| 47 scoped_ptr<DictionaryValue> value(CreateTestTypeDictionary()); | |
| 48 scoped_ptr<test::api::simple_api::TestType> test_type( | |
| 49 new test::api::simple_api::TestType()); | |
| 50 EXPECT_TRUE( | |
| 51 test::api::simple_api::TestType::Populate(*value, test_type.get())); | |
| 52 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type)); | |
| 53 EXPECT_TRUE(value->Equals(result.get())); | |
| 54 } | |
| 55 | |
| 56 | |
|
not at google - send to devlin
2012/02/19 23:19:59
unnecessary blank lines
calamity
2012/02/20 05:03:37
Done.
| |
| OLD | NEW |