blob: 1eb05c7a003220be42c9884ce31d06e866a5f7ff [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/json_schema_compiler/test/callbacks.h"
#include <memory>
#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
TEST(JsonSchemaCompilerCallbacksTest, ReturnsObjectResultCreate) {
test::api::callbacks::ReturnsObject::Results::SomeObject some_object;
some_object.state = test::api::callbacks::ENUMERATION_FOO;
base::Value results = base::Value::FromUniquePtrValue(
test::api::callbacks::ReturnsObject::Results::Create(some_object));
auto expected_dict = std::make_unique<base::DictionaryValue>();
expected_dict->SetString("state", "foo");
base::ListValue expected;
expected.Append(std::move(expected_dict));
EXPECT_EQ(expected, results);
}
TEST(JsonSchemaCompilerCallbacksTest, ReturnsMultipleResultCreate) {
test::api::callbacks::ReturnsMultiple::Results::SomeObject some_object;
some_object.state = test::api::callbacks::ENUMERATION_FOO;
base::Value results = base::Value::FromUniquePtrValue(
test::api::callbacks::ReturnsMultiple::Results::Create(5, some_object));
auto expected_dict = std::make_unique<base::DictionaryValue>();
expected_dict->SetString("state", "foo");
base::ListValue expected;
expected.AppendInteger(5);
expected.Append(std::move(expected_dict));
EXPECT_EQ(expected, results);
}