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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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 1238f5a442ded96edd4d6d2c8b5e4d60102fa62a..9b40bad1503e34e3e164b7ea3591b4b199c78bc3 100644
--- a/components/policy/core/common/schema_unittest.cc
+++ b/components/policy/core/common/schema_unittest.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <memory>
+#include <utility>
#include "base/macros.h"
#include "base/strings/stringprintf.h"
@@ -770,9 +771,10 @@ TEST(SchemaTest, Validate) {
base::ListValue root;
// Unknown property.
- base::DictionaryValue* dict_value = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> dict_value(
+ new base::DictionaryValue());
dict_value->SetBoolean("three", true);
- root.Append(dict_value); // Pass ownership to root.
+ root.Append(std::move(dict_value));
TestSchemaValidation(subschema, root, SCHEMA_STRICT, false);
TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false);
TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, true);
@@ -782,9 +784,9 @@ TEST(SchemaTest, Validate) {
root.Remove(root.GetSize() - 1, NULL);
// Invalid property.
- dict_value = new base::DictionaryValue();
+ dict_value.reset(new base::DictionaryValue());
dict_value->SetBoolean("two", true);
- root.Append(dict_value); // Pass ownership to root.
+ root.Append(std::move(dict_value));
TestSchemaValidation(subschema, root, SCHEMA_STRICT, false);
TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false);
TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, false);
@@ -828,9 +830,10 @@ TEST(SchemaTest, Validate) {
base::ListValue root;
base::ListValue* list_value = new base::ListValue();
- base::DictionaryValue* dict_value = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> dict_value(
+ new base::DictionaryValue());
dict_value->Set("List", list_value); // Pass ownership to dict_value.
- root.Append(dict_value); // Pass ownership to root.
+ root.Append(std::move(dict_value));
// Test that there are not errors here.
list_value->AppendString("blabla");

Powered by Google App Engine
This is Rietveld 408576698