Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | 11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
| 12 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | |
| 13 #include "chrome/browser/policy/configuration_policy_pref_store.h" | |
|
Mattias Nissler (ping if slow)
2011/06/24 09:16:46
are these includes needed?
gfeher
2011/06/24 15:32:44
Done.
| |
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 ((TestingBrowserProcess*) g_browser_process)->SetLocalState(NULL); | 145 ((TestingBrowserProcess*) g_browser_process)->SetLocalState(NULL); |
| 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 const PolicyMap* policy_map = cache_->policy( |
| 154 EXPECT_CALL(store, Apply(_, _)).Times(AtLeast(1)); | 156 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY); |
| 155 cache_->GetManagedPolicyProvider()->Provide(&store); | 157 ASSERT_TRUE(Value::Equals(expected, policy_map->Get(type))); |
| 156 ASSERT_TRUE(Value::Equals(expected, store.Get(type))); | |
| 157 } | 158 } |
| 158 | 159 |
| 159 // Verifies that the last recorded run of the subsystem did not issue | 160 // Verifies that the last recorded run of the subsystem did not issue |
| 160 // too frequent requests: | 161 // too frequent requests: |
| 161 // - no more than 10 requests in the first 10 minutes | 162 // - no more than 10 requests in the first 10 minutes |
| 162 // - no more then 12 requests per hour in the next 10 hours | 163 // - no more then 12 requests per hour in the next 10 hours |
| 163 // TODO(gfeher): Thighten these conditions further. This will require | 164 // TODO(gfeher): Thighten these conditions further. This will require |
| 164 // fine-tuning of the subsystem. See: http://crosbug.com/15195 | 165 // fine-tuning of the subsystem. See: http://crosbug.com/15195 |
| 165 void VerifyServerLoad() { | 166 void VerifyServerLoad() { |
| 166 std::vector<int64> events; | 167 std::vector<int64> events; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 EXPECT_CALL(*(factory_.get()), Intercept(kGaiaAuthHeader, "register", _)). | 296 EXPECT_CALL(*(factory_.get()), Intercept(kGaiaAuthHeader, "register", _)). |
| 296 WillOnce(CreateSuccessfulRegisterResponse(kDMToken)); | 297 WillOnce(CreateSuccessfulRegisterResponse(kDMToken)); |
| 297 | 298 |
| 298 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)). | 299 EXPECT_CALL(*(factory_.get()), Intercept(kDMAuthHeader, "policy", _)). |
| 299 WillOnce(CreateSuccessfulPolicyResponse("http://www.example.com")); | 300 WillOnce(CreateSuccessfulPolicyResponse("http://www.example.com")); |
| 300 | 301 |
| 301 ExecuteTest("http://www.example.com"); | 302 ExecuteTest("http://www.example.com"); |
| 302 } | 303 } |
| 303 | 304 |
| 304 } // policy | 305 } // policy |
| OLD | NEW |