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