OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/policy/mock_configuration_policy_store.h" | 5 #include "chrome/browser/policy/mock_configuration_policy_store.h" |
6 | 6 |
7 namespace policy { | 7 namespace policy { |
8 | 8 |
9 using ::testing::_; | 9 using ::testing::_; |
10 using ::testing::Invoke; | 10 using ::testing::Invoke; |
11 | 11 |
12 MockConfigurationPolicyStore::MockConfigurationPolicyStore() { | 12 MockConfigurationPolicyStore::MockConfigurationPolicyStore() { |
13 ON_CALL(*this, Apply(_, _)).WillByDefault( | 13 ON_CALL(*this, Apply(_, _)).WillByDefault( |
14 Invoke(this, &MockConfigurationPolicyStore::ApplyToMap)); | 14 Invoke(this, &MockConfigurationPolicyStore::ApplyToMap)); |
15 } | 15 } |
16 | 16 |
17 MockConfigurationPolicyStore::~MockConfigurationPolicyStore() { | 17 MockConfigurationPolicyStore::~MockConfigurationPolicyStore() {} |
18 STLDeleteValues(&policy_map_); | |
19 } | |
20 | 18 |
21 const Value* MockConfigurationPolicyStore::Get( | 19 const Value* MockConfigurationPolicyStore::Get( |
22 ConfigurationPolicyType type) const { | 20 ConfigurationPolicyType type) const { |
23 PolicyMap::const_iterator entry(policy_map_.find(type)); | 21 return policy_map_.Get(type); |
24 return entry == policy_map_.end() ? NULL : entry->second; | |
25 } | 22 } |
26 | 23 |
27 void MockConfigurationPolicyStore::ApplyToMap( | 24 void MockConfigurationPolicyStore::ApplyToMap( |
28 ConfigurationPolicyType policy, Value* value) { | 25 ConfigurationPolicyType policy, Value* value) { |
29 std::swap(policy_map_[policy], value); | 26 policy_map_.Set(policy, value); |
30 delete value; | |
31 } | 27 } |
32 | 28 |
33 } // namespace policy | 29 } // namespace policy |
OLD | NEW |