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 "base/prefs/testing_pref_store.h" | 5 #include "base/prefs/testing_pref_store.h" |
6 #include "chrome/browser/policy/configuration_policy_provider_test.h" | 6 #include "chrome/browser/policy/configuration_policy_provider_test.h" |
7 #include "chrome/browser/policy/managed_mode_policy_provider.h" | 7 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
8 #include "chrome/browser/policy/policy_bundle.h" | 8 #include "chrome/browser/policy/policy_bundle.h" |
9 #include "chrome/browser/policy/policy_map.h" | 9 #include "chrome/browser/policy/policy_map.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // static | 59 // static |
60 PolicyProviderTestHarness* TestHarness::Create() { | 60 PolicyProviderTestHarness* TestHarness::Create() { |
61 return new TestHarness(); | 61 return new TestHarness(); |
62 } | 62 } |
63 | 63 |
64 void TestHarness::SetUp() { | 64 void TestHarness::SetUp() { |
65 } | 65 } |
66 | 66 |
67 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 67 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
68 const PolicyDefinitionList* policy_definition_list) { | 68 const PolicyDefinitionList* policy_definition_list) { |
69 return new ManagedModePolicyProvider(pref_store_); | 69 return new ManagedModePolicyProvider(pref_store_.get()); |
70 } | 70 } |
71 | 71 |
72 void TestHarness::InstallEmptyPolicy() {} | 72 void TestHarness::InstallEmptyPolicy() {} |
73 | 73 |
74 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 74 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
75 const std::string& policy_value) { | 75 const std::string& policy_value) { |
76 InstallPolicy(policy_name, base::Value::CreateStringValue(policy_value)); | 76 InstallPolicy(policy_name, base::Value::CreateStringValue(policy_value)); |
77 } | 77 } |
78 | 78 |
79 void TestHarness::InstallIntegerPolicy(const std::string& policy_name, | 79 void TestHarness::InstallIntegerPolicy(const std::string& policy_name, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 // Instantiate abstract test case for basic policy reading tests. | 118 // Instantiate abstract test case for basic policy reading tests. |
119 INSTANTIATE_TEST_CASE_P( | 119 INSTANTIATE_TEST_CASE_P( |
120 ManagedModePolicyProviderTest, | 120 ManagedModePolicyProviderTest, |
121 ConfigurationPolicyProviderTest, | 121 ConfigurationPolicyProviderTest, |
122 testing::Values(TestHarness::Create)); | 122 testing::Values(TestHarness::Create)); |
123 | 123 |
124 class ManagedModePolicyProviderAPITest : public PolicyTestBase { | 124 class ManagedModePolicyProviderAPITest : public PolicyTestBase { |
125 protected: | 125 protected: |
126 ManagedModePolicyProviderAPITest() | 126 ManagedModePolicyProviderAPITest() |
127 : pref_store_(new TestingPrefStore), | 127 : pref_store_(new TestingPrefStore), provider_(pref_store_.get()) { |
128 provider_(pref_store_) { | |
129 pref_store_->SetInitializationCompleted(); | 128 pref_store_->SetInitializationCompleted(); |
130 } | 129 } |
131 virtual ~ManagedModePolicyProviderAPITest() {} | 130 virtual ~ManagedModePolicyProviderAPITest() {} |
132 | 131 |
133 virtual void SetUp() OVERRIDE { | 132 virtual void SetUp() OVERRIDE { |
134 PolicyTestBase::SetUp(); | 133 PolicyTestBase::SetUp(); |
135 provider_.InitDefaultsForTesting( | 134 provider_.InitDefaultsForTesting( |
136 make_scoped_ptr(new base::DictionaryValue)); | 135 make_scoped_ptr(new base::DictionaryValue)); |
137 } | 136 } |
138 | 137 |
(...skipping 24 matching lines...) Expand all Loading... |
163 provider_.GetPolicy(kPolicyKey))); | 162 provider_.GetPolicy(kPolicyKey))); |
164 | 163 |
165 PolicyBundle expected_bundle; | 164 PolicyBundle expected_bundle; |
166 PolicyMap* policy_map = &expected_bundle.Get( | 165 PolicyMap* policy_map = &expected_bundle.Get( |
167 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 166 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
168 policy_map->Set(kPolicyKey, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 167 policy_map->Set(kPolicyKey, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
169 policy_value.DeepCopy()); | 168 policy_value.DeepCopy()); |
170 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); | 169 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); |
171 | 170 |
172 // A newly-created provider should have the same policies. | 171 // A newly-created provider should have the same policies. |
173 ManagedModePolicyProvider new_provider(pref_store_); | 172 ManagedModePolicyProvider new_provider(pref_store_.get()); |
174 new_provider.Init(); | 173 new_provider.Init(); |
175 EXPECT_TRUE(new_provider.policies().Equals(expected_bundle)); | 174 EXPECT_TRUE(new_provider.policies().Equals(expected_bundle)); |
176 | 175 |
177 // Cleanup. | 176 // Cleanup. |
178 new_provider.Shutdown(); | 177 new_provider.Shutdown(); |
179 } | 178 } |
180 | 179 |
181 } // namespace policy | 180 } // namespace policy |
OLD | NEW |