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

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

Issue 1940153002: Use std::unique_ptr to express ownership of base::Value in PolicyMap::Entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another-fix Created 4 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_registry_tracking_policy_provider_unittest.cc
diff --git a/components/policy/core/common/schema_registry_tracking_policy_provider_unittest.cc b/components/policy/core/common/schema_registry_tracking_policy_provider_unittest.cc
index de8dcd151610389a80d1891f52cdd39b847bef45..061bb6566fb1255a66f92c11242e085525c71ebe 100644
--- a/components/policy/core/common/schema_registry_tracking_policy_provider_unittest.cc
+++ b/components/policy/core/common/schema_registry_tracking_policy_provider_unittest.cc
@@ -8,6 +8,7 @@
#include <string>
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_bundle.h"
@@ -84,23 +85,17 @@ TEST_F(SchemaRegistryTrackingPolicyProviderTest, Empty) {
TEST_F(SchemaRegistryTrackingPolicyProviderTest, PassOnChromePolicy) {
PolicyBundle bundle;
const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
- bundle.Get(chrome_ns).Set("policy",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
- new base::StringValue("visible"),
- NULL);
+ bundle.Get(chrome_ns).Set(
+ "policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
+ base::WrapUnique(new base::StringValue("visible")), nullptr);
EXPECT_CALL(observer_, OnUpdatePolicy(&schema_registry_tracking_provider_));
std::unique_ptr<PolicyBundle> delegate_bundle(new PolicyBundle);
delegate_bundle->CopyFrom(bundle);
delegate_bundle->Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"))
- .Set("foo",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
+ .Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
POLICY_SOURCE_CLOUD,
- new base::StringValue("not visible"),
- NULL);
+ base::WrapUnique(new base::StringValue("not visible")), nullptr);
mock_provider_.UpdatePolicy(std::move(delegate_bundle));
Mock::VerifyAndClearExpectations(&observer_);
@@ -127,12 +122,9 @@ TEST_F(SchemaRegistryTrackingPolicyProviderTest, SchemaReady) {
TEST_F(SchemaRegistryTrackingPolicyProviderTest, SchemaReadyWithComponents) {
PolicyMap policy_map;
- policy_map.Set("foo",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
+ policy_map.Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
POLICY_SOURCE_CLOUD,
- new base::StringValue("omg"),
- NULL);
+ base::WrapUnique(new base::StringValue("omg")), nullptr);
std::unique_ptr<PolicyBundle> bundle(new PolicyBundle);
bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, "")).CopyFrom(policy_map);
bundle->Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"))
@@ -179,12 +171,9 @@ TEST_F(SchemaRegistryTrackingPolicyProviderTest, DelegateUpdates) {
policy::POLICY_DOMAIN_EXTENSIONS));
PolicyMap policy_map;
- policy_map.Set("foo",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
+ policy_map.Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
POLICY_SOURCE_CLOUD,
- new base::StringValue("omg"),
- NULL);
+ base::WrapUnique(new base::StringValue("omg")), nullptr);
// Chrome policy updates are visible even if the components aren't ready.
EXPECT_CALL(observer_, OnUpdatePolicy(&schema_registry_tracking_provider_));
mock_provider_.UpdateChromePolicy(policy_map);
@@ -223,12 +212,9 @@ TEST_F(SchemaRegistryTrackingPolicyProviderTest, RemoveAndAddComponent) {
// Serve policy for |ns|.
PolicyBundle platform_policy;
- platform_policy.Get(ns).Set("foo",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
- new base::StringValue("omg"),
- NULL);
+ platform_policy.Get(ns).Set(
+ "foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
+ base::WrapUnique(new base::StringValue("omg")), nullptr);
std::unique_ptr<PolicyBundle> copy(new PolicyBundle);
copy->CopyFrom(platform_policy);
EXPECT_CALL(observer_, OnUpdatePolicy(_));
« no previous file with comments | « components/policy/core/common/schema_map_unittest.cc ('k') | components/policy/tools/generate_policy_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698