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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 using namespace test::api::objects; | 10 using namespace test::api::objects; |
10 | 11 |
11 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { | 12 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { |
12 { | 13 { |
13 scoped_ptr<ListValue> strings(new ListValue()); | 14 scoped_ptr<ListValue> strings(new ListValue()); |
14 strings->Append(Value::CreateStringValue("one")); | 15 strings->Append(Value::CreateStringValue("one")); |
15 strings->Append(Value::CreateStringValue("two")); | 16 strings->Append(Value::CreateStringValue("two")); |
16 scoped_ptr<DictionaryValue> info_value(new DictionaryValue()); | 17 scoped_ptr<DictionaryValue> info_value(new DictionaryValue()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) { | 61 TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) { |
61 OnObjectFired::SomeObject object; | 62 OnObjectFired::SomeObject object; |
62 object.state = OnObjectFired::SomeObject::STATE_BAR; | 63 object.state = OnObjectFired::SomeObject::STATE_BAR; |
63 scoped_ptr<ListValue> results(OnObjectFired::Create(object)); | 64 scoped_ptr<ListValue> results(OnObjectFired::Create(object)); |
64 | 65 |
65 DictionaryValue expected; | 66 DictionaryValue expected; |
66 expected.SetString("state", "bar"); | 67 expected.SetString("state", "bar"); |
67 DictionaryValue* result = NULL; | 68 DictionaryValue* result = NULL; |
68 ASSERT_TRUE(results->GetDictionary(0, &result)); | 69 ASSERT_TRUE(results->GetDictionary(0, &result)); |
69 ASSERT_TRUE(result->Equals(&expected)); | 70 ASSERT_TRUE(result->Equals(&expected)); |
| 71 |
| 72 std::string json1 = OnObjectFired::ToJson(object); |
| 73 std::string json2; |
| 74 base::JSONWriter::Write(results.get(), &json2); |
| 75 ASSERT_EQ(json1, json2); |
70 } | 76 } |
OLD | NEW |