| OLD | NEW |
| 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/ptr_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace policy { | 27 namespace policy { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Helper to write a policy in |bundle| with less code. | 31 // Helper to write a policy in |bundle| with less code. |
| 32 void SetPolicy(PolicyBundle* bundle, | 32 void SetPolicy(PolicyBundle* bundle, |
| 33 const std::string& name, | 33 const std::string& name, |
| 34 const std::string& value) { | 34 const std::string& value) { |
| 35 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 35 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
| 36 .Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 36 .Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 37 POLICY_SOURCE_PLATFORM, base::MakeUnique<base::StringValue>(value), | 37 POLICY_SOURCE_PLATFORM, base::MakeUnique<base::Value>(value), |
| 38 nullptr); | 38 nullptr); |
| 39 } | 39 } |
| 40 | 40 |
| 41 class MockPolicyLoader : public AsyncPolicyLoader { | 41 class MockPolicyLoader : public AsyncPolicyLoader { |
| 42 public: | 42 public: |
| 43 explicit MockPolicyLoader( | 43 explicit MockPolicyLoader( |
| 44 scoped_refptr<base::SequencedTaskRunner> task_runner); | 44 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 45 ~MockPolicyLoader() override; | 45 ~MockPolicyLoader() override; |
| 46 | 46 |
| 47 // Load() returns a std::unique_ptr<PolicyBundle> but it can't be mocked | 47 // Load() returns a std::unique_ptr<PolicyBundle> but it can't be mocked |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 219 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
| 220 provider_->Shutdown(); | 220 provider_->Shutdown(); |
| 221 base::RunLoop().RunUntilIdle(); | 221 base::RunLoop().RunUntilIdle(); |
| 222 Mock::VerifyAndClearExpectations(&observer); | 222 Mock::VerifyAndClearExpectations(&observer); |
| 223 | 223 |
| 224 provider_->RemoveObserver(&observer); | 224 provider_->RemoveObserver(&observer); |
| 225 provider_.reset(); | 225 provider_.reset(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace policy | 228 } // namespace policy |
| OLD | NEW |