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

Side by Side Diff: components/policy/core/common/policy_loader_ios_unittest.mm

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed platform-specific tests. Created 5 years, 3 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 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698