| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <CoreFoundation/CoreFoundation.h> | 5 #include <CoreFoundation/CoreFoundation.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 TestHarness::~TestHarness() {} | 154 TestHarness::~TestHarness() {} |
| 155 | 155 |
| 156 void TestHarness::SetUp() {} | 156 void TestHarness::SetUp() {} |
| 157 | 157 |
| 158 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 158 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
| 159 const PolicyDefinitionList* policy_definition_list) { | 159 const PolicyDefinitionList* policy_definition_list) { |
| 160 prefs_ = new MockPreferences(); | 160 prefs_ = new MockPreferences(); |
| 161 scoped_ptr<AsyncPolicyLoader> loader( | 161 scoped_ptr<AsyncPolicyLoader> loader( |
| 162 new PolicyLoaderMac(policy_definition_list, prefs_)); | 162 new PolicyLoaderMac(policy_definition_list, prefs_)); |
| 163 return new AsyncPolicyProvider(policy_definition_list, loader.Pass()); | 163 return new AsyncPolicyProvider(loader.Pass()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void TestHarness::InstallEmptyPolicy() {} | 166 void TestHarness::InstallEmptyPolicy() {} |
| 167 | 167 |
| 168 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 168 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
| 169 const std::string& policy_value) { | 169 const std::string& policy_value) { |
| 170 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); | 170 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); |
| 171 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); | 171 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); |
| 172 prefs_->AddTestItem(name, value, true); | 172 prefs_->AddTestItem(name, value, true); |
| 173 } | 173 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 PolicyProviderMacTest, | 219 PolicyProviderMacTest, |
| 220 ConfigurationPolicyProviderTest, | 220 ConfigurationPolicyProviderTest, |
| 221 testing::Values(TestHarness::Create)); | 221 testing::Values(TestHarness::Create)); |
| 222 | 222 |
| 223 // Special test cases for some mac preferences details. | 223 // Special test cases for some mac preferences details. |
| 224 class PolicyLoaderMacTest : public PolicyTestBase { | 224 class PolicyLoaderMacTest : public PolicyTestBase { |
| 225 protected: | 225 protected: |
| 226 PolicyLoaderMacTest() | 226 PolicyLoaderMacTest() |
| 227 : prefs_(new MockPreferences()), | 227 : prefs_(new MockPreferences()), |
| 228 loader_(new PolicyLoaderMac(&test_policy_definitions::kList, prefs_)), | 228 loader_(new PolicyLoaderMac(&test_policy_definitions::kList, prefs_)), |
| 229 provider_(&test_policy_definitions::kList, | 229 provider_(scoped_ptr<AsyncPolicyLoader>(loader_)) {} |
| 230 scoped_ptr<AsyncPolicyLoader>(loader_)) {} | |
| 231 virtual ~PolicyLoaderMacTest() {} | 230 virtual ~PolicyLoaderMacTest() {} |
| 232 | 231 |
| 233 MockPreferences* prefs_; | 232 MockPreferences* prefs_; |
| 234 PolicyLoaderMac* loader_; | 233 PolicyLoaderMac* loader_; |
| 235 AsyncPolicyProvider provider_; | 234 AsyncPolicyProvider provider_; |
| 236 }; | 235 }; |
| 237 | 236 |
| 238 TEST_F(PolicyLoaderMacTest, Invalid) { | 237 TEST_F(PolicyLoaderMacTest, Invalid) { |
| 239 ScopedCFTypeRef<CFStringRef> name( | 238 ScopedCFTypeRef<CFStringRef> name( |
| 240 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString)); | 239 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root)); | 311 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root)); |
| 313 ASSERT_TRUE(property); | 312 ASSERT_TRUE(property); |
| 314 scoped_ptr<base::Value> value( | 313 scoped_ptr<base::Value> value( |
| 315 PolicyLoaderMac::CreateValueFromProperty(property)); | 314 PolicyLoaderMac::CreateValueFromProperty(property)); |
| 316 ASSERT_TRUE(value.get()); | 315 ASSERT_TRUE(value.get()); |
| 317 | 316 |
| 318 EXPECT_TRUE(root.Equals(value.get())); | 317 EXPECT_TRUE(root.Equals(value.get())); |
| 319 } | 318 } |
| 320 | 319 |
| 321 } // namespace policy | 320 } // namespace policy |
| OLD | NEW |