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

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

Issue 2809933003: Remove ListValue::Append(raw ptr) on Win (Closed)
Patch Set: Includes Created 3 years, 8 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
« no previous file with comments | « chrome/browser/win/enumerate_modules_model.cc ('k') | components/wifi/wifi_service_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <userenv.h> 10 #include <userenv.h>
(...skipping 14 matching lines...) Expand all
25 #include "base/macros.h" 25 #include "base/macros.h"
26 #include "base/memory/ptr_util.h" 26 #include "base/memory/ptr_util.h"
27 #include "base/path_service.h" 27 #include "base/path_service.h"
28 #include "base/process/process_handle.h" 28 #include "base/process/process_handle.h"
29 #include "base/strings/string16.h" 29 #include "base/strings/string16.h"
30 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
31 #include "base/strings/string_util.h" 31 #include "base/strings/string_util.h"
32 #include "base/strings/stringprintf.h" 32 #include "base/strings/stringprintf.h"
33 #include "base/strings/utf_string_conversions.h" 33 #include "base/strings/utf_string_conversions.h"
34 #include "base/sys_byteorder.h" 34 #include "base/sys_byteorder.h"
35 #include "base/values.h"
35 #include "base/win/registry.h" 36 #include "base/win/registry.h"
36 #include "base/win/win_util.h" 37 #include "base/win/win_util.h"
37 #include "components/policy/core/common/async_policy_provider.h" 38 #include "components/policy/core/common/async_policy_provider.h"
38 #include "components/policy/core/common/configuration_policy_provider_test.h" 39 #include "components/policy/core/common/configuration_policy_provider_test.h"
39 #include "components/policy/core/common/external_data_fetcher.h" 40 #include "components/policy/core/common/external_data_fetcher.h"
40 #include "components/policy/core/common/policy_bundle.h" 41 #include "components/policy/core/common/policy_bundle.h"
41 #include "components/policy/core/common/policy_map.h" 42 #include "components/policy/core/common/policy_map.h"
42 #include "components/policy/core/common/policy_types.h" 43 #include "components/policy/core/common/policy_types.h"
43 #include "components/policy/core/common/preg_parser.h" 44 #include "components/policy/core/common/preg_parser.h"
44 #include "components/policy/core/common/schema_map.h" 45 #include "components/policy/core/common/schema_map.h"
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 " \"dict\": { \"$ref\": \"MainType\" }" 901 " \"dict\": { \"$ref\": \"MainType\" }"
901 " }" 902 " }"
902 "}")); 903 "}"));
903 904
904 base::DictionaryValue policy; 905 base::DictionaryValue policy;
905 policy.Set("null", base::MakeUnique<base::Value>()); 906 policy.Set("null", base::MakeUnique<base::Value>());
906 policy.SetBoolean("bool", true); 907 policy.SetBoolean("bool", true);
907 policy.SetInteger("int", -123); 908 policy.SetInteger("int", -123);
908 policy.SetDouble("double", 456.78e9); 909 policy.SetDouble("double", 456.78e9);
909 base::ListValue list; 910 base::ListValue list;
910 list.Append(policy.DeepCopy()); 911 list.Append(base::MakeUnique<base::Value>(policy));
911 list.Append(policy.DeepCopy()); 912 list.Append(base::MakeUnique<base::Value>(policy));
912 policy.Set("list", list.DeepCopy()); 913 policy.Set("list", base::MakeUnique<base::Value>(list));
913 // Encode |policy| before adding the "dict" entry. 914 // Encode |policy| before adding the "dict" entry.
914 std::string encoded_dict; 915 std::string encoded_dict;
915 base::JSONWriter::Write(policy, &encoded_dict); 916 base::JSONWriter::Write(policy, &encoded_dict);
916 ASSERT_FALSE(encoded_dict.empty()); 917 ASSERT_FALSE(encoded_dict.empty());
917 policy.Set("dict", policy.DeepCopy()); 918 policy.Set("dict", base::MakeUnique<base::Value>(policy));
918 std::string encoded_list; 919 std::string encoded_list;
919 base::JSONWriter::Write(list, &encoded_list); 920 base::JSONWriter::Write(list, &encoded_list);
920 ASSERT_FALSE(encoded_list.empty()); 921 ASSERT_FALSE(encoded_list.empty());
921 base::DictionaryValue encoded_policy; 922 base::DictionaryValue encoded_policy;
922 encoded_policy.SetString("null", ""); 923 encoded_policy.SetString("null", "");
923 encoded_policy.SetString("bool", "1"); 924 encoded_policy.SetString("bool", "1");
924 encoded_policy.SetString("int", "-123"); 925 encoded_policy.SetString("int", "-123");
925 encoded_policy.SetString("double", "456.78e9"); 926 encoded_policy.SetString("double", "456.78e9");
926 encoded_policy.SetString("list", encoded_list); 927 encoded_policy.SetString("list", encoded_list);
927 encoded_policy.SetString("dict", encoded_dict); 928 encoded_policy.SetString("dict", encoded_dict);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // Write some test values. 995 // Write some test values.
995 base::DictionaryValue policy; 996 base::DictionaryValue policy;
996 // These special values have a specific schema for them. 997 // These special values have a specific schema for them.
997 policy.SetInteger("special-int1", 123); 998 policy.SetInteger("special-int1", 123);
998 policy.SetString("special-int2", "-456"); 999 policy.SetString("special-int2", "-456");
999 // Other values default to be loaded as doubles. 1000 // Other values default to be loaded as doubles.
1000 policy.SetInteger("double1", 789.0); 1001 policy.SetInteger("double1", 789.0);
1001 policy.SetString("double2", "123.456e7"); 1002 policy.SetString("double2", "123.456e7");
1002 policy.SetString("invalid", "omg"); 1003 policy.SetString("invalid", "omg");
1003 base::DictionaryValue all_policies; 1004 base::DictionaryValue all_policies;
1004 all_policies.Set("policy", policy.DeepCopy()); 1005 all_policies.Set("policy", base::MakeUnique<base::Value>(policy));
1005 1006
1006 const base::string16 kPathSuffix = 1007 const base::string16 kPathSuffix =
1007 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\test"); 1008 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\test");
1008 EXPECT_TRUE( 1009 EXPECT_TRUE(
1009 InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory)); 1010 InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
1010 1011
1011 base::DictionaryValue expected_policy; 1012 base::DictionaryValue expected_policy;
1012 expected_policy.SetInteger("special-int1", 123); 1013 expected_policy.SetInteger("special-int1", 123);
1013 expected_policy.SetInteger("special-int2", -456); 1014 expected_policy.SetInteger("special-int2", -456);
1014 expected_policy.SetDouble("double1", 789.0); 1015 expected_policy.SetDouble("double1", 789.0);
1015 expected_policy.SetDouble("double2", 123.456e7); 1016 expected_policy.SetDouble("double2", 123.456e7);
1016 base::DictionaryValue expected_policies; 1017 base::DictionaryValue expected_policies;
1017 expected_policies.Set("policy", expected_policy.DeepCopy()); 1018 expected_policies.Set("policy",
1019 base::MakeUnique<base::Value>(expected_policy));
1018 PolicyBundle expected; 1020 PolicyBundle expected;
1019 expected.Get(ns).LoadFrom(&expected_policies, POLICY_LEVEL_MANDATORY, 1021 expected.Get(ns).LoadFrom(&expected_policies, POLICY_LEVEL_MANDATORY,
1020 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM); 1022 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM);
1021 EXPECT_TRUE(Matches(expected)); 1023 EXPECT_TRUE(Matches(expected));
1022 } 1024 }
1023 1025
1024 TEST_F(PolicyLoaderWinTest, AppliedPolicyNotPresent) { 1026 TEST_F(PolicyLoaderWinTest, AppliedPolicyNotPresent) {
1025 InstallRegistrySentinel(); 1027 InstallRegistrySentinel();
1026 gpo_list_ = NULL; 1028 gpo_list_ = NULL;
1027 gpo_list_status_ = ERROR_SUCCESS; 1029 gpo_list_status_ = ERROR_SUCCESS;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 expected.Get(ns_a).LoadFrom(&expected_a, POLICY_LEVEL_MANDATORY, 1187 expected.Get(ns_a).LoadFrom(&expected_a, POLICY_LEVEL_MANDATORY,
1186 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); 1188 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM);
1187 base::DictionaryValue expected_b; 1189 base::DictionaryValue expected_b;
1188 expected_b.SetInteger("policy 1", 2); 1190 expected_b.SetInteger("policy 1", 2);
1189 expected.Get(ns_b).LoadFrom(&expected_b, POLICY_LEVEL_MANDATORY, 1191 expected.Get(ns_b).LoadFrom(&expected_b, POLICY_LEVEL_MANDATORY,
1190 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); 1192 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM);
1191 EXPECT_TRUE(Matches(expected)); 1193 EXPECT_TRUE(Matches(expected));
1192 } 1194 }
1193 1195
1194 } // namespace policy 1196 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/win/enumerate_modules_model.cc ('k') | components/wifi/wifi_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698