| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 recommended_reader_->OnUpdatePolicy(); | 142 recommended_reader_->OnUpdatePolicy(); |
| 143 dict->SetString("level", | 143 dict->SetString("level", |
| 144 PolicyStatusInfo::GetPolicyLevelString(PolicyStatusInfo::RECOMMENDED)); | 144 PolicyStatusInfo::GetPolicyLevelString(PolicyStatusInfo::RECOMMENDED)); |
| 145 result.reset(recommended_reader_->GetPolicyStatus(kPolicyRestoreOnStartup)); | 145 result.reset(recommended_reader_->GetPolicyStatus(kPolicyRestoreOnStartup)); |
| 146 EXPECT_TRUE(dict->Equals(result.get())); | 146 EXPECT_TRUE(dict->Equals(result.get())); |
| 147 } | 147 } |
| 148 | 148 |
| 149 class PolicyStatusTest : public testing::Test { | 149 class PolicyStatusTest : public testing::Test { |
| 150 protected: | 150 protected: |
| 151 typedef ConfigurationPolicyProvider::PolicyDefinitionList | |
| 152 PolicyDefinitionList; | |
| 153 | |
| 154 PolicyStatusTest() { | 151 PolicyStatusTest() { |
| 155 managed_platform_ = new MockConfigurationPolicyReader(); | 152 managed_platform_ = new MockConfigurationPolicyReader(); |
| 156 managed_cloud_ = new MockConfigurationPolicyReader(); | 153 managed_cloud_ = new MockConfigurationPolicyReader(); |
| 157 recommended_platform_ = new MockConfigurationPolicyReader(); | 154 recommended_platform_ = new MockConfigurationPolicyReader(); |
| 158 recommended_cloud_ = new MockConfigurationPolicyReader(); | 155 recommended_cloud_ = new MockConfigurationPolicyReader(); |
| 159 | 156 |
| 160 policy_status_.reset(new PolicyStatus(managed_platform_, | 157 policy_status_.reset(new PolicyStatus(managed_platform_, |
| 161 managed_cloud_, | 158 managed_cloud_, |
| 162 recommended_platform_, | 159 recommended_platform_, |
| 163 recommended_cloud_)); | 160 recommended_cloud_)); |
| 164 status_ok_ = ASCIIToUTF16("ok"); | 161 status_ok_ = ASCIIToUTF16("ok"); |
| 165 | 162 |
| 166 policy_list_ = | 163 policy_list_ = GetChromePolicyDefinitionList(); |
| 167 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); | |
| 168 policy_list_size_ = | 164 policy_list_size_ = |
| 169 static_cast<size_t>(policy_list_->end - policy_list_->begin); | 165 static_cast<size_t>(policy_list_->end - policy_list_->begin); |
| 170 } | 166 } |
| 171 | 167 |
| 172 void DontSendPolicies() { | 168 void DontSendPolicies() { |
| 173 EXPECT_CALL(*managed_platform_, GetPolicyStatus(_)) | 169 EXPECT_CALL(*managed_platform_, GetPolicyStatus(_)) |
| 174 .WillRepeatedly(ReturnNull()); | 170 .WillRepeatedly(ReturnNull()); |
| 175 EXPECT_CALL(*managed_cloud_, GetPolicyStatus(_)) | 171 EXPECT_CALL(*managed_cloud_, GetPolicyStatus(_)) |
| 176 .WillRepeatedly(ReturnNull()); | 172 .WillRepeatedly(ReturnNull()); |
| 177 EXPECT_CALL(*recommended_platform_, GetPolicyStatus(_)) | 173 EXPECT_CALL(*recommended_platform_, GetPolicyStatus(_)) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 SetDictionaryPaths(undefined_dict.get(), | 336 SetDictionaryPaths(undefined_dict.get(), |
| 341 entry->name, | 337 entry->name, |
| 342 false, | 338 false, |
| 343 PolicyStatusInfo::LEVEL_UNDEFINED); | 339 PolicyStatusInfo::LEVEL_UNDEFINED); |
| 344 EXPECT_TRUE(undefined_dict->Equals(status_dict)); | 340 EXPECT_TRUE(undefined_dict->Equals(status_dict)); |
| 345 break; | 341 break; |
| 346 } | 342 } |
| 347 } | 343 } |
| 348 } | 344 } |
| 349 | 345 |
| 350 TEST_F(PolicyStatusTest, GetPolicyName) { | |
| 351 for (const PolicyDefinitionList::Entry* entry = policy_list_->begin; | |
| 352 entry != policy_list_->end; ++entry) { | |
| 353 EXPECT_EQ(ASCIIToUTF16(entry->name), | |
| 354 PolicyStatus::GetPolicyName(entry->policy_type)); | |
| 355 } | |
| 356 } | |
| 357 | |
| 358 } // namespace policy | 346 } // namespace policy |
| OLD | NEW |