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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_manager_unittest.cc

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: Fixed mac tests Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cloud_policy_manager.h" 5 #include "chrome/browser/policy/cloud/cloud_policy_manager.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 class TestHarness : public PolicyProviderTestHarness { 30 class TestHarness : public PolicyProviderTestHarness {
31 public: 31 public:
32 explicit TestHarness(PolicyLevel level); 32 explicit TestHarness(PolicyLevel level);
33 virtual ~TestHarness(); 33 virtual ~TestHarness();
34 34
35 virtual void SetUp() OVERRIDE; 35 virtual void SetUp() OVERRIDE;
36 36
37 virtual ConfigurationPolicyProvider* CreateProvider( 37 virtual ConfigurationPolicyProvider* CreateProvider(
38 SchemaRegistry* registry,
38 scoped_refptr<base::SequencedTaskRunner> task_runner, 39 scoped_refptr<base::SequencedTaskRunner> task_runner,
39 const PolicyDefinitionList* policy_definition_list) OVERRIDE; 40 const PolicyDefinitionList* policy_definition_list) OVERRIDE;
40 41
41 virtual void InstallEmptyPolicy() OVERRIDE; 42 virtual void InstallEmptyPolicy() OVERRIDE;
42 virtual void InstallStringPolicy(const std::string& policy_name, 43 virtual void InstallStringPolicy(const std::string& policy_name,
43 const std::string& policy_value) OVERRIDE; 44 const std::string& policy_value) OVERRIDE;
44 virtual void InstallIntegerPolicy(const std::string& policy_name, 45 virtual void InstallIntegerPolicy(const std::string& policy_name,
45 int policy_value) OVERRIDE; 46 int policy_value) OVERRIDE;
46 virtual void InstallBooleanPolicy(const std::string& policy_name, 47 virtual void InstallBooleanPolicy(const std::string& policy_name,
47 bool policy_value) OVERRIDE; 48 bool policy_value) OVERRIDE;
(...skipping 15 matching lines...) Expand all
63 }; 64 };
64 65
65 TestHarness::TestHarness(PolicyLevel level) 66 TestHarness::TestHarness(PolicyLevel level)
66 : PolicyProviderTestHarness(level, POLICY_SCOPE_USER) {} 67 : PolicyProviderTestHarness(level, POLICY_SCOPE_USER) {}
67 68
68 TestHarness::~TestHarness() {} 69 TestHarness::~TestHarness() {}
69 70
70 void TestHarness::SetUp() {} 71 void TestHarness::SetUp() {}
71 72
72 ConfigurationPolicyProvider* TestHarness::CreateProvider( 73 ConfigurationPolicyProvider* TestHarness::CreateProvider(
74 SchemaRegistry* registry,
73 scoped_refptr<base::SequencedTaskRunner> task_runner, 75 scoped_refptr<base::SequencedTaskRunner> task_runner,
74 const PolicyDefinitionList* policy_definition_list) { 76 const PolicyDefinitionList* policy_definition_list) {
75 // Create and initialize the store. 77 // Create and initialize the store.
76 store_.NotifyStoreLoaded(); 78 store_.NotifyStoreLoaded();
77 ConfigurationPolicyProvider* provider = new CloudPolicyManager( 79 ConfigurationPolicyProvider* provider = new CloudPolicyManager(
78 PolicyNamespaceKey(dm_protocol::kChromeUserPolicyType, std::string()), 80 PolicyNamespaceKey(dm_protocol::kChromeUserPolicyType, std::string()),
79 &store_, 81 &store_,
80 task_runner); 82 task_runner);
81 Mock::VerifyAndClearExpectations(&store_); 83 Mock::VerifyAndClearExpectations(&store_);
82 return provider; 84 return provider;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 base::Value::CreateStringValue("value"), NULL); 171 base::Value::CreateStringValue("value"), NULL);
170 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 172 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
171 .CopyFrom(policy_map_); 173 .CopyFrom(policy_map_);
172 174
173 policy_.payload().mutable_passwordmanagerenabled()->set_value(false); 175 policy_.payload().mutable_passwordmanagerenabled()->set_value(false);
174 policy_.Build(); 176 policy_.Build();
175 177
176 EXPECT_CALL(store_, Load()); 178 EXPECT_CALL(store_, Load());
177 manager_.reset(new TestCloudPolicyManager(&store_, 179 manager_.reset(new TestCloudPolicyManager(&store_,
178 loop_.message_loop_proxy())); 180 loop_.message_loop_proxy()));
179 manager_->Init(); 181 manager_->Init(&schema_registry_);
180 Mock::VerifyAndClearExpectations(&store_); 182 Mock::VerifyAndClearExpectations(&store_);
181 manager_->AddObserver(&observer_); 183 manager_->AddObserver(&observer_);
182 } 184 }
183 185
184 virtual void TearDown() OVERRIDE { 186 virtual void TearDown() OVERRIDE {
185 manager_->RemoveObserver(&observer_); 187 manager_->RemoveObserver(&observer_);
186 manager_->Shutdown(); 188 manager_->Shutdown();
187 } 189 }
188 190
189 // Required by the refresh scheduler that's created by the manager. 191 // Required by the refresh scheduler that's created by the manager.
190 base::MessageLoop loop_; 192 base::MessageLoop loop_;
191 193
192 // Testing policy. 194 // Testing policy.
193 const PolicyNamespaceKey policy_ns_key_; 195 const PolicyNamespaceKey policy_ns_key_;
194 UserPolicyBuilder policy_; 196 UserPolicyBuilder policy_;
195 PolicyMap policy_map_; 197 PolicyMap policy_map_;
196 PolicyBundle expected_bundle_; 198 PolicyBundle expected_bundle_;
197 199
198 // Policy infrastructure. 200 // Policy infrastructure.
201 SchemaRegistry schema_registry_;
bartfab (slow) 2013/11/05 15:53:04 #include "chrome/browser/policy/schema_registry.h"
Joao da Silva 2013/11/07 13:15:00 Done.
199 MockConfigurationPolicyObserver observer_; 202 MockConfigurationPolicyObserver observer_;
200 MockCloudPolicyStore store_; 203 MockCloudPolicyStore store_;
201 scoped_ptr<TestCloudPolicyManager> manager_; 204 scoped_ptr<TestCloudPolicyManager> manager_;
202 205
203 private: 206 private:
204 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManagerTest); 207 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManagerTest);
205 }; 208 };
206 209
207 TEST_F(CloudPolicyManagerTest, InitAndShutdown) { 210 TEST_F(CloudPolicyManagerTest, InitAndShutdown) {
208 PolicyBundle empty_bundle; 211 PolicyBundle empty_bundle;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 store_.policy_.reset(new em::PolicyData(policy_.policy_data())); 342 store_.policy_.reset(new em::PolicyData(policy_.policy_data()));
340 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())); 343 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
341 store_.NotifyStoreError(); 344 store_.NotifyStoreError();
342 Mock::VerifyAndClearExpectations(&observer_); 345 Mock::VerifyAndClearExpectations(&observer_);
343 346
344 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); 347 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
345 } 348 }
346 349
347 } // namespace 350 } // namespace
348 } // namespace policy 351 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698