Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/policy/cloud_policy_provider_unittest.cc

Issue 8258018: Generate Chrome policy definition list from policy_templates.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the unittest fix Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/policy/cloud_policy_cache_base.h" 9 #include "chrome/browser/policy/cloud_policy_cache_base.h"
10 #include "chrome/browser/policy/cloud_policy_provider_impl.h" 10 #include "chrome/browser/policy/cloud_policy_provider_impl.h"
11 #include "chrome/browser/policy/configuration_policy_pref_store.h" 11 #include "chrome/browser/policy/configuration_policy_pref_store.h"
12 #include "policy/policy_constants.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 14
14 using testing::AnyNumber; 15 using testing::AnyNumber;
15 using testing::_; 16 using testing::_;
16 17
17 namespace policy { 18 namespace policy {
18 19
19 class MockCloudPolicyCache : public CloudPolicyCacheBase { 20 class MockCloudPolicyCache : public CloudPolicyCacheBase {
20 public: 21 public:
21 MockCloudPolicyCache() {} 22 MockCloudPolicyCache() {}
(...skipping 29 matching lines...) Expand all
51 } 52 }
52 53
53 private: 54 private:
54 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyCache); 55 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyCache);
55 }; 56 };
56 57
57 class CloudPolicyProviderTest : public testing::Test { 58 class CloudPolicyProviderTest : public testing::Test {
58 protected: 59 protected:
59 void CreateCloudPolicyProvider(CloudPolicyCacheBase::PolicyLevel level) { 60 void CreateCloudPolicyProvider(CloudPolicyCacheBase::PolicyLevel level) {
60 cloud_policy_provider_.reset(new CloudPolicyProviderImpl( 61 cloud_policy_provider_.reset(new CloudPolicyProviderImpl(
61 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), level)); 62 GetChromePolicyDefinitionList(), level));
62 } 63 }
63 64
64 // Appends the caches to a provider and then provides the policies to 65 // Appends the caches to a provider and then provides the policies to
65 // |policy_map_|. 66 // |policy_map_|.
66 void RunCachesThroughProvider(MockCloudPolicyCache caches[], int n, 67 void RunCachesThroughProvider(MockCloudPolicyCache caches[], int n,
67 CloudPolicyCacheBase::PolicyLevel level) { 68 CloudPolicyCacheBase::PolicyLevel level) {
68 CloudPolicyProviderImpl provider( 69 CloudPolicyProviderImpl provider(
69 policy::ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), 70 GetChromePolicyDefinitionList(),
70 level); 71 level);
71 for (int i = 0; i < n; i++) { 72 for (int i = 0; i < n; i++) {
72 provider.AppendCache(&caches[i]); 73 provider.AppendCache(&caches[i]);
73 } 74 }
74 policy_map_.reset(new PolicyMap()); 75 policy_map_.reset(new PolicyMap());
75 provider.Provide(policy_map_.get()); 76 provider.Provide(policy_map_.get());
76 } 77 }
77 78
78 // Checks a string policy in |policy_map_|. 79 // Checks a string policy in |policy_map_|.
79 void ExpectStringPolicy(const std::string& expected, 80 void ExpectStringPolicy(const std::string& expected,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 EXPECT_TRUE(value->GetAsInteger(&int_value)); 216 EXPECT_TRUE(value->GetAsInteger(&int_value));
216 EXPECT_EQ(100, int_value); 217 EXPECT_EQ(100, int_value);
217 } 218 }
218 219
219 TEST_F(CloudPolicyProviderTest, CombineTwoPolicyMapsProxies) { 220 TEST_F(CloudPolicyProviderTest, CombineTwoPolicyMapsProxies) {
220 const int a_value = 1; 221 const int a_value = 1;
221 const int b_value = -1; 222 const int b_value = -1;
222 PolicyMap A, B, C; 223 PolicyMap A, B, C;
223 CreateCloudPolicyProvider(CloudPolicyCacheBase::POLICY_LEVEL_RECOMMENDED); 224 CreateCloudPolicyProvider(CloudPolicyCacheBase::POLICY_LEVEL_RECOMMENDED);
224 225
225 A.Set(policy::kPolicyProxyMode, Value::CreateIntegerValue(a_value)); 226 A.Set(kPolicyProxyMode, Value::CreateIntegerValue(a_value));
226 227
227 B.Set(policy::kPolicyProxyServerMode, Value::CreateIntegerValue(b_value)); 228 B.Set(kPolicyProxyServerMode, Value::CreateIntegerValue(b_value));
228 B.Set(policy::kPolicyProxyServer, Value::CreateIntegerValue(b_value)); 229 B.Set(kPolicyProxyServer, Value::CreateIntegerValue(b_value));
229 B.Set(policy::kPolicyProxyPacUrl, Value::CreateIntegerValue(b_value)); 230 B.Set(kPolicyProxyPacUrl, Value::CreateIntegerValue(b_value));
230 B.Set(policy::kPolicyProxyBypassList, Value::CreateIntegerValue(b_value)); 231 B.Set(kPolicyProxyBypassList, Value::CreateIntegerValue(b_value));
231 232
232 CombineTwoPolicyMaps(A, B, &C); 233 CombineTwoPolicyMaps(A, B, &C);
233 234
234 EXPECT_TRUE(A.Equals(C)); 235 EXPECT_TRUE(A.Equals(C));
235 EXPECT_FALSE(B.Equals(C)); 236 EXPECT_FALSE(B.Equals(C));
236 } 237 }
237 238
238 } // namespace policy 239 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_provider_impl.cc ('k') | chrome/browser/policy/config_dir_policy_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698