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

Side by Side Diff: components/policy/core/common/policy_loader_win_unittest.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 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 | Annotate | Revision Log
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 "components/policy/core/common/policy_loader_win.h" 5 #include "components/policy/core/common/policy_loader_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <userenv.h> 8 #include <userenv.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 RegKey hkcu_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS); 798 RegKey hkcu_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS);
799 ASSERT_TRUE(hkcu_key.Valid()); 799 ASSERT_TRUE(hkcu_key.Valid());
800 hkcu_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(), 800 hkcu_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(),
801 UTF8ToUTF16("hkcu").c_str()); 801 UTF8ToUTF16("hkcu").c_str());
802 802
803 PolicyBundle expected; 803 PolicyBundle expected;
804 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 804 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
805 .Set(test_keys::kKeyString, 805 .Set(test_keys::kKeyString,
806 POLICY_LEVEL_MANDATORY, 806 POLICY_LEVEL_MANDATORY,
807 POLICY_SCOPE_MACHINE, 807 POLICY_SCOPE_MACHINE,
808 base::Value::CreateStringValue("hklm"), NULL); 808 new base::StringValue("hklm"),
809 NULL);
809 EXPECT_TRUE(Matches(expected)); 810 EXPECT_TRUE(Matches(expected));
810 } 811 }
811 812
812 TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) { 813 TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) {
813 // Policy for the same extension will be provided at the 4 level/scope 814 // Policy for the same extension will be provided at the 4 level/scope
814 // combinations, to verify that they overlap as expected. 815 // combinations, to verify that they overlap as expected.
815 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "merge"); 816 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "merge");
816 ASSERT_TRUE(RegisterSchema( 817 ASSERT_TRUE(RegisterSchema(
817 ns, 818 ns,
818 "{" 819 "{"
(...skipping 29 matching lines...) Expand all
848 kPathSuffix, kRecommended)); 849 kPathSuffix, kRecommended));
849 policy.SetString("a", kUserRecommended); 850 policy.SetString("a", kUserRecommended);
850 policy.SetString("b", kUserRecommended); 851 policy.SetString("b", kUserRecommended);
851 policy.SetString("c", kUserRecommended); 852 policy.SetString("c", kUserRecommended);
852 policy.SetString("d", kUserRecommended); 853 policy.SetString("d", kUserRecommended);
853 EXPECT_TRUE(InstallValue(policy, HKEY_CURRENT_USER, 854 EXPECT_TRUE(InstallValue(policy, HKEY_CURRENT_USER,
854 kPathSuffix, kRecommended)); 855 kPathSuffix, kRecommended));
855 856
856 PolicyBundle expected; 857 PolicyBundle expected;
857 PolicyMap& expected_policy = expected.Get(ns); 858 PolicyMap& expected_policy = expected.Get(ns);
858 expected_policy.Set("a", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 859 expected_policy.Set("a",
859 base::Value::CreateStringValue(kMachineMandatory), NULL); 860 POLICY_LEVEL_MANDATORY,
860 expected_policy.Set("b", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 861 POLICY_SCOPE_MACHINE,
861 base::Value::CreateStringValue(kUserMandatory), NULL); 862 new base::StringValue(kMachineMandatory),
862 expected_policy.Set("c", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_MACHINE,
863 base::Value::CreateStringValue(kMachineRecommended),
864 NULL); 863 NULL);
865 expected_policy.Set("d", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER, 864 expected_policy.Set("b",
866 base::Value::CreateStringValue(kUserRecommended), NULL); 865 POLICY_LEVEL_MANDATORY,
866 POLICY_SCOPE_USER,
867 new base::StringValue(kUserMandatory),
868 NULL);
869 expected_policy.Set("c",
870 POLICY_LEVEL_RECOMMENDED,
871 POLICY_SCOPE_MACHINE,
872 new base::StringValue(kMachineRecommended),
873 NULL);
874 expected_policy.Set("d",
875 POLICY_LEVEL_RECOMMENDED,
876 POLICY_SCOPE_USER,
877 new base::StringValue(kUserRecommended),
878 NULL);
867 EXPECT_TRUE(Matches(expected)); 879 EXPECT_TRUE(Matches(expected));
868 } 880 }
869 881
870 TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) { 882 TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) {
871 // Create a dictionary with all the types that can be stored encoded in a 883 // Create a dictionary with all the types that can be stored encoded in a
872 // string. 884 // string.
873 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "string"); 885 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "string");
874 ASSERT_TRUE(RegisterSchema( 886 ASSERT_TRUE(RegisterSchema(
875 ns, 887 ns,
876 "{" 888 "{"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 PolicyMap& expected_policy = expected.Get(ns); 1209 PolicyMap& expected_policy = expected.Get(ns);
1198 expected_policy.Set("alternative_browser_path", 1210 expected_policy.Set("alternative_browser_path",
1199 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1211 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1200 new base::StringValue("c:\\legacy\\browser.exe"), NULL); 1212 new base::StringValue("c:\\legacy\\browser.exe"), NULL);
1201 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1213 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1202 list.DeepCopy(), NULL); 1214 list.DeepCopy(), NULL);
1203 EXPECT_TRUE(Matches(expected)); 1215 EXPECT_TRUE(Matches(expected));
1204 } 1216 }
1205 1217
1206 } // namespace policy 1218 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_mac_unittest.cc ('k') | components/policy/core/common/policy_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698