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/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" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 ScopedCFTypeRef<CFDataRef> invalid_data( | 254 ScopedCFTypeRef<CFDataRef> invalid_data( |
255 CFDataCreate(kCFAllocatorDefault, | 255 CFDataCreate(kCFAllocatorDefault, |
256 reinterpret_cast<const UInt8 *>(buffer), | 256 reinterpret_cast<const UInt8 *>(buffer), |
257 arraysize(buffer))); | 257 arraysize(buffer))); |
258 ASSERT_TRUE(invalid_data); | 258 ASSERT_TRUE(invalid_data); |
259 prefs_->AddTestItem(name, invalid_data.get(), true); | 259 prefs_->AddTestItem(name, invalid_data.get(), true); |
260 prefs_->AddTestItem(name, invalid_data.get(), false); | 260 prefs_->AddTestItem(name, invalid_data.get(), false); |
261 | 261 |
262 // Make the provider read the updated |prefs_|. | 262 // Make the provider read the updated |prefs_|. |
263 provider_.RefreshPolicies(); | 263 provider_.RefreshPolicies(); |
264 loop_.RunAllPending(); | 264 loop_.RunUntilIdle(); |
265 const PolicyBundle kEmptyBundle; | 265 const PolicyBundle kEmptyBundle; |
266 EXPECT_TRUE(provider_.policies().Equals(kEmptyBundle)); | 266 EXPECT_TRUE(provider_.policies().Equals(kEmptyBundle)); |
267 } | 267 } |
268 | 268 |
269 TEST_F(PolicyLoaderMacTest, TestNonForcedValue) { | 269 TEST_F(PolicyLoaderMacTest, TestNonForcedValue) { |
270 ScopedCFTypeRef<CFStringRef> name( | 270 ScopedCFTypeRef<CFStringRef> name( |
271 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString)); | 271 base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString)); |
272 ScopedCFTypeRef<CFPropertyListRef> test_value( | 272 ScopedCFTypeRef<CFPropertyListRef> test_value( |
273 base::SysUTF8ToCFStringRef("string value")); | 273 base::SysUTF8ToCFStringRef("string value")); |
274 ASSERT_TRUE(test_value.get()); | 274 ASSERT_TRUE(test_value.get()); |
275 prefs_->AddTestItem(name, test_value.get(), false); | 275 prefs_->AddTestItem(name, test_value.get(), false); |
276 | 276 |
277 // Make the provider read the updated |prefs_|. | 277 // Make the provider read the updated |prefs_|. |
278 provider_.RefreshPolicies(); | 278 provider_.RefreshPolicies(); |
279 loop_.RunAllPending(); | 279 loop_.RunUntilIdle(); |
280 PolicyBundle expected_bundle; | 280 PolicyBundle expected_bundle; |
281 expected_bundle.Get(POLICY_DOMAIN_CHROME, "") | 281 expected_bundle.Get(POLICY_DOMAIN_CHROME, "") |
282 .Set(test_policy_definitions::kKeyString, POLICY_LEVEL_RECOMMENDED, | 282 .Set(test_policy_definitions::kKeyString, POLICY_LEVEL_RECOMMENDED, |
283 POLICY_SCOPE_USER, base::Value::CreateStringValue("string value")); | 283 POLICY_SCOPE_USER, base::Value::CreateStringValue("string value")); |
284 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); | 284 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); |
285 } | 285 } |
286 | 286 |
287 TEST_F(PolicyLoaderMacTest, TestConversions) { | 287 TEST_F(PolicyLoaderMacTest, TestConversions) { |
288 base::DictionaryValue root; | 288 base::DictionaryValue root; |
289 | 289 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root)); | 324 ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root)); |
325 ASSERT_TRUE(property); | 325 ASSERT_TRUE(property); |
326 scoped_ptr<base::Value> value( | 326 scoped_ptr<base::Value> value( |
327 PolicyLoaderMac::CreateValueFromProperty(property)); | 327 PolicyLoaderMac::CreateValueFromProperty(property)); |
328 ASSERT_TRUE(value.get()); | 328 ASSERT_TRUE(value.get()); |
329 | 329 |
330 EXPECT_TRUE(root.Equals(value.get())); | 330 EXPECT_TRUE(root.Equals(value.get())); |
331 } | 331 } |
332 | 332 |
333 } // namespace policy | 333 } // namespace policy |
OLD | NEW |