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/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/policy/core/common/async_policy_provider.h" | 13 #include "components/policy/core/common/async_policy_provider.h" |
14 #include "components/policy/core/common/configuration_policy_provider_test.h" | 14 #include "components/policy/core/common/configuration_policy_provider_test.h" |
15 #include "components/policy/core/common/external_data_fetcher.h" | 15 #include "components/policy/core/common/external_data_fetcher.h" |
16 #include "components/policy/core/common/policy_bundle.h" | 16 #include "components/policy/core/common/policy_bundle.h" |
17 #include "components/policy/core/common/policy_loader_mac.h" | 17 #include "components/policy/core/common/policy_loader_mac.h" |
18 #include "components/policy/core/common/policy_map.h" | 18 #include "components/policy/core/common/policy_map.h" |
19 #include "components/policy/core/common/policy_test_utils.h" | 19 #include "components/policy/core/common/policy_test_utils.h" |
| 20 #include "components/policy/core/common/policy_types.h" |
20 #include "components/policy/core/common/preferences_mock_mac.h" | 21 #include "components/policy/core/common/preferences_mock_mac.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 using base::ScopedCFTypeRef; | 24 using base::ScopedCFTypeRef; |
24 | 25 |
25 namespace policy { | 26 namespace policy { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 class TestHarness : public PolicyProviderTestHarness { | 30 class TestHarness : public PolicyProviderTestHarness { |
(...skipping 22 matching lines...) Expand all Loading... |
52 | 53 |
53 static PolicyProviderTestHarness* Create(); | 54 static PolicyProviderTestHarness* Create(); |
54 | 55 |
55 private: | 56 private: |
56 MockPreferences* prefs_; | 57 MockPreferences* prefs_; |
57 | 58 |
58 DISALLOW_COPY_AND_ASSIGN(TestHarness); | 59 DISALLOW_COPY_AND_ASSIGN(TestHarness); |
59 }; | 60 }; |
60 | 61 |
61 TestHarness::TestHarness() | 62 TestHarness::TestHarness() |
62 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER) {} | 63 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 64 POLICY_SOURCE_PLATFORM) {} |
63 | 65 |
64 TestHarness::~TestHarness() {} | 66 TestHarness::~TestHarness() {} |
65 | 67 |
66 void TestHarness::SetUp() {} | 68 void TestHarness::SetUp() {} |
67 | 69 |
68 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 70 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
69 SchemaRegistry* registry, | 71 SchemaRegistry* registry, |
70 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 72 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
71 prefs_ = new MockPreferences(); | 73 prefs_ = new MockPreferences(); |
72 scoped_ptr<AsyncPolicyLoader> loader( | 74 scoped_ptr<AsyncPolicyLoader> loader( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 prefs_->AddTestItem(name, test_value.get(), false); | 185 prefs_->AddTestItem(name, test_value.get(), false); |
184 | 186 |
185 // Make the provider read the updated |prefs_|. | 187 // Make the provider read the updated |prefs_|. |
186 provider_->RefreshPolicies(); | 188 provider_->RefreshPolicies(); |
187 loop_.RunUntilIdle(); | 189 loop_.RunUntilIdle(); |
188 PolicyBundle expected_bundle; | 190 PolicyBundle expected_bundle; |
189 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 191 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
190 .Set(test_keys::kKeyString, | 192 .Set(test_keys::kKeyString, |
191 POLICY_LEVEL_RECOMMENDED, | 193 POLICY_LEVEL_RECOMMENDED, |
192 POLICY_SCOPE_USER, | 194 POLICY_SCOPE_USER, |
| 195 POLICY_SOURCE_PLATFORM, |
193 new base::StringValue("string value"), | 196 new base::StringValue("string value"), |
194 NULL); | 197 NULL); |
195 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); | 198 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); |
196 } | 199 } |
197 | 200 |
198 } // namespace policy | 201 } // namespace policy |
OLD | NEW |