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

Unified Diff: chrome/browser/policy/policy_loader_win_unittest.cc

Issue 13619014: Change PolicyLoaderWin to load PReg files if possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_loader_win_unittest.cc
diff --git a/chrome/browser/policy/policy_loader_win_unittest.cc b/chrome/browser/policy/policy_loader_win_unittest.cc
index 00b303b8d87eeb87aa42e18ce4c605102021acec..a0c782aff50008e3520480ab6c044ffd5a926768 100644
--- a/chrome/browser/policy/policy_loader_win_unittest.cc
+++ b/chrome/browser/policy/policy_loader_win_unittest.cc
@@ -320,7 +320,7 @@ void TestHarness::InstallEmptyPolicy() {}
void TestHarness::InstallStringPolicy(const std::string& policy_name,
const std::string& policy_value) {
- RegKey key(hive_, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey key(hive_, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
ASSERT_HRESULT_SUCCEEDED(key.WriteValue(UTF8ToUTF16(policy_name).c_str(),
UTF8ToUTF16(policy_value).c_str()));
@@ -328,7 +328,7 @@ void TestHarness::InstallStringPolicy(const std::string& policy_name,
void TestHarness::InstallIntegerPolicy(const std::string& policy_name,
int policy_value) {
- RegKey key(hive_, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey key(hive_, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
key.WriteValue(UTF8ToUTF16(policy_name).c_str(),
static_cast<DWORD>(policy_value));
@@ -336,7 +336,7 @@ void TestHarness::InstallIntegerPolicy(const std::string& policy_name,
void TestHarness::InstallBooleanPolicy(const std::string& policy_name,
bool policy_value) {
- RegKey key(hive_, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey key(hive_, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
key.WriteValue(UTF8ToUTF16(policy_name).c_str(),
static_cast<DWORD>(policy_value));
@@ -345,7 +345,7 @@ void TestHarness::InstallBooleanPolicy(const std::string& policy_name,
void TestHarness::InstallStringListPolicy(const std::string& policy_name,
const base::ListValue* policy_value) {
RegKey key(hive_,
- (string16(kRegistryMandatorySubKey) + ASCIIToUTF16("\\") +
+ (string16(kRegistryChromePolicyKey) + ASCIIToUTF16("\\") +
UTF8ToUTF16(policy_name)).c_str(),
KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
@@ -367,7 +367,7 @@ void TestHarness::InstallDictionaryPolicy(
const base::DictionaryValue* policy_value) {
std::string json;
base::JSONWriter::Write(policy_value, &json);
- RegKey key(hive_, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey key(hive_, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
key.WriteValue(UTF8ToUTF16(policy_name).c_str(),
UTF8ToUTF16(json).c_str());
@@ -376,7 +376,7 @@ void TestHarness::InstallDictionaryPolicy(
void TestHarness::Install3rdPartyPolicy(const base::DictionaryValue* policies) {
// The first level entries are domains, and the second level entries map
// components to their policy.
- const string16 kPathPrefix = string16(kRegistryMandatorySubKey) + kPathSep +
+ const string16 kPathPrefix = string16(kRegistryChromePolicyKey) + kPathSep +
kThirdParty + kPathSep;
for (base::DictionaryValue::Iterator domain(*policies);
domain.HasNext(); domain.Advance()) {
@@ -387,7 +387,7 @@ void TestHarness::Install3rdPartyPolicy(const base::DictionaryValue* policies) {
}
for (base::DictionaryValue::Iterator component(*components);
component.HasNext(); component.Advance()) {
- const string16 path = string16(kRegistryMandatorySubKey) + kPathSep +
+ const string16 path = string16(kRegistryChromePolicyKey) + kPathSep +
kThirdParty + kPathSep +
UTF8ToUTF16(domain.key()) + kPathSep +
UTF8ToUTF16(component.key());
@@ -437,11 +437,11 @@ class PolicyLoaderWinTest : public PolicyTestBase {
};
TEST_F(PolicyLoaderWinTest, HKLMOverHKCU) {
- RegKey hklm_key(HKEY_LOCAL_MACHINE, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey hklm_key(HKEY_LOCAL_MACHINE, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(hklm_key.Valid());
hklm_key.WriteValue(UTF8ToUTF16(test_policy_definitions::kKeyString).c_str(),
UTF8ToUTF16("hklm").c_str());
- RegKey hkcu_key(HKEY_CURRENT_USER, kRegistryMandatorySubKey, KEY_ALL_ACCESS);
+ RegKey hkcu_key(HKEY_CURRENT_USER, kRegistryChromePolicyKey, KEY_ALL_ACCESS);
ASSERT_TRUE(hkcu_key.Valid());
hkcu_key.WriteValue(UTF8ToUTF16(test_policy_definitions::kKeyString).c_str(),
UTF8ToUTF16("hkcu").c_str());
@@ -469,7 +469,7 @@ TEST_F(PolicyLoaderWinTest, Load3rdPartyWithoutSchema) {
policy_dict.Set("extensions.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.policy",
dict.DeepCopy());
EXPECT_TRUE(InstallValue(policy_dict, HKEY_LOCAL_MACHINE,
- kRegistryMandatorySubKey, kThirdParty));
+ kRegistryChromePolicyKey, kThirdParty));
PolicyBundle expected;
expected.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
@@ -486,7 +486,7 @@ TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) {
// combinations, to verify that they overlap as expected.
const string16 kPathSuffix =
- kRegistryMandatorySubKey + ASCIIToUTF16("\\3rdparty\\extensions\\merge");
+ kRegistryChromePolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\merge");
const char kUserMandatory[] = "user-mandatory";
const char kUserRecommended[] = "user-recommended";
@@ -558,7 +558,7 @@ TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) {
encoded_policy.SetString("dict", encoded_dict);
const string16 kPathSuffix =
- kRegistryMandatorySubKey + ASCIIToUTF16("\\3rdparty\\extensions\\string");
+ kRegistryChromePolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\string");
EXPECT_TRUE(InstallSchema(policy, HKEY_CURRENT_USER, kPathSuffix, kSchema));
EXPECT_TRUE(
InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
@@ -581,7 +581,7 @@ TEST_F(PolicyLoaderWinTest, LoadIntegerEncodedValues) {
encoded_policy.SetInteger("double", 456);
const string16 kPathSuffix =
- kRegistryMandatorySubKey + ASCIIToUTF16("\\3rdparty\\extensions\\int");
+ kRegistryChromePolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\int");
EXPECT_TRUE(InstallSchema(policy, HKEY_CURRENT_USER, kPathSuffix, kSchema));
EXPECT_TRUE(
InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
@@ -607,7 +607,7 @@ TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
schema.Set(schema::kAdditionalProperties, default_schema.DeepCopy());
const string16 kPathSuffix =
- kRegistryMandatorySubKey + ASCIIToUTF16("\\3rdparty\\extensions\\test");
+ kRegistryChromePolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\test");
EXPECT_TRUE(WriteSchema(schema, HKEY_CURRENT_USER, kPathSuffix, kSchema));
// Write some test values.
@@ -626,6 +626,7 @@ TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
expected_policy.SetInteger("special-int2", -456);
expected_policy.SetDouble("double1", 789.0);
expected_policy.SetDouble("double2", 123.456e7);
+ expected_policy.Set("invalid", base::Value::CreateNullValue());
PolicyBundle expected;
expected.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "test"))
.LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);

Powered by Google App Engine
This is Rietveld 408576698