Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cloud_policy_provider.h" | 5 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browser_process.h" | |
| 9 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 10 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 10 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | 11 #include "chrome/browser/policy/cloud_policy_provider_impl.h" |
| 11 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 12 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 12 #include "policy/policy_constants.h" | 13 #include "policy/policy_constants.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 14 | 15 |
| 15 using testing::AnyNumber; | 16 using testing::AnyNumber; |
| 16 using testing::_; | 17 using testing::_; |
| 17 | 18 |
| 18 namespace policy { | 19 namespace policy { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 40 } | 41 } |
| 41 | 42 |
| 42 PolicyMap* raw_recommended_policy() { | 43 PolicyMap* raw_recommended_policy() { |
| 43 return &recommended_policy_; | 44 return &recommended_policy_; |
| 44 } | 45 } |
| 45 | 46 |
| 46 void SetUnmanaged() { | 47 void SetUnmanaged() { |
| 47 is_unmanaged_ = true; | 48 is_unmanaged_ = true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void SetFetchingDone() { | |
| 51 // Implement pure virtual method. | |
| 52 } | |
| 53 | |
| 54 void set_initialized(bool initialized) { | 51 void set_initialized(bool initialized) { |
| 55 initialization_complete_ = initialized; | 52 initialization_complete_ = initialized; |
| 56 } | 53 } |
| 57 | 54 |
| 58 private: | 55 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyCache); | 56 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyCache); |
| 60 }; | 57 }; |
| 61 | 58 |
| 62 class CloudPolicyProviderTest : public testing::Test { | 59 class CloudPolicyProviderTest : public testing::Test { |
| 63 protected: | 60 protected: |
| 64 void CreateCloudPolicyProvider(CloudPolicyCacheBase::PolicyLevel level) { | 61 void CreateCloudPolicyProvider(CloudPolicyCacheBase::PolicyLevel level) { |
| 65 cloud_policy_provider_.reset(new CloudPolicyProviderImpl( | 62 cloud_policy_provider_.reset( |
| 66 GetChromePolicyDefinitionList(), level)); | 63 new CloudPolicyProviderImpl( |
| 64 g_browser_process->browser_policy_connector(), | |
|
Mattias Nissler (ping if slow)
2011/11/18 11:00:25
shouldn't we rather mock that thing?
Joao da Silva
2011/11/18 14:03:30
It is "mocked" in unit_tests (as in, it has no pro
| |
| 65 GetChromePolicyDefinitionList(), | |
| 66 level)); | |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Appends the caches to a provider and then provides the policies to | 69 // Appends the caches to a provider and then provides the policies to |
| 70 // |policy_map_|. | 70 // |policy_map_|. |
| 71 void RunCachesThroughProvider(MockCloudPolicyCache caches[], int n, | 71 void RunCachesThroughProvider(MockCloudPolicyCache caches[], int n, |
| 72 CloudPolicyCacheBase::PolicyLevel level) { | 72 CloudPolicyCacheBase::PolicyLevel level) { |
| 73 CloudPolicyProviderImpl provider( | 73 CloudPolicyProviderImpl provider( |
| 74 g_browser_process->browser_policy_connector(), | |
| 74 GetChromePolicyDefinitionList(), | 75 GetChromePolicyDefinitionList(), |
| 75 level); | 76 level); |
| 76 for (int i = 0; i < n; i++) { | 77 for (int i = 0; i < n; i++) { |
| 77 provider.AppendCache(&caches[i]); | 78 provider.AppendCache(&caches[i]); |
| 78 } | 79 } |
| 79 policy_map_.reset(new PolicyMap()); | 80 policy_map_.reset(new PolicyMap()); |
| 80 provider.Provide(policy_map_.get()); | 81 provider.Provide(policy_map_.get()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 // Checks a string policy in |policy_map_|. | 84 // Checks a string policy in |policy_map_|. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 B.Set(kPolicyProxyPacUrl, Value::CreateIntegerValue(b_value)); | 235 B.Set(kPolicyProxyPacUrl, Value::CreateIntegerValue(b_value)); |
| 235 B.Set(kPolicyProxyBypassList, Value::CreateIntegerValue(b_value)); | 236 B.Set(kPolicyProxyBypassList, Value::CreateIntegerValue(b_value)); |
| 236 | 237 |
| 237 CombineTwoPolicyMaps(A, B, &C); | 238 CombineTwoPolicyMaps(A, B, &C); |
| 238 | 239 |
| 239 EXPECT_TRUE(A.Equals(C)); | 240 EXPECT_TRUE(A.Equals(C)); |
| 240 EXPECT_FALSE(B.Equals(C)); | 241 EXPECT_FALSE(B.Equals(C)); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace policy | 244 } // namespace policy |
| OLD | NEW |