Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Unified Diff: tools/json_schema_compiler/test/functions_on_types_unittest.cc

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add any in arrays to util.h Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/test/functions_on_types_unittest.cc
diff --git a/tools/json_schema_compiler/test/functions_on_types_unittest.cc b/tools/json_schema_compiler/test/functions_on_types_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..41a276cd57b5a5f6e77340731e456c3aefaa51f0
--- /dev/null
+++ b/tools/json_schema_compiler/test/functions_on_types_unittest.cc
@@ -0,0 +1,68 @@
+// 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/functionsOnTypes.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace test::api::functions_on_types;
+
+TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetParamsCreate) {
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<StorageArea::Get::Params> params(
+ StorageArea::Get::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_EQ(StorageArea::Get::Params::KEYS_NONE, params->keys_type);
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(Value::CreateIntegerValue(9));
+ scoped_ptr<StorageArea::Get::Params> params(
+ StorageArea::Get::Params::Create(*params_value));
+ EXPECT_FALSE(params.get());
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(Value::CreateStringValue("test"));
+ scoped_ptr<StorageArea::Get::Params> params(
+ StorageArea::Get::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_EQ(StorageArea::Get::Params::KEYS_STRING, params->keys_type);
+ EXPECT_EQ("test", *params->keys_string);
+ }
+ {
+ scoped_ptr<DictionaryValue> keys_object_value(new DictionaryValue());
+ keys_object_value->SetInteger("integer", 5);
+ keys_object_value->SetString("string", "string");
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(keys_object_value->DeepCopy());
+ scoped_ptr<StorageArea::Get::Params> params(
+ StorageArea::Get::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_EQ(StorageArea::Get::Params::KEYS_OBJECT, params->keys_type);
+ EXPECT_TRUE(
+ keys_object_value->Equals(&params->keys_object->additional_properties));
+ }
+}
+
+TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetResultCreate) {
+ scoped_ptr<StorageArea::Get::Result::Items> items(
+ new StorageArea::Get::Result::Items());
+ items->additional_properties.SetDouble("asdf", 0.1);
+ items->additional_properties.SetString("sdfg", "zxcv");
+ scoped_ptr<Value> result_value(StorageArea::Get::Result::Create(*items));
+ EXPECT_TRUE(result_value->Equals(&items->additional_properties));
+}
+
+TEST(JsonSchemaCompilerFunctionsOnTypesTest, ChromeSettingGetParamsCreate) {
+ scoped_ptr<DictionaryValue> details_value(new DictionaryValue());
+ details_value->SetBoolean("incognito", true);
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(details_value.release());
+ scoped_ptr<ChromeSetting::Get::Params> params(
+ ChromeSetting::Get::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_TRUE(*params->details.incognito);
+}
« no previous file with comments | « tools/json_schema_compiler/test/functionsOnTypes.json ('k') | tools/json_schema_compiler/test/json_schema_compiler_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698