| 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" |
| 11 #include "chrome/browser/policy/configuration_policy_reader.h" | 11 #include "chrome/browser/policy/configuration_policy_reader.h" |
| 12 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 12 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 13 #include "chrome/browser/policy/mock_configuration_policy_reader.h" | 13 #include "chrome/browser/policy/mock_configuration_policy_reader.h" |
| 14 #include "policy/policy_constants.h" | 14 #include "policy/policy_constants.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using ::testing::Return; | 17 using ::testing::Return; |
| 18 using ::testing::ReturnNull; | 18 using ::testing::ReturnNull; |
| 19 using ::testing::_; | 19 using ::testing::_; |
| 20 | 20 |
| 21 namespace policy { | 21 namespace policy { |
| 22 | 22 |
| 23 class ConfigurationPolicyReaderTest : public testing::Test { | 23 class ConfigurationPolicyReaderTest : public testing::Test { |
| 24 protected: | 24 protected: |
| 25 ConfigurationPolicyReaderTest() : provider_() { | 25 ConfigurationPolicyReaderTest() : provider_() { |
| 26 managed_reader_.reset( | 26 managed_reader_.reset( |
| 27 new ConfigurationPolicyReader(&provider_, PolicyStatusInfo::MANDATORY)); | 27 new ConfigurationPolicyReader(&provider_, PolicyStatusInfo::MANDATORY)); |
| 28 recommended_reader_.reset(new ConfigurationPolicyReader(&provider_, | 28 recommended_reader_.reset(new ConfigurationPolicyReader(&provider_, |
| 29 PolicyStatusInfo::RECOMMENDED)); | 29 PolicyStatusInfo::RECOMMENDED)); |
| 30 status_ok_ = ASCIIToUTF16("ok"); | 30 status_ok_ = ASCIIToUTF16("OK"); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DictionaryValue* CreateDictionary(const char* policy_name, | 33 DictionaryValue* CreateDictionary(const char* policy_name, |
| 34 Value* policy_value) { | 34 Value* policy_value) { |
| 35 DictionaryValue* dict = new DictionaryValue(); | 35 DictionaryValue* dict = new DictionaryValue(); |
| 36 dict->SetString(std::string(PolicyStatusInfo::kNameDictPath), | 36 dict->SetString(std::string(PolicyStatusInfo::kNameDictPath), |
| 37 ASCIIToUTF16(policy_name)); | 37 ASCIIToUTF16(policy_name)); |
| 38 dict->SetString(std::string(PolicyStatusInfo::kLevelDictPath), | 38 dict->SetString(std::string(PolicyStatusInfo::kLevelDictPath), |
| 39 PolicyStatusInfo::GetPolicyLevelString(PolicyStatusInfo::MANDATORY)); | 39 PolicyStatusInfo::GetPolicyLevelString(PolicyStatusInfo::MANDATORY)); |
| 40 dict->SetString(std::string(PolicyStatusInfo::kSourceTypeDictPath), | 40 dict->SetString(std::string(PolicyStatusInfo::kSourceTypeDictPath), |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 PolicyStatusTest() { | 151 PolicyStatusTest() { |
| 152 managed_platform_ = new MockConfigurationPolicyReader(); | 152 managed_platform_ = new MockConfigurationPolicyReader(); |
| 153 managed_cloud_ = new MockConfigurationPolicyReader(); | 153 managed_cloud_ = new MockConfigurationPolicyReader(); |
| 154 recommended_platform_ = new MockConfigurationPolicyReader(); | 154 recommended_platform_ = new MockConfigurationPolicyReader(); |
| 155 recommended_cloud_ = new MockConfigurationPolicyReader(); | 155 recommended_cloud_ = new MockConfigurationPolicyReader(); |
| 156 | 156 |
| 157 policy_status_.reset(new PolicyStatus(managed_platform_, | 157 policy_status_.reset(new PolicyStatus(managed_platform_, |
| 158 managed_cloud_, | 158 managed_cloud_, |
| 159 recommended_platform_, | 159 recommended_platform_, |
| 160 recommended_cloud_)); | 160 recommended_cloud_)); |
| 161 status_ok_ = ASCIIToUTF16("ok"); | 161 status_ok_ = ASCIIToUTF16("OK"); |
| 162 | 162 |
| 163 policy_list_ = GetChromePolicyDefinitionList(); | 163 policy_list_ = GetChromePolicyDefinitionList(); |
| 164 policy_list_size_ = | 164 policy_list_size_ = |
| 165 static_cast<size_t>(policy_list_->end - policy_list_->begin); | 165 static_cast<size_t>(policy_list_->end - policy_list_->begin); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void DontSendPolicies() { | 168 void DontSendPolicies() { |
| 169 EXPECT_CALL(*managed_platform_, GetPolicyStatus(_)) | 169 EXPECT_CALL(*managed_platform_, GetPolicyStatus(_)) |
| 170 .WillRepeatedly(ReturnNull()); | 170 .WillRepeatedly(ReturnNull()); |
| 171 EXPECT_CALL(*managed_cloud_, GetPolicyStatus(_)) | 171 EXPECT_CALL(*managed_cloud_, GetPolicyStatus(_)) |
| 172 .WillRepeatedly(ReturnNull()); | 172 .WillRepeatedly(ReturnNull()); |
| 173 EXPECT_CALL(*recommended_platform_, GetPolicyStatus(_)) | 173 EXPECT_CALL(*recommended_platform_, GetPolicyStatus(_)) |
| 174 .WillRepeatedly(ReturnNull()); | 174 .WillRepeatedly(ReturnNull()); |
| 175 EXPECT_CALL(*recommended_cloud_, GetPolicyStatus(_)) | 175 EXPECT_CALL(*recommended_cloud_, GetPolicyStatus(_)) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 entry->name, | 337 entry->name, |
| 338 false, | 338 false, |
| 339 PolicyStatusInfo::LEVEL_UNDEFINED); | 339 PolicyStatusInfo::LEVEL_UNDEFINED); |
| 340 EXPECT_TRUE(undefined_dict->Equals(status_dict)); | 340 EXPECT_TRUE(undefined_dict->Equals(status_dict)); |
| 341 break; | 341 break; |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace policy | 346 } // namespace policy |
| OLD | NEW |