Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / tools / json_schema_compiler / test / functions_as_parameters_unittest.cc
blobf53e434f153bf6a890276438ded4cb4edf939951
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 "tools/json_schema_compiler/test/functions_as_parameters.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 using namespace test::api::functions_as_parameters;
11 TEST(JsonSchemaCompilerFunctionsAsParametersTest, PopulateRequiredFunction) {
12 // The expectation is that if any value is set for the function, then
13 // the function is "present".
15 DictionaryValue empty_value;
16 FunctionType out;
17 EXPECT_FALSE(FunctionType::Populate(empty_value, &out));
20 DictionaryValue value;
21 DictionaryValue function_dict;
22 value.Set("event_callback", function_dict.DeepCopy());
23 FunctionType out;
24 ASSERT_TRUE(FunctionType::Populate(value, &out));
25 EXPECT_TRUE(out.event_callback.empty());
29 TEST(JsonSchemaCompilerFunctionsAsParametersTest, RequiredFunctionToValue) {
31 DictionaryValue value;
32 DictionaryValue function_dict;
33 value.Set("event_callback", function_dict.DeepCopy());
35 FunctionType out;
36 ASSERT_TRUE(FunctionType::Populate(value, &out));
37 EXPECT_TRUE(value.Equals(out.ToValue().get()));
40 DictionaryValue value;
41 DictionaryValue expected_value;
42 DictionaryValue function_dict;
43 value.Set("event_callback", function_dict.DeepCopy());
44 expected_value.Set("event_callback", function_dict.DeepCopy());
46 FunctionType out;
47 ASSERT_TRUE(FunctionType::Populate(value, &out));
48 EXPECT_TRUE(expected_value.Equals(out.ToValue().get()));
52 TEST(JsonSchemaCompilerFunctionsAsParametersTest, PopulateOptionalFunction) {
54 DictionaryValue empty_value;
55 OptionalFunctionType out;
56 ASSERT_TRUE(OptionalFunctionType::Populate(empty_value, &out));
57 EXPECT_FALSE(out.event_callback.get());
60 DictionaryValue value;
61 DictionaryValue function_value;
62 value.Set("event_callback", function_value.DeepCopy());
63 OptionalFunctionType out;
64 ASSERT_TRUE(OptionalFunctionType::Populate(value, &out));
65 EXPECT_TRUE(out.event_callback.get());
68 DictionaryValue value;
69 DictionaryValue function_value;
70 value.Set("event_callback", function_value.DeepCopy());
71 OptionalFunctionType out;
72 ASSERT_TRUE(OptionalFunctionType::Populate(value, &out));
73 EXPECT_TRUE(out.event_callback.get());
77 TEST(JsonSchemaCompilerFunctionsAsParametersTest, OptionalFunctionToValue) {
79 DictionaryValue empty_value;
80 OptionalFunctionType out;
81 ASSERT_TRUE(OptionalFunctionType::Populate(empty_value, &out));
82 // event_callback should not be set in the return from ToValue.
83 EXPECT_TRUE(empty_value.Equals(out.ToValue().get()));
86 DictionaryValue value;
87 DictionaryValue function_value;
88 value.Set("event_callback", function_value.DeepCopy());
90 OptionalFunctionType out;
91 ASSERT_TRUE(OptionalFunctionType::Populate(value, &out));
92 EXPECT_TRUE(value.Equals(out.ToValue().get()));