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

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

Issue 7147015: Move user cloud policy to BrowserProcess (was 6979011) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cut a circular startup dependency Created 9 years, 6 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 <vector> 5 #include <vector>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/policy/configuration_policy_pref_store.h"
Joao da Silva 2011/06/22 12:51:30 Nit: header order
gfeher 2011/06/22 19:18:34 Done.
11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" 12 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
13 #include "chrome/browser/policy/cloud_policy_provider_impl.h"
12 #include "chrome/browser/policy/logging_work_scheduler.h" 14 #include "chrome/browser/policy/logging_work_scheduler.h"
13 #include "chrome/browser/policy/mock_configuration_policy_store.h" 15 #include "chrome/browser/policy/mock_configuration_policy_store.h"
14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" 16 #include "chrome/browser/policy/proto/cloud_policy.pb.h"
15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 17 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
16 #include "chrome/browser/policy/testing_cloud_policy_subsystem.h" 18 #include "chrome/browser/policy/testing_cloud_policy_subsystem.h"
17 #include "chrome/browser/policy/testing_policy_url_fetcher_factory.h" 19 #include "chrome/browser/policy/testing_policy_url_fetcher_factory.h"
18 #include "chrome/browser/policy/user_policy_cache.h" 20 #include "chrome/browser/policy/user_policy_cache.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
20 #include "chrome/test/testing_browser_process.h" 22 #include "chrome/test/testing_browser_process.h"
21 #include "chrome/test/testing_pref_service.h" 23 #include "chrome/test/testing_pref_service.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 cloud_policy_subsystem_->Shutdown(); 146 cloud_policy_subsystem_->Shutdown();
145 cloud_policy_subsystem_.reset(); 147 cloud_policy_subsystem_.reset();
146 factory_.reset(); 148 factory_.reset();
147 logger_.reset(); 149 logger_.reset();
148 prefs_.reset(); 150 prefs_.reset();
149 } 151 }
150 152
151 // Verifies for a given policy that it is provided by the subsystem. 153 // Verifies for a given policy that it is provided by the subsystem.
152 void VerifyPolicy(enum ConfigurationPolicyType type, Value* expected) { 154 void VerifyPolicy(enum ConfigurationPolicyType type, Value* expected) {
153 MockConfigurationPolicyStore store; 155 MockConfigurationPolicyStore store;
156 CloudPolicyProviderImpl provider(
157 policy::ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
158 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY);
159 provider.AppendCache(cache_);
154 EXPECT_CALL(store, Apply(_, _)).Times(AtLeast(1)); 160 EXPECT_CALL(store, Apply(_, _)).Times(AtLeast(1));
155 cache_->GetManagedPolicyProvider()->Provide(&store); 161 provider.Provide(&store);
Mattias Nissler (ping if slow) 2011/06/21 20:09:56 can't you just get the policy map from the cache a
gfeher 2011/06/22 19:18:34 Done.
156 ASSERT_TRUE(Value::Equals(expected, store.Get(type))); 162 ASSERT_TRUE(Value::Equals(expected, store.Get(type)));
157 } 163 }
158 164
159 // Verifies that the last recorded run of the subsystem did not issue 165 // Verifies that the last recorded run of the subsystem did not issue
160 // too frequent requests: 166 // too frequent requests:
161 // - no more than 10 requests in the first 10 minutes 167 // - no more than 10 requests in the first 10 minutes
162 // - no more then 12 requests per hour in the next 10 hours 168 // - no more then 12 requests per hour in the next 10 hours
163 // TODO(gfeher): Thighten these conditions further. This will require 169 // TODO(gfeher): Thighten these conditions further. This will require
164 // fine-tuning of the subsystem. See: http://crosbug.com/15195 170 // fine-tuning of the subsystem. See: http://crosbug.com/15195
165 void VerifyServerLoad() { 171 void VerifyServerLoad() {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_CALL(*(factory_.get()), Intercept(kGaiaAuthHeader, "register", _)). 301 EXPECT_CALL(*(factory_.get()), Intercept(kGaiaAuthHeader, "register", _)).
296 WillOnce(CreateSuccessfulRegisterResponse(kDMToken)); 302 WillOnce(CreateSuccessfulRegisterResponse(kDMToken));
297 303
298 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)). 304 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)).
299 WillOnce(CreateSuccessfulPolicyResponse("http://www.example.com")); 305 WillOnce(CreateSuccessfulPolicyResponse("http://www.example.com"));
300 306
301 ExecuteTest("http://www.example.com"); 307 ExecuteTest("http://www.example.com");
302 } 308 }
303 309
304 } // policy 310 } // policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698