| 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" |
| 6 |
| 5 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 6 | 8 |
| 9 #include <utility> |
| 10 |
| 7 #include "base/callback.h" | 11 #include "base/callback.h" |
| 8 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 9 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "base/macros.h" | 14 #include "base/macros.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 12 #include "base/values.h" | 16 #include "base/values.h" |
| 13 #include "components/policy/core/common/async_policy_provider.h" | 17 #include "components/policy/core/common/async_policy_provider.h" |
| 14 #include "components/policy/core/common/configuration_policy_provider_test.h" | 18 #include "components/policy/core/common/configuration_policy_provider_test.h" |
| 15 #include "components/policy/core/common/external_data_fetcher.h" | 19 #include "components/policy/core/common/external_data_fetcher.h" |
| 16 #include "components/policy/core/common/policy_bundle.h" | 20 #include "components/policy/core/common/policy_bundle.h" |
| 17 #include "components/policy/core/common/policy_loader_mac.h" | |
| 18 #include "components/policy/core/common/policy_map.h" | 21 #include "components/policy/core/common/policy_map.h" |
| 19 #include "components/policy/core/common/policy_test_utils.h" | 22 #include "components/policy/core/common/policy_test_utils.h" |
| 20 #include "components/policy/core/common/policy_types.h" | 23 #include "components/policy/core/common/policy_types.h" |
| 21 #include "components/policy/core/common/preferences_mock_mac.h" | 24 #include "components/policy/core/common/preferences_mock_mac.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 26 |
| 24 using base::ScopedCFTypeRef; | 27 using base::ScopedCFTypeRef; |
| 25 | 28 |
| 26 namespace policy { | 29 namespace policy { |
| 27 | 30 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 TestHarness::~TestHarness() {} | 69 TestHarness::~TestHarness() {} |
| 67 | 70 |
| 68 void TestHarness::SetUp() {} | 71 void TestHarness::SetUp() {} |
| 69 | 72 |
| 70 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 73 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
| 71 SchemaRegistry* registry, | 74 SchemaRegistry* registry, |
| 72 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 75 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
| 73 prefs_ = new MockPreferences(); | 76 prefs_ = new MockPreferences(); |
| 74 scoped_ptr<AsyncPolicyLoader> loader( | 77 scoped_ptr<AsyncPolicyLoader> loader( |
| 75 new PolicyLoaderMac(task_runner, base::FilePath(), prefs_)); | 78 new PolicyLoaderMac(task_runner, base::FilePath(), prefs_)); |
| 76 return new AsyncPolicyProvider(registry, loader.Pass()); | 79 return new AsyncPolicyProvider(registry, std::move(loader)); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void TestHarness::InstallEmptyPolicy() {} | 82 void TestHarness::InstallEmptyPolicy() {} |
| 80 | 83 |
| 81 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 84 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
| 82 const std::string& policy_value) { | 85 const std::string& policy_value) { |
| 83 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); | 86 ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name)); |
| 84 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); | 87 ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value)); |
| 85 prefs_->AddTestItem(name, value, true); | 88 prefs_->AddTestItem(name, value, true); |
| 86 } | 89 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Special test cases for some mac preferences details. | 140 // Special test cases for some mac preferences details. |
| 138 class PolicyLoaderMacTest : public PolicyTestBase { | 141 class PolicyLoaderMacTest : public PolicyTestBase { |
| 139 protected: | 142 protected: |
| 140 PolicyLoaderMacTest() | 143 PolicyLoaderMacTest() |
| 141 : prefs_(new MockPreferences()) {} | 144 : prefs_(new MockPreferences()) {} |
| 142 | 145 |
| 143 void SetUp() override { | 146 void SetUp() override { |
| 144 PolicyTestBase::SetUp(); | 147 PolicyTestBase::SetUp(); |
| 145 scoped_ptr<AsyncPolicyLoader> loader( | 148 scoped_ptr<AsyncPolicyLoader> loader( |
| 146 new PolicyLoaderMac(loop_.task_runner(), base::FilePath(), prefs_)); | 149 new PolicyLoaderMac(loop_.task_runner(), base::FilePath(), prefs_)); |
| 147 provider_.reset(new AsyncPolicyProvider(&schema_registry_, loader.Pass())); | 150 provider_.reset( |
| 151 new AsyncPolicyProvider(&schema_registry_, std::move(loader))); |
| 148 provider_->Init(&schema_registry_); | 152 provider_->Init(&schema_registry_); |
| 149 } | 153 } |
| 150 | 154 |
| 151 void TearDown() override { | 155 void TearDown() override { |
| 152 provider_->Shutdown(); | 156 provider_->Shutdown(); |
| 153 PolicyTestBase::TearDown(); | 157 PolicyTestBase::TearDown(); |
| 154 } | 158 } |
| 155 | 159 |
| 156 MockPreferences* prefs_; | 160 MockPreferences* prefs_; |
| 157 scoped_ptr<AsyncPolicyProvider> provider_; | 161 scoped_ptr<AsyncPolicyProvider> provider_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 .Set(test_keys::kKeyString, | 196 .Set(test_keys::kKeyString, |
| 193 POLICY_LEVEL_RECOMMENDED, | 197 POLICY_LEVEL_RECOMMENDED, |
| 194 POLICY_SCOPE_USER, | 198 POLICY_SCOPE_USER, |
| 195 POLICY_SOURCE_PLATFORM, | 199 POLICY_SOURCE_PLATFORM, |
| 196 new base::StringValue("string value"), | 200 new base::StringValue("string value"), |
| 197 NULL); | 201 NULL); |
| 198 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); | 202 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); |
| 199 } | 203 } |
| 200 | 204 |
| 201 } // namespace policy | 205 } // namespace policy |
| OLD | NEW |