Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Side by Side Diff: chrome/browser/policy/configuration_policy_provider_mac_unittest.cc

Issue 10384145: Removed ConfigurationPolicyProvider::Provide(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/policy/asynchronous_policy_test_base.h" 11 #include "chrome/browser/policy/asynchronous_policy_test_base.h"
12 #include "chrome/browser/policy/configuration_policy_provider_mac.h" 12 #include "chrome/browser/policy/configuration_policy_provider_mac.h"
13 #include "chrome/browser/policy/configuration_policy_provider_test.h" 13 #include "chrome/browser/policy/configuration_policy_provider_test.h"
14 #include "chrome/browser/policy/policy_bundle.h"
14 #include "chrome/browser/policy/policy_map.h" 15 #include "chrome/browser/policy/policy_map.h"
15 #include "chrome/browser/preferences_mock_mac.h" 16 #include "chrome/browser/preferences_mock_mac.h"
16 #include "policy/policy_constants.h" 17 #include "policy/policy_constants.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using base::mac::ScopedCFTypeRef; 20 using base::mac::ScopedCFTypeRef;
20 21
21 namespace policy { 22 namespace policy {
22 23
23 namespace { 24 namespace {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const base::DictionaryValue* policy_value) OVERRIDE; 141 const base::DictionaryValue* policy_value) OVERRIDE;
141 142
142 static PolicyProviderTestHarness* Create(); 143 static PolicyProviderTestHarness* Create();
143 144
144 private: 145 private:
145 MockPreferences* prefs_; 146 MockPreferences* prefs_;
146 147
147 DISALLOW_COPY_AND_ASSIGN(TestHarness); 148 DISALLOW_COPY_AND_ASSIGN(TestHarness);
148 }; 149 };
149 150
150 TestHarness::TestHarness() {} 151 TestHarness::TestHarness()
152 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER) {}
151 153
152 TestHarness::~TestHarness() {} 154 TestHarness::~TestHarness() {}
153 155
154 void TestHarness::SetUp() {} 156 void TestHarness::SetUp() {}
155 157
156 AsynchronousPolicyProvider* TestHarness::CreateProvider( 158 AsynchronousPolicyProvider* TestHarness::CreateProvider(
157 const PolicyDefinitionList* policy_definition_list) { 159 const PolicyDefinitionList* policy_definition_list) {
158 prefs_ = new MockPreferences(); 160 prefs_ = new MockPreferences();
159 return new ConfigurationPolicyProviderMac(policy_definition_list, 161 return new ConfigurationPolicyProviderMac(policy_definition_list,
160 POLICY_LEVEL_MANDATORY, 162 POLICY_LEVEL_MANDATORY,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 reinterpret_cast<const UInt8 *>(buffer), 249 reinterpret_cast<const UInt8 *>(buffer),
248 arraysize(buffer))); 250 arraysize(buffer)));
249 ASSERT_TRUE(invalid_data); 251 ASSERT_TRUE(invalid_data);
250 mandatory_prefs_->AddTestItem(name, invalid_data.get(), true); 252 mandatory_prefs_->AddTestItem(name, invalid_data.get(), true);
251 recommended_prefs_->AddTestItem(name, invalid_data.get(), false); 253 recommended_prefs_->AddTestItem(name, invalid_data.get(), false);
252 254
253 // Create the provider and have it read |mandatory_prefs_|. 255 // Create the provider and have it read |mandatory_prefs_|.
254 mandatory_provider_.RefreshPolicies(); 256 mandatory_provider_.RefreshPolicies();
255 recommended_provider_.RefreshPolicies(); 257 recommended_provider_.RefreshPolicies();
256 loop_.RunAllPending(); 258 loop_.RunAllPending();
257 PolicyMap policy_map; 259 const PolicyBundle kEmptyBundle;
258 EXPECT_TRUE(mandatory_provider_.Provide(&policy_map)); 260 EXPECT_TRUE(mandatory_provider_.policies().Equals(kEmptyBundle));
259 EXPECT_TRUE(policy_map.empty()); 261 EXPECT_TRUE(recommended_provider_.policies().Equals(kEmptyBundle));
260 EXPECT_TRUE(recommended_provider_.Provide(&policy_map));
261 EXPECT_TRUE(policy_map.empty());
262 } 262 }
263 263
264 TEST_F(ConfigurationPolicyProviderMacTest, TestNonForcedValue) { 264 TEST_F(ConfigurationPolicyProviderMacTest, TestNonForcedValue) {
265 ScopedCFTypeRef<CFStringRef> name( 265 ScopedCFTypeRef<CFStringRef> name(
266 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString)); 266 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString));
267 ScopedCFTypeRef<CFPropertyListRef> test_value( 267 ScopedCFTypeRef<CFPropertyListRef> test_value(
268 base::SysUTF8ToCFStringRef("string value")); 268 base::SysUTF8ToCFStringRef("string value"));
269 ASSERT_TRUE(test_value.get()); 269 ASSERT_TRUE(test_value.get());
270 mandatory_prefs_->AddTestItem(name, test_value.get(), false); 270 mandatory_prefs_->AddTestItem(name, test_value.get(), false);
271 recommended_prefs_->AddTestItem(name, test_value.get(), false); 271 recommended_prefs_->AddTestItem(name, test_value.get(), false);
272 272
273 // Create the provider and have it read |mandatory_prefs_|. 273 // Create the provider and have it read |mandatory_prefs_|.
274 mandatory_provider_.RefreshPolicies(); 274 mandatory_provider_.RefreshPolicies();
275 recommended_provider_.RefreshPolicies(); 275 recommended_provider_.RefreshPolicies();
276 loop_.RunAllPending(); 276 loop_.RunAllPending();
277 PolicyMap policy_map; 277 PolicyBundle expected_bundle;
278 EXPECT_TRUE(mandatory_provider_.Provide(&policy_map)); 278 EXPECT_TRUE(mandatory_provider_.policies().Equals(expected_bundle));
279 EXPECT_TRUE(policy_map.empty()); 279 expected_bundle.Get(POLICY_DOMAIN_CHROME, "")
280 EXPECT_TRUE(recommended_provider_.Provide(&policy_map)); 280 .Set(test_policy_definitions::kKeyString, POLICY_LEVEL_RECOMMENDED,
281 EXPECT_EQ(1U, policy_map.size()); 281 POLICY_SCOPE_USER, base::Value::CreateStringValue("string value"));
282 EXPECT_TRUE(recommended_provider_.policies().Equals(expected_bundle));
282 } 283 }
283 284
284 TEST_F(ConfigurationPolicyProviderMacTest, TestConversions) { 285 TEST_F(ConfigurationPolicyProviderMacTest, TestConversions) {
285 base::DictionaryValue root; 286 base::DictionaryValue root;
286 287
287 // base::Value::TYPE_NULL 288 // base::Value::TYPE_NULL
288 root.Set("null", base::Value::CreateNullValue()); 289 root.Set("null", base::Value::CreateNullValue());
289 290
290 // base::Value::TYPE_BOOLEAN 291 // base::Value::TYPE_BOOLEAN
291 root.SetBoolean("false", false); 292 root.SetBoolean("false", false);
(...skipping 29 matching lines...) Expand all
321 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root)); 322 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root));
322 ASSERT_TRUE(property); 323 ASSERT_TRUE(property);
323 scoped_ptr<base::Value> value( 324 scoped_ptr<base::Value> value(
324 MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(property)); 325 MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(property));
325 ASSERT_TRUE(value.get()); 326 ASSERT_TRUE(value.get());
326 327
327 EXPECT_TRUE(root.Equals(value.get())); 328 EXPECT_TRUE(root.Equals(value.get()));
328 } 329 }
329 330
330 } // namespace policy 331 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_provider_mac.cc ('k') | chrome/browser/policy/configuration_policy_provider_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698