| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/error_generation.h" | 5 #include "tools/json_schema_compiler/test/error_generation.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "tools/json_schema_compiler/test/test_util.h" | 10 #include "tools/json_schema_compiler/test/test_util.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // GenerateFunctionParamsCreate errors | 94 // GenerateFunctionParamsCreate errors |
| 95 | 95 |
| 96 TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) { | 96 TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) { |
| 97 { | 97 { |
| 98 scoped_ptr<base::ListValue> params_value = List( | 98 scoped_ptr<base::ListValue> params_value = List( |
| 99 new FundamentalValue(5)); | 99 new FundamentalValue(5)); |
| 100 base::string16 error; | 100 base::string16 error; |
| 101 EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error)); | 101 EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error)); |
| 102 } | 102 } |
| 103 { | 103 { |
| 104 scoped_ptr<base::ListValue> params_value = List( | 104 scoped_ptr<base::ListValue> params_value = |
| 105 base::Value::CreateNullValue()); | 105 List(base::Value::CreateNullValue().release()); |
| 106 base::string16 error; | 106 base::string16 error; |
| 107 EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error)); | 107 EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error)); |
| 108 EXPECT_TRUE(EqualsUtf16("'num' is required", error)); | 108 EXPECT_TRUE(EqualsUtf16("'num' is required", error)); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 // GeneratePopulateVariableFromValue errors | 112 // GeneratePopulateVariableFromValue errors |
| 113 | 113 |
| 114 TEST(JsonSchemaCompilerErrorTest, WrongPropertyValueType) { | 114 TEST(JsonSchemaCompilerErrorTest, WrongPropertyValueType) { |
| 115 { | 115 { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value))); | 329 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value))); |
| 330 } | 330 } |
| 331 { | 331 { |
| 332 scoped_ptr<base::DictionaryValue> value = Dictionary( | 332 scoped_ptr<base::DictionaryValue> value = Dictionary( |
| 333 "string", new base::StringValue("yes"), | 333 "string", new base::StringValue("yes"), |
| 334 "ohno", new base::StringValue("many values")); | 334 "ohno", new base::StringValue("many values")); |
| 335 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'", | 335 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'", |
| 336 GetPopulateError<TestType>(*value))); | 336 GetPopulateError<TestType>(*value))); |
| 337 } | 337 } |
| 338 } | 338 } |
| OLD | NEW |