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

Side by Side Diff: components/policy/core/common/async_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 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/async_policy_provider.h" 5 #include "components/policy/core/common/async_policy_provider.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "components/policy/core/common/async_policy_loader.h" 14 #include "components/policy/core/common/async_policy_loader.h"
14 #include "components/policy/core/common/external_data_fetcher.h" 15 #include "components/policy/core/common/external_data_fetcher.h"
15 #include "components/policy/core/common/mock_configuration_policy_provider.h" 16 #include "components/policy/core/common/mock_configuration_policy_provider.h"
16 #include "components/policy/core/common/policy_types.h" 17 #include "components/policy/core/common/policy_types.h"
17 #include "components/policy/core/common/schema_registry.h" 18 #include "components/policy/core/common/schema_registry.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using testing::Mock; 22 using testing::Mock;
22 using testing::Return; 23 using testing::Return;
23 using testing::Sequence; 24 using testing::Sequence;
24 25
25 namespace policy { 26 namespace policy {
26 27
27 namespace { 28 namespace {
28 29
29 // Helper to write a policy in |bundle| with less code. 30 // Helper to write a policy in |bundle| with less code.
30 void SetPolicy(PolicyBundle* bundle, 31 void SetPolicy(PolicyBundle* bundle,
31 const std::string& name, 32 const std::string& name,
32 const std::string& value) { 33 const std::string& value) {
33 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 34 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
34 .Set(name, 35 .Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
35 POLICY_LEVEL_MANDATORY,
36 POLICY_SCOPE_USER,
37 POLICY_SOURCE_PLATFORM, 36 POLICY_SOURCE_PLATFORM,
38 new base::StringValue(value), 37 base::WrapUnique(new base::StringValue(value)), nullptr);
39 NULL);
40 } 38 }
41 39
42 class MockPolicyLoader : public AsyncPolicyLoader { 40 class MockPolicyLoader : public AsyncPolicyLoader {
43 public: 41 public:
44 explicit MockPolicyLoader( 42 explicit MockPolicyLoader(
45 scoped_refptr<base::SequencedTaskRunner> task_runner); 43 scoped_refptr<base::SequencedTaskRunner> task_runner);
46 ~MockPolicyLoader() override; 44 ~MockPolicyLoader() override;
47 45
48 // Load() returns a std::unique_ptr<PolicyBundle> but it can't be mocked 46 // Load() returns a std::unique_ptr<PolicyBundle> but it can't be mocked
49 // because std::unique_ptr is moveable but not copyable. This override 47 // because std::unique_ptr is moveable but not copyable. This override
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); 218 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0);
221 provider_->Shutdown(); 219 provider_->Shutdown();
222 loop_.RunUntilIdle(); 220 loop_.RunUntilIdle();
223 Mock::VerifyAndClearExpectations(&observer); 221 Mock::VerifyAndClearExpectations(&observer);
224 222
225 provider_->RemoveObserver(&observer); 223 provider_->RemoveObserver(&observer);
226 provider_.reset(); 224 provider_.reset();
227 } 225 }
228 226
229 } // namespace policy 227 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698