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

Side by Side Diff: components/policy/core/common/cloud/component_cloud_policy_updater_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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/policy/core/common/cloud/component_cloud_policy_updater.h" 5 #include "components/policy/core/common/cloud/component_cloud_policy_updater.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ASSERT_EQ(store_->policy().end(), store_->policy().begin()); 102 ASSERT_EQ(store_->policy().end(), store_->policy().begin());
103 103
104 builder_.policy_data().set_policy_type( 104 builder_.policy_data().set_policy_type(
105 dm_protocol::kChromeExtensionPolicyType); 105 dm_protocol::kChromeExtensionPolicyType);
106 builder_.policy_data().set_settings_entity_id(kTestExtension); 106 builder_.policy_data().set_settings_entity_id(kTestExtension);
107 builder_.payload().set_download_url(kTestDownload); 107 builder_.payload().set_download_url(kTestDownload);
108 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy)); 108 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy));
109 109
110 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); 110 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension);
111 PolicyMap& policy = expected_bundle_.Get(ns); 111 PolicyMap& policy = expected_bundle_.Get(ns);
112 policy.Set("Name", 112 policy.Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
113 POLICY_LEVEL_MANDATORY,
114 POLICY_SCOPE_USER,
115 POLICY_SOURCE_CLOUD, 113 POLICY_SOURCE_CLOUD,
116 new base::StringValue("disabled"), 114 base::WrapUnique(new base::StringValue("disabled")), nullptr);
117 NULL); 115 policy.Set("Second", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER,
118 policy.Set("Second",
119 POLICY_LEVEL_RECOMMENDED,
120 POLICY_SCOPE_USER,
121 POLICY_SOURCE_CLOUD, 116 POLICY_SOURCE_CLOUD,
122 new base::StringValue("maybe"), 117 base::WrapUnique(new base::StringValue("maybe")), nullptr);
123 NULL);
124 } 118 }
125 119
126 void ComponentCloudPolicyUpdaterTest::TearDown() { 120 void ComponentCloudPolicyUpdaterTest::TearDown() {
127 updater_.reset(); 121 updater_.reset();
128 task_runner_->RunUntilIdle(); 122 task_runner_->RunUntilIdle();
129 } 123 }
130 124
131 std::unique_ptr<em::PolicyFetchResponse> 125 std::unique_ptr<em::PolicyFetchResponse>
132 ComponentCloudPolicyUpdaterTest::CreateResponse() { 126 ComponentCloudPolicyUpdaterTest::CreateResponse() {
133 builder_.Build(); 127 builder_.Build();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // Now cancel that update before the download completes. 344 // Now cancel that update before the download completes.
351 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0); 345 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0);
352 updater_->CancelUpdate( 346 updater_->CancelUpdate(
353 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension)); 347 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension));
354 task_runner_->RunUntilIdle(); 348 task_runner_->RunUntilIdle();
355 Mock::VerifyAndClearExpectations(&store_delegate_); 349 Mock::VerifyAndClearExpectations(&store_delegate_);
356 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0)); 350 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0));
357 } 351 }
358 352
359 } // namespace policy 353 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698