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

Side by Side Diff: components/policy/core/common/policy_map_unittest.cc

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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 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/policy_map.h" 5 #include "components/policy/core/common/policy_map.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
9 #include "components/policy/core/common/external_data_manager.h" 10 #include "components/policy/core/common/external_data_manager.h"
10 #include "components/policy/core/common/policy_types.h" 11 #include "components/policy/core/common/policy_types.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace policy { 14 namespace policy {
14 15
15 namespace { 16 namespace {
16 17
17 // Dummy policy names. 18 // Dummy policy names.
(...skipping 16 matching lines...) Expand all
34 const char* name, 35 const char* name,
35 ExternalDataFetcher* external_data_fetcher) { 36 ExternalDataFetcher* external_data_fetcher) {
36 map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 37 map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
37 NULL, external_data_fetcher); 38 NULL, external_data_fetcher);
38 } 39 }
39 40
40 } // namespace 41 } // namespace
41 42
42 class PolicyMapTest : public testing::Test { 43 class PolicyMapTest : public testing::Test {
43 protected: 44 protected:
44 scoped_ptr<ExternalDataFetcher> CreateExternalDataFetcher( 45 std::unique_ptr<ExternalDataFetcher> CreateExternalDataFetcher(
45 const std::string& policy) const; 46 const std::string& policy) const;
46 }; 47 };
47 48
48 scoped_ptr<ExternalDataFetcher> PolicyMapTest::CreateExternalDataFetcher( 49 std::unique_ptr<ExternalDataFetcher> PolicyMapTest::CreateExternalDataFetcher(
49 const std::string& policy) const { 50 const std::string& policy) const {
50 return make_scoped_ptr( 51 return base::WrapUnique(
51 new ExternalDataFetcher(base::WeakPtr<ExternalDataManager>(), policy)); 52 new ExternalDataFetcher(base::WeakPtr<ExternalDataManager>(), policy));
52 } 53 }
53 54
54 TEST_F(PolicyMapTest, SetAndGet) { 55 TEST_F(PolicyMapTest, SetAndGet) {
55 PolicyMap map; 56 PolicyMap map;
56 SetPolicy(&map, kTestPolicyName1, new base::StringValue("aaa")); 57 SetPolicy(&map, kTestPolicyName1, new base::StringValue("aaa"));
57 base::StringValue expected("aaa"); 58 base::StringValue expected("aaa");
58 EXPECT_TRUE(expected.Equals(map.GetValue(kTestPolicyName1))); 59 EXPECT_TRUE(expected.Equals(map.GetValue(kTestPolicyName1)));
59 SetPolicy(&map, kTestPolicyName1, new base::StringValue("bbb")); 60 SetPolicy(&map, kTestPolicyName1, new base::StringValue("bbb"));
60 base::StringValue expected_b("bbb"); 61 base::StringValue expected_b("bbb");
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 expected.Set("TestPolicy3", 418 expected.Set("TestPolicy3",
418 POLICY_LEVEL_MANDATORY, 419 POLICY_LEVEL_MANDATORY,
419 POLICY_SCOPE_USER, 420 POLICY_SCOPE_USER,
420 POLICY_SOURCE_PLATFORM, 421 POLICY_SOURCE_PLATFORM,
421 new base::FundamentalValue(-12321), 422 new base::FundamentalValue(-12321),
422 nullptr); 423 nullptr);
423 EXPECT_TRUE(loaded.Equals(expected)); 424 EXPECT_TRUE(loaded.Equals(expected));
424 } 425 }
425 426
426 } // namespace policy 427 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_map.cc ('k') | components/policy/core/common/policy_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698