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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simpler AsyncLoader, fixed unit_tests, added connector::RefreshPolicies Created 9 years, 1 month 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/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
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 14:49:32 I see. Globals suck though, your call.
Joao da Silva 2011/11/18 15:39:18 Removed the static-ness out of BrowserPolicyConnec
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698