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

Side by Side Diff: components/policy/core/common/configuration_policy_provider_test.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 unified diff | Download patch
« no previous file with comments | « components/flags_ui/flags_state.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/configuration_policy_provider_test.h" 5 #include "components/policy/core/common/configuration_policy_provider_test.h"
6 6
7 #include <memory>
8 #include <utility>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/callback.h" 11 #include "base/callback.h"
9 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
10 #include "base/values.h" 13 #include "base/values.h"
11 #include "components/policy/core/common/configuration_policy_provider.h" 14 #include "components/policy/core/common/configuration_policy_provider.h"
12 #include "components/policy/core/common/external_data_fetcher.h" 15 #include "components/policy/core/common/external_data_fetcher.h"
13 #include "components/policy/core/common/mock_configuration_policy_provider.h" 16 #include "components/policy/core/common/mock_configuration_policy_provider.h"
14 #include "components/policy/core/common/policy_bundle.h" 17 #include "components/policy/core/common/policy_bundle.h"
15 #include "components/policy/core/common/policy_map.h" 18 #include "components/policy/core/common/policy_map.h"
16 #include "components/policy/core/common/policy_namespace.h" 19 #include "components/policy/core/common/policy_namespace.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 expected_value.SetString("string", "omg"); 297 expected_value.SetString("string", "omg");
295 298
296 base::ListValue* list = new base::ListValue(); 299 base::ListValue* list = new base::ListValue();
297 list->Set(0U, new base::StringValue("first")); 300 list->Set(0U, new base::StringValue("first"));
298 list->Set(1U, new base::StringValue("second")); 301 list->Set(1U, new base::StringValue("second"));
299 expected_value.Set("array", list); 302 expected_value.Set("array", list);
300 303
301 base::DictionaryValue* dict = new base::DictionaryValue(); 304 base::DictionaryValue* dict = new base::DictionaryValue();
302 dict->SetString("sub", "value"); 305 dict->SetString("sub", "value");
303 list = new base::ListValue(); 306 list = new base::ListValue();
304 base::DictionaryValue* sub = new base::DictionaryValue(); 307 std::unique_ptr<base::DictionaryValue> sub(new base::DictionaryValue());
305 sub->SetInteger("aaa", 111); 308 sub->SetInteger("aaa", 111);
306 sub->SetInteger("bbb", 222); 309 sub->SetInteger("bbb", 222);
307 list->Append(sub); 310 list->Append(std::move(sub));
308 sub = new base::DictionaryValue(); 311 sub.reset(new base::DictionaryValue());
309 sub->SetString("ccc", "333"); 312 sub->SetString("ccc", "333");
310 sub->SetString("ddd", "444"); 313 sub->SetString("ddd", "444");
311 list->Append(sub); 314 list->Append(std::move(sub));
312 dict->Set("sublist", list); 315 dict->Set("sublist", list);
313 expected_value.Set("dictionary", dict); 316 expected_value.Set("dictionary", dict);
314 317
315 CheckValue(test_keys::kKeyDictionary, 318 CheckValue(test_keys::kKeyDictionary,
316 expected_value, 319 expected_value,
317 base::Bind(&PolicyProviderTestHarness::InstallDictionaryPolicy, 320 base::Bind(&PolicyProviderTestHarness::InstallDictionaryPolicy,
318 base::Unretained(test_harness_.get()), 321 base::Unretained(test_harness_.get()),
319 test_keys::kKeyDictionary, 322 test_keys::kKeyDictionary,
320 &expected_value)); 323 &expected_value));
321 } 324 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 360
358 TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) { 361 TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) {
359 base::DictionaryValue policy_dict; 362 base::DictionaryValue policy_dict;
360 policy_dict.SetBoolean("bool", true); 363 policy_dict.SetBoolean("bool", true);
361 policy_dict.SetDouble("double", 123.456); 364 policy_dict.SetDouble("double", 123.456);
362 policy_dict.SetInteger("int", 789); 365 policy_dict.SetInteger("int", 789);
363 policy_dict.SetString("string", "string value"); 366 policy_dict.SetString("string", "string value");
364 367
365 base::ListValue* list = new base::ListValue(); 368 base::ListValue* list = new base::ListValue();
366 for (int i = 0; i < 2; ++i) { 369 for (int i = 0; i < 2; ++i) {
367 base::DictionaryValue* dict = new base::DictionaryValue(); 370 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
368 dict->SetInteger("subdictindex", i); 371 dict->SetInteger("subdictindex", i);
369 dict->Set("subdict", policy_dict.DeepCopy()); 372 dict->Set("subdict", policy_dict.DeepCopy());
370 list->Append(dict); 373 list->Append(std::move(dict));
371 } 374 }
372 policy_dict.Set("list", list); 375 policy_dict.Set("list", list);
373 policy_dict.Set("dict", policy_dict.DeepCopy()); 376 policy_dict.Set("dict", policy_dict.DeepCopy());
374 377
375 // Install these policies as a Chrome policy. 378 // Install these policies as a Chrome policy.
376 test_harness_->InstallDictionaryPolicy(test_keys::kKeyDictionary, 379 test_harness_->InstallDictionaryPolicy(test_keys::kKeyDictionary,
377 &policy_dict); 380 &policy_dict);
378 // Install them as 3rd party policies too. 381 // Install them as 3rd party policies too.
379 base::DictionaryValue policy_3rdparty; 382 base::DictionaryValue policy_3rdparty;
380 policy_3rdparty.Set("extensions.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 383 policy_3rdparty.Set("extensions.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
(...skipping 26 matching lines...) Expand all
407 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 410 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
408 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) 411 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
409 .CopyFrom(expected_policy); 412 .CopyFrom(expected_policy);
410 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 413 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
411 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) 414 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))
412 .CopyFrom(expected_policy); 415 .CopyFrom(expected_policy);
413 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); 416 EXPECT_TRUE(provider_->policies().Equals(expected_bundle));
414 } 417 }
415 418
416 } // namespace policy 419 } // namespace policy
OLDNEW
« no previous file with comments | « components/flags_ui/flags_state.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698