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

Unified Diff: components/policy/core/common/policy_map_unittest.cc

Issue 1350913006: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/policy_map.cc ('k') | components/policy/core/common/policy_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/policy_map_unittest.cc
diff --git a/components/policy/core/common/policy_map_unittest.cc b/components/policy/core/common/policy_map_unittest.cc
index 58dfcac054b4653347e778e2862de257e5dde029..356cabce7c812389103cf9263e34cc5ebb08eeb4 100644
--- a/components/policy/core/common/policy_map_unittest.cc
+++ b/components/policy/core/common/policy_map_unittest.cc
@@ -7,7 +7,6 @@
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "components/policy/core/common/external_data_manager.h"
-#include "components/policy/core/common/policy_types.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace policy {
@@ -26,14 +25,13 @@
// Utility functions for the tests.
void SetPolicy(PolicyMap* map, const char* name, base::Value* value) {
- map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
- value, nullptr);
+ map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, value, NULL);
}
void SetPolicy(PolicyMap* map,
const char* name,
ExternalDataFetcher* external_data_fetcher) {
- map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
+ map->Set(name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
NULL, external_data_fetcher);
}
@@ -66,17 +64,15 @@
ASSERT_TRUE(entry != NULL);
EXPECT_EQ(POLICY_LEVEL_MANDATORY, entry->level);
EXPECT_EQ(POLICY_SCOPE_USER, entry->scope);
- EXPECT_EQ(POLICY_SOURCE_CLOUD, entry->source);
EXPECT_TRUE(ExternalDataFetcher::Equals(
entry->external_data_fetcher, CreateExternalDataFetcher("dummy").get()));
- map.Set(kTestPolicyName1, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_ENTERPRISE_DEFAULT, nullptr, nullptr);
+ map.Set(kTestPolicyName1, POLICY_LEVEL_RECOMMENDED,
+ POLICY_SCOPE_MACHINE, NULL, NULL);
EXPECT_FALSE(map.GetValue(kTestPolicyName1));
entry = map.Get(kTestPolicyName1);
ASSERT_TRUE(entry != NULL);
EXPECT_EQ(POLICY_LEVEL_RECOMMENDED, entry->level);
EXPECT_EQ(POLICY_SCOPE_MACHINE, entry->scope);
- EXPECT_EQ(POLICY_SOURCE_ENTERPRISE_DEFAULT, entry->source);
EXPECT_FALSE(entry->external_data_fetcher);
}
@@ -168,30 +164,24 @@
a.Set(kTestPolicyName1,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com"),
NULL);
a.Set(kTestPolicyName2,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
a.Set(kTestPolicyName3,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_ENTERPRISE_DEFAULT,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("a").release());
a.Set(kTestPolicyName4,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(false),
NULL);
a.Set(kTestPolicyName5,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com/q={x}"),
NULL);
@@ -199,36 +189,29 @@
b.Set(kTestPolicyName1,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::StringValue("chromium.org"),
NULL);
b.Set(kTestPolicyName2,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(false),
NULL);
b.Set(kTestPolicyName3,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("b").release());
b.Set(kTestPolicyName4,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_ENTERPRISE_OVERRIDE,
new base::FundamentalValue(true),
NULL);
b.Set(kTestPolicyName5,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_PLATFORM,
new base::StringValue(std::string()),
NULL);
b.Set(kTestPolicyName6,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
@@ -239,40 +222,33 @@
c.Set(kTestPolicyName1,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::StringValue("chromium.org"),
NULL);
// |a| has precedence over |b|.
c.Set(kTestPolicyName2,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
c.Set(kTestPolicyName3,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_ENTERPRISE_DEFAULT,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("a").release());
// POLICY_SCOPE_MACHINE over POLICY_SCOPE_USER for POLICY_LEVEL_RECOMMENDED.
c.Set(kTestPolicyName4,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_ENTERPRISE_OVERRIDE,
new base::FundamentalValue(true),
NULL);
// POLICY_LEVEL_MANDATORY over POLICY_LEVEL_RECOMMENDED.
c.Set(kTestPolicyName5,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_PLATFORM,
new base::StringValue(std::string()),
NULL);
// Merge new ones.
c.Set(kTestPolicyName6,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
@@ -284,41 +260,32 @@
a.Set(kTestPolicyName1,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com"),
NULL);
a.Set(kTestPolicyName2,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("dummy").release());
a.Set(kTestPolicyName3,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
a.Set(kTestPolicyName4,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("a").release());
a.Set(kTestPolicyName5,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(false),
NULL);
a.Set(kTestPolicyName6,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com/q={x}"),
NULL);
a.Set(kTestPolicyName7,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
@@ -326,41 +293,32 @@
b.Set(kTestPolicyName1,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com"),
NULL);
b.Set(kTestPolicyName2,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("dummy").release());
b.Set(kTestPolicyName3,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(false),
NULL);
b.Set(kTestPolicyName4,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- POLICY_SOURCE_CLOUD,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
NULL, CreateExternalDataFetcher("b").release());
b.Set(kTestPolicyName5,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(false),
NULL);
b.Set(kTestPolicyName6,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::StringValue("google.com/q={x}"),
NULL);
b.Set(kTestPolicyName8,
POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER,
- POLICY_SOURCE_CLOUD,
new base::FundamentalValue(true),
NULL);
@@ -389,38 +347,4 @@
EXPECT_EQ(6u, diff.size());
}
-TEST_F(PolicyMapTest, LoadFromSetsLevelScopeAndSource) {
- base::DictionaryValue policies;
- policies.SetString("TestPolicy1", "google.com");
- policies.SetBoolean("TestPolicy2", true);
- policies.SetInteger("TestPolicy3", -12321);
-
- PolicyMap loaded;
- loaded.LoadFrom(&policies,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_PLATFORM);
-
- PolicyMap expected;
- expected.Set("TestPolicy1",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_PLATFORM,
- new base::StringValue("google.com"),
- nullptr);
- expected.Set("TestPolicy2",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_PLATFORM,
- new base::FundamentalValue(true),
- nullptr);
- expected.Set("TestPolicy3",
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER,
- POLICY_SOURCE_PLATFORM,
- new base::FundamentalValue(-12321),
- nullptr);
- EXPECT_TRUE(loaded.Equals(expected));
-}
-
} // namespace policy
« no previous file with comments | « components/policy/core/common/policy_map.cc ('k') | components/policy/core/common/policy_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698