15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "tools/json_schema_compiler/test/callbacks.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using namespace test::api::callbacks;
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST(JsonSchemaCompilerCallbacksTest, ReturnsObjectResultCreate) {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ReturnsObject::Results::SomeObject some_object;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  some_object.state = ReturnsObject::Results::SomeObject::STATE_FOO;
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<base::ListValue> results =
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ReturnsObject::Results::Create(some_object);
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::DictionaryValue* expected_dict = new base::DictionaryValue();
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  expected_dict->SetString("state", "foo");
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::ListValue expected;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  expected.Append(expected_dict);
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EXPECT_TRUE(results->Equals(&expected));
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST(JsonSchemaCompilerCallbacksTest, ReturnsMultipleResultCreate) {
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ReturnsMultiple::Results::SomeObject some_object;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  some_object.state = ReturnsMultiple::Results::SomeObject::STATE_FOO;
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<base::ListValue> results =
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      ReturnsMultiple::Results::Create(5, some_object);
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::DictionaryValue* expected_dict = new base::DictionaryValue();
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  expected_dict->SetString("state", "foo");
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::ListValue expected;
33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  expected.Append(new base::FundamentalValue(5));
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  expected.Append(expected_dict);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EXPECT_TRUE(results->Equals(&expected));
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
37