[email protected] | 4cbb342 | 2012-01-22 16:25:52 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 12a3c02 | 2010-11-03 10:24:11 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "chrome/browser/policy/mock_configuration_policy_provider.h" | ||||
6 | |||||
[email protected] | 4c5656c | 2012-05-15 21:18:05 | [diff] [blame] | 7 | #include <string> |
8 | |||||
9 | #include "base/memory/scoped_ptr.h" | ||||
[email protected] | 6788061 | 2013-08-01 16:19:16 | [diff] [blame] | 10 | #include "base/message_loop/message_loop.h" |
11 | #include "base/run_loop.h" | ||||
[email protected] | 4c5656c | 2012-05-15 21:18:05 | [diff] [blame] | 12 | #include "chrome/browser/policy/policy_bundle.h" |
[email protected] | 12a3c02 | 2010-11-03 10:24:11 | [diff] [blame] | 13 | |
[email protected] | d25da25 | 2013-11-14 01:23:43 | [diff] [blame^] | 14 | using testing::Invoke; |
15 | |||||
[email protected] | 12a3c02 | 2010-11-03 10:24:11 | [diff] [blame] | 16 | namespace policy { |
17 | |||||
[email protected] | e9ad1c3 | 2012-06-07 14:11:01 | [diff] [blame] | 18 | MockConfigurationPolicyProvider::MockConfigurationPolicyProvider() {} |
[email protected] | 12a3c02 | 2010-11-03 10:24:11 | [diff] [blame] | 19 | |
[email protected] | f8636972 | 2011-02-17 13:25:23 | [diff] [blame] | 20 | MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() {} |
[email protected] | 12a3c02 | 2010-11-03 10:24:11 | [diff] [blame] | 21 | |
[email protected] | 4c5656c | 2012-05-15 21:18:05 | [diff] [blame] | 22 | void MockConfigurationPolicyProvider::UpdateChromePolicy( |
23 | const PolicyMap& policy) { | ||||
24 | scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); | ||||
[email protected] | 2ccf8373 | 2013-02-04 20:19:02 | [diff] [blame] | 25 | bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
26 | .CopyFrom(policy); | ||||
[email protected] | 4c5656c | 2012-05-15 21:18:05 | [diff] [blame] | 27 | UpdatePolicy(bundle.Pass()); |
[email protected] | 6788061 | 2013-08-01 16:19:16 | [diff] [blame] | 28 | if (base::MessageLoop::current()) |
29 | base::RunLoop().RunUntilIdle(); | ||||
[email protected] | 4c5656c | 2012-05-15 21:18:05 | [diff] [blame] | 30 | } |
31 | |||||
[email protected] | d25da25 | 2013-11-14 01:23:43 | [diff] [blame^] | 32 | void MockConfigurationPolicyProvider::SetAutoRefresh() { |
33 | EXPECT_CALL(*this, RefreshPolicies()).WillRepeatedly( | ||||
34 | Invoke(this, &MockConfigurationPolicyProvider::RefreshWithSamePolicies)); | ||||
35 | } | ||||
36 | |||||
37 | void MockConfigurationPolicyProvider::RefreshWithSamePolicies() { | ||||
38 | scoped_ptr<PolicyBundle> bundle(new PolicyBundle); | ||||
39 | bundle->CopyFrom(policies()); | ||||
40 | UpdatePolicy(bundle.Pass()); | ||||
41 | } | ||||
42 | |||||
[email protected] | 5fe0458 | 2011-11-21 19:25:57 | [diff] [blame] | 43 | MockConfigurationPolicyObserver::MockConfigurationPolicyObserver() {} |
44 | |||||
45 | MockConfigurationPolicyObserver::~MockConfigurationPolicyObserver() {} | ||||
46 | |||||
[email protected] | f8636972 | 2011-02-17 13:25:23 | [diff] [blame] | 47 | } // namespace policy |