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 <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" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 void ExpectSuccessfulPolicy(int n, const std::string& homepage) { | 237 void ExpectSuccessfulPolicy(int n, const std::string& homepage) { |
238 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)) | 238 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)) |
239 .Times(n) | 239 .Times(n) |
240 .WillRepeatedly(CreateSuccessfulPolicyResponse(homepage)); | 240 .WillRepeatedly(CreateSuccessfulPolicyResponse(homepage)); |
241 } | 241 } |
242 | 242 |
243 private: | 243 private: |
244 // Verifies for a given policy that it is provided by the subsystem. | 244 // Verifies for a given policy that it is provided by the subsystem. |
245 void VerifyPolicy(enum ConfigurationPolicyType type, Value* expected) { | 245 void VerifyPolicy(enum ConfigurationPolicyType type, Value* expected) { |
246 MockConfigurationPolicyStore store; | 246 const PolicyMap* policy_map = cache_->policy( |
247 EXPECT_CALL(store, Apply(_, _)).Times(AtLeast(1)); | 247 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY); |
248 cache_->GetManagedPolicyProvider()->Provide(&store); | 248 ASSERT_TRUE(Value::Equals(expected, policy_map->Get(type))); |
249 ASSERT_TRUE(Value::Equals(expected, store.Get(type))); | |
250 } | 249 } |
251 | 250 |
252 // Verifies that the last recorded run of the subsystem did not issue | 251 // Verifies that the last recorded run of the subsystem did not issue |
253 // too frequent requests: | 252 // too frequent requests: |
254 // - no more than 10 requests in the first 10 minutes | 253 // - no more than 10 requests in the first 10 minutes |
255 // - no more then 12 requests per hour in the next 10 hours | 254 // - no more then 12 requests per hour in the next 10 hours |
256 // TODO(gfeher): Thighten these conditions further. This will require | 255 // TODO(gfeher): Thighten these conditions further. This will require |
257 // fine-tuning of the subsystem. See: http://crosbug.com/16637 | 256 // fine-tuning of the subsystem. See: http://crosbug.com/16637 |
258 void VerifyServerLoad() { | 257 void VerifyServerLoad() { |
259 std::vector<int64> events; | 258 std::vector<int64> events; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 ExecuteTest(); | 435 ExecuteTest(); |
437 VerifyTest("http://www.youtube.com"); | 436 VerifyTest("http://www.youtube.com"); |
438 } | 437 } |
439 | 438 |
440 INSTANTIATE_TEST_CASE_P( | 439 INSTANTIATE_TEST_CASE_P( |
441 CloudPolicySubsystemPolicyReregisterTestInstance, | 440 CloudPolicySubsystemPolicyReregisterTestInstance, |
442 CloudPolicySubsystemPolicyReregisterTest, | 441 CloudPolicySubsystemPolicyReregisterTest, |
443 testing::Values(401, 403, 410)); | 442 testing::Values(401, 403, 410)); |
444 | 443 |
445 } // policy | 444 } // policy |
OLD | NEW |