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
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/json_schema_compiler/test/any.h"
8 using namespace test::api::any
;
10 TEST(JsonSchemaCompilerAnyTest
, AnyTypePopulate
) {
13 scoped_ptr
<DictionaryValue
> any_type_value(new DictionaryValue());
14 any_type_value
->SetString("any", "value");
15 EXPECT_TRUE(AnyType::Populate(*any_type_value
, &any_type
));
16 scoped_ptr
<Value
> any_type_to_value(any_type
.ToValue());
17 EXPECT_TRUE(any_type_value
->Equals(any_type_to_value
.get()));
21 scoped_ptr
<DictionaryValue
> any_type_value(new DictionaryValue());
22 any_type_value
->SetInteger("any", 5);
23 EXPECT_TRUE(AnyType::Populate(*any_type_value
, &any_type
));
24 scoped_ptr
<Value
> any_type_to_value(any_type
.ToValue());
25 EXPECT_TRUE(any_type_value
->Equals(any_type_to_value
.get()));
29 TEST(JsonSchemaCompilerAnyTest
, OptionalAnyParamsCreate
) {
31 scoped_ptr
<ListValue
> params_value(new ListValue());
32 scoped_ptr
<OptionalAny::Params
> params(
33 OptionalAny::Params::Create(*params_value
));
34 EXPECT_TRUE(params
.get());
35 EXPECT_FALSE(params
->any_name
.get());
38 scoped_ptr
<ListValue
> params_value(new ListValue());
39 scoped_ptr
<Value
> param(Value::CreateStringValue("asdf"));
40 params_value
->Append(param
->DeepCopy());
41 scoped_ptr
<OptionalAny::Params
> params(
42 OptionalAny::Params::Create(*params_value
));
44 ASSERT_TRUE(params
->any_name
);
45 EXPECT_TRUE(params
->any_name
->Equals(param
.get()));
48 scoped_ptr
<ListValue
> params_value(new ListValue());
49 scoped_ptr
<Value
> param(Value::CreateBooleanValue(true));
50 params_value
->Append(param
->DeepCopy());
51 scoped_ptr
<OptionalAny::Params
> params(
52 OptionalAny::Params::Create(*params_value
));
54 ASSERT_TRUE(params
->any_name
);
55 EXPECT_TRUE(params
->any_name
->Equals(param
.get()));