| 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 "components/policy/core/common/policy_loader_mac.h" | 5 #include "components/policy/core/common/policy_loader_mac.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 POLICY_SOURCE_PLATFORM) {} | 67 POLICY_SOURCE_PLATFORM) {} |
| 68 | 68 |
| 69 TestHarness::~TestHarness() {} | 69 TestHarness::~TestHarness() {} |
| 70 | 70 |
| 71 void TestHarness::SetUp() {} | 71 void TestHarness::SetUp() {} |
| 72 | 72 |
| 73 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 73 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
| 74 SchemaRegistry* registry, | 74 SchemaRegistry* registry, |
| 75 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 75 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
| 76 prefs_ = new MockPreferences(); | 76 prefs_ = new MockPreferences(); |
| 77 scoped_ptr<AsyncPolicyLoader> loader( | 77 std::unique_ptr<AsyncPolicyLoader> loader( |
| 78 new PolicyLoaderMac(task_runner, base::FilePath(), prefs_)); | 78 new PolicyLoaderMac(task_runner, base::FilePath(), prefs_)); |
| 79 return new AsyncPolicyProvider(registry, std::move(loader)); | 79 return new AsyncPolicyProvider(registry, std::move(loader)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TestHarness::InstallEmptyPolicy() {} | 82 void TestHarness::InstallEmptyPolicy() {} |
| 83 | 83 |
| 84 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 84 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
| 85 const std::string& policy_value) { | 85 const std::string& policy_value) { |
| 86 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); | 86 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); |
| 87 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); | 87 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // once the mac loader supports 3rd party policy. http://crbug.com/108995 | 138 // once the mac loader supports 3rd party policy. http://crbug.com/108995 |
| 139 | 139 |
| 140 // Special test cases for some mac preferences details. | 140 // Special test cases for some mac preferences details. |
| 141 class PolicyLoaderMacTest : public PolicyTestBase { | 141 class PolicyLoaderMacTest : public PolicyTestBase { |
| 142 protected: | 142 protected: |
| 143 PolicyLoaderMacTest() | 143 PolicyLoaderMacTest() |
| 144 : prefs_(new MockPreferences()) {} | 144 : prefs_(new MockPreferences()) {} |
| 145 | 145 |
| 146 void SetUp() override { | 146 void SetUp() override { |
| 147 PolicyTestBase::SetUp(); | 147 PolicyTestBase::SetUp(); |
| 148 scoped_ptr<AsyncPolicyLoader> loader( | 148 std::unique_ptr<AsyncPolicyLoader> loader( |
| 149 new PolicyLoaderMac(loop_.task_runner(), base::FilePath(), prefs_)); | 149 new PolicyLoaderMac(loop_.task_runner(), base::FilePath(), prefs_)); |
| 150 provider_.reset( | 150 provider_.reset( |
| 151 new AsyncPolicyProvider(&schema_registry_, std::move(loader))); | 151 new AsyncPolicyProvider(&schema_registry_, std::move(loader))); |
| 152 provider_->Init(&schema_registry_); | 152 provider_->Init(&schema_registry_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void TearDown() override { | 155 void TearDown() override { |
| 156 provider_->Shutdown(); | 156 provider_->Shutdown(); |
| 157 PolicyTestBase::TearDown(); | 157 PolicyTestBase::TearDown(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 MockPreferences* prefs_; | 160 MockPreferences* prefs_; |
| 161 scoped_ptr<AsyncPolicyProvider> provider_; | 161 std::unique_ptr<AsyncPolicyProvider> provider_; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 TEST_F(PolicyLoaderMacTest, Invalid) { | 164 TEST_F(PolicyLoaderMacTest, Invalid) { |
| 165 ScopedCFTypeRef<CFStringRef> name( | 165 ScopedCFTypeRef<CFStringRef> name( |
| 166 base::SysUTF8ToCFStringRef(test_keys::kKeyString)); | 166 base::SysUTF8ToCFStringRef(test_keys::kKeyString)); |
| 167 const char buffer[] = "binary \xde\xad\xbe\xef data"; | 167 const char buffer[] = "binary \xde\xad\xbe\xef data"; |
| 168 ScopedCFTypeRef<CFDataRef> invalid_data( | 168 ScopedCFTypeRef<CFDataRef> invalid_data( |
| 169 CFDataCreate(kCFAllocatorDefault, | 169 CFDataCreate(kCFAllocatorDefault, |
| 170 reinterpret_cast<const UInt8 *>(buffer), | 170 reinterpret_cast<const UInt8 *>(buffer), |
| 171 arraysize(buffer))); | 171 arraysize(buffer))); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 196 .Set(test_keys::kKeyString, | 196 .Set(test_keys::kKeyString, |
| 197 POLICY_LEVEL_RECOMMENDED, | 197 POLICY_LEVEL_RECOMMENDED, |
| 198 POLICY_SCOPE_USER, | 198 POLICY_SCOPE_USER, |
| 199 POLICY_SOURCE_PLATFORM, | 199 POLICY_SOURCE_PLATFORM, |
| 200 new base::StringValue("string value"), | 200 new base::StringValue("string value"), |
| 201 NULL); | 201 NULL); |
| 202 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); | 202 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace policy | 205 } // namespace policy |
| OLD | NEW |