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

Unified Diff: components/policy/core/common/schema_unittest.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 7 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: components/policy/core/common/schema_unittest.cc
diff --git a/components/policy/core/common/schema_unittest.cc b/components/policy/core/common/schema_unittest.cc
index 3ebec136ddb6e31ebee0ed4fd921bdb3403a5a37..d0af06538ec2535609043508059659c4c280b894 100644
--- a/components/policy/core/common/schema_unittest.cc
+++ b/components/policy/core/common/schema_unittest.cc
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
+#include "base/values.h"
#include "components/policy/core/common/schema_internal.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -619,7 +620,7 @@ TEST(SchemaTest, Validate) {
bundle.Clear();
base::ListValue list;
list.AppendInteger(1);
- bundle.Set("Array", list.DeepCopy());
+ bundle.Set("Array", base::MakeUnique<base::Value>(list));
TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
}
@@ -628,7 +629,7 @@ TEST(SchemaTest, Validate) {
bundle.Clear();
base::DictionaryValue dict;
dict.SetString("one", "one");
- bundle.Set("Object", dict.DeepCopy());
+ bundle.Set("Object", base::MakeUnique<base::Value>(dict));
TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
}
@@ -642,14 +643,14 @@ TEST(SchemaTest, Validate) {
bundle.SetBoolean("Boolean", true);
bundle.SetInteger("Integer", 123);
bundle.Set("Null", base::MakeUnique<base::Value>());
- bundle.Set("Number", new base::Value(3.14));
+ bundle.SetDouble("Number", 3.14);
bundle.SetString("String", "omg");
{
base::ListValue list;
list.AppendString("a string");
list.AppendString("another string");
- bundle.Set("Array", list.DeepCopy());
+ bundle.Set("Array", base::MakeUnique<base::Value>(list));
}
{
@@ -657,9 +658,9 @@ TEST(SchemaTest, Validate) {
dict.SetString("one", "string");
dict.SetInteger("two", 2);
base::ListValue list;
- list.Append(dict.CreateDeepCopy());
- list.Append(dict.CreateDeepCopy());
- bundle.Set("ArrayOfObjects", list.DeepCopy());
+ list.GetList().push_back(dict);
+ list.GetList().push_back(dict);
+ bundle.Set("ArrayOfObjects", base::MakeUnique<base::Value>(list));
}
{
@@ -667,9 +668,9 @@ TEST(SchemaTest, Validate) {
list.AppendString("a string");
list.AppendString("another string");
base::ListValue listlist;
- listlist.Append(list.CreateDeepCopy());
- listlist.Append(list.CreateDeepCopy());
- bundle.Set("ArrayOfArray", listlist.DeepCopy());
+ listlist.GetList().push_back(list);
+ listlist.GetList().push_back(list);
+ bundle.Set("ArrayOfArray", base::MakeUnique<base::Value>(listlist));
}
{
@@ -678,7 +679,7 @@ TEST(SchemaTest, Validate) {
dict.SetInteger("two", 2);
dict.SetString("additionally", "a string");
dict.SetString("and also", "another string");
- bundle.Set("Object", dict.DeepCopy());
+ bundle.Set("Object", base::MakeUnique<base::Value>(dict));
}
bundle.SetInteger("IntegerWithEnums", 1);
@@ -803,8 +804,8 @@ TEST(SchemaTest, Validate) {
ASSERT_TRUE(subschema.valid());
base::DictionaryValue root;
- base::ListValue* list_value = new base::ListValue();
- root.Set("List", list_value); // Pass ownership to root.
+ base::ListValue* list_value =
+ root.SetList("List", base::MakeUnique<base::ListValue>());
// Test that there are not errors here.
list_value->AppendInteger(12345);
@@ -830,10 +831,9 @@ TEST(SchemaTest, Validate) {
ASSERT_TRUE(subschema.valid());
base::ListValue root;
- base::ListValue* list_value = new base::ListValue();
- std::unique_ptr<base::DictionaryValue> dict_value(
- new base::DictionaryValue());
- dict_value->Set("List", list_value); // Pass ownership to dict_value.
+ auto dict_value = base::MakeUnique<base::DictionaryValue>();
+ base::ListValue* list_value =
+ dict_value->SetList("List", base::MakeUnique<base::ListValue>());
root.Append(std::move(dict_value));
// Test that there are not errors here.

Powered by Google App Engine
This is Rietveld 408576698