| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using namespace test::api::objects; | 9 using namespace test::api::objects; |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 scoped_ptr<ListValue> params_value(new ListValue()); | 40 scoped_ptr<ListValue> params_value(new ListValue()); |
| 41 params_value->Append(info_value.release()); | 41 params_value->Append(info_value.release()); |
| 42 scoped_ptr<ObjectParam::Params> params( | 42 scoped_ptr<ObjectParam::Params> params( |
| 43 ObjectParam::Params::Create(*params_value)); | 43 ObjectParam::Params::Create(*params_value)); |
| 44 EXPECT_FALSE(params.get()); | 44 EXPECT_FALSE(params.get()); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) { | 48 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) { |
| 49 scoped_ptr<ReturnsObject::Result::Info> info( | 49 ReturnsObject::Result::Info info; |
| 50 new ReturnsObject::Result::Info()); | 50 info.state = ReturnsObject::Result::Info::STATE_FOO; |
| 51 info->state = ReturnsObject::Result::Info::STATE_FOO; | 51 scoped_ptr<ListValue> results(ReturnsObject::Result::Create(info)); |
| 52 scoped_ptr<Value> result_value( | 52 |
| 53 ReturnsObject::Result::Create(*info)); | 53 DictionaryValue expected; |
| 54 DictionaryValue* result_dict = NULL; | 54 expected.SetString("state", "foo"); |
| 55 EXPECT_TRUE(result_value->GetAsDictionary(&result_dict)); | 55 DictionaryValue* result = NULL; |
| 56 std::string state; | 56 ASSERT_TRUE(results->GetDictionary(0, &result)); |
| 57 EXPECT_TRUE(result_dict->GetString("state", &state)); | 57 ASSERT_TRUE(result->Equals(&expected)); |
| 58 EXPECT_EQ("foo", state); | |
| 59 } | 58 } |
| 59 |
| 60 TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) { |
| 61 OnObjectFired::SomeObject object; |
| 62 object.state = OnObjectFired::SomeObject::STATE_BAR; |
| 63 scoped_ptr<ListValue> results(OnObjectFired::Create(object)); |
| 64 |
| 65 DictionaryValue expected; |
| 66 expected.SetString("state", "bar"); |
| 67 DictionaryValue* result = NULL; |
| 68 ASSERT_TRUE(results->GetDictionary(0, &result)); |
| 69 ASSERT_TRUE(result->Equals(&expected)); |
| 70 } |
| OLD | NEW |