OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <UIKit/UIKit.h> | 5 #include <UIKit/UIKit.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/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void AddPolicies(NSDictionary* policy); | 61 void AddPolicies(NSDictionary* policy); |
62 void AddChromePolicy(NSDictionary* policy); | 62 void AddChromePolicy(NSDictionary* policy); |
63 void AddEncodedChromePolicy(NSDictionary* policy); | 63 void AddEncodedChromePolicy(NSDictionary* policy); |
64 | 64 |
65 bool use_encoded_key_; | 65 bool use_encoded_key_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(TestHarness); | 67 DISALLOW_COPY_AND_ASSIGN(TestHarness); |
68 }; | 68 }; |
69 | 69 |
70 TestHarness::TestHarness(bool use_encoded_key) | 70 TestHarness::TestHarness(bool use_encoded_key) |
71 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE), | 71 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 72 POLICY_SOURCE_PLATFORM), |
72 use_encoded_key_(use_encoded_key) {} | 73 use_encoded_key_(use_encoded_key) {} |
73 | 74 |
74 TestHarness::~TestHarness() { | 75 TestHarness::~TestHarness() { |
75 // Cleanup any policies left from the test. | 76 // Cleanup any policies left from the test. |
76 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kConfigurationKey]; | 77 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kConfigurationKey]; |
77 } | 78 } |
78 | 79 |
79 void TestHarness::SetUp() { | 80 void TestHarness::SetUp() { |
80 // Make sure there is no pre-existing policy present. | 81 // Make sure there is no pre-existing policy present. |
81 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kConfigurationKey]; | 82 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kConfigurationKey]; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 @"ChromePolicy": chromePolicy, | 244 @"ChromePolicy": chromePolicy, |
244 @"EncodedChromePolicy": encodedChromePolicy, | 245 @"EncodedChromePolicy": encodedChromePolicy, |
245 }; | 246 }; |
246 | 247 |
247 [[NSUserDefaults standardUserDefaults] setObject:wrapper | 248 [[NSUserDefaults standardUserDefaults] setObject:wrapper |
248 forKey:kConfigurationKey]; | 249 forKey:kConfigurationKey]; |
249 | 250 |
250 PolicyBundle expected; | 251 PolicyBundle expected; |
251 PolicyMap& expectedMap = | 252 PolicyMap& expectedMap = |
252 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, "")); | 253 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, "")); |
253 expectedMap.Set("shared", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 254 expectedMap.SetWithSource("shared", |
254 new base::StringValue("right"), NULL); | 255 POLICY_LEVEL_MANDATORY, |
255 expectedMap.Set("key2", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 256 POLICY_SCOPE_MACHINE, |
256 new base::StringValue("value2"), NULL); | 257 new base::StringValue("right"), |
| 258 NULL, |
| 259 POLICY_SOURCE_PLATFORM); |
| 260 expectedMap.SetWithSource("key2", |
| 261 POLICY_LEVEL_MANDATORY, |
| 262 POLICY_SCOPE_MACHINE, |
| 263 new base::StringValue("value2"), |
| 264 NULL, |
| 265 POLICY_SOURCE_PLATFORM); |
257 | 266 |
258 scoped_refptr<base::TestSimpleTaskRunner> taskRunner = | 267 scoped_refptr<base::TestSimpleTaskRunner> taskRunner = |
259 new base::TestSimpleTaskRunner(); | 268 new base::TestSimpleTaskRunner(); |
260 PolicyLoaderIOS loader(taskRunner); | 269 PolicyLoaderIOS loader(taskRunner); |
261 scoped_ptr<PolicyBundle> bundle = loader.Load(); | 270 scoped_ptr<PolicyBundle> bundle = loader.Load(); |
262 ASSERT_TRUE(bundle); | 271 ASSERT_TRUE(bundle); |
263 EXPECT_TRUE(bundle->Equals(expected)); | 272 EXPECT_TRUE(bundle->Equals(expected)); |
264 } | 273 } |
265 | 274 |
266 } // namespace policy | 275 } // namespace policy |
OLD | NEW |