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

Unified Diff: components/policy/core/browser/configuration_policy_handler_unittest.cc

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 another test. 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
Index: components/policy/core/browser/configuration_policy_handler_unittest.cc
diff --git a/components/policy/core/browser/configuration_policy_handler_unittest.cc b/components/policy/core/browser/configuration_policy_handler_unittest.cc
index 67b66049ae9f090344caeeefb58c2d1cad61c856..57db6d6fedd76d3e59cc836f2bd940cf9ebe49d9 100644
--- a/components/policy/core/browser/configuration_policy_handler_unittest.cc
+++ b/components/policy/core/browser/configuration_policy_handler_unittest.cc
@@ -11,6 +11,7 @@
#include "components/policy/core/browser/configuration_policy_handler.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
+#include "components/policy/core/common/policy_types.h"
#include "components/policy/core/common/schema.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -56,22 +57,22 @@ TEST(StringToIntEnumListPolicyHandlerTest, CheckPolicySettings) {
kTestPref,
base::Bind(GetIntegerTypeMap));
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
errors.Clear();
EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
EXPECT_TRUE(errors.empty());
list.AppendString("one");
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
errors.Clear();
EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
EXPECT_TRUE(errors.empty());
list.AppendString("invalid");
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
errors.Clear();
EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
EXPECT_FALSE(errors.empty());
@@ -80,6 +81,7 @@ TEST(StringToIntEnumListPolicyHandlerTest, CheckPolicySettings) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::StringValue("no list"),
NULL);
errors.Clear();
@@ -99,23 +101,23 @@ TEST(StringMappingListPolicyHandlerTest, ApplyPolicySettings) {
kTestPref,
base::Bind(GetIntegerTypeMap));
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
handler.ApplyPolicySettings(policy_map, &prefs);
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(&expected, value));
list.AppendString("two");
expected.AppendInteger(2);
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
handler.ApplyPolicySettings(policy_map, &prefs);
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(&expected, value));
list.AppendString("invalid");
- policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, list.DeepCopy(), NULL);
+ policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD, list.DeepCopy(), nullptr);
handler.ApplyPolicySettings(policy_map, &prefs);
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(&expected, value));
@@ -133,6 +135,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
errors.Clear();
@@ -142,6 +145,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
errors.Clear();
@@ -151,6 +155,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
errors.Clear();
@@ -162,6 +167,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
errors.Clear();
@@ -171,6 +177,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
errors.Clear();
@@ -182,6 +189,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::StringValue("invalid"),
NULL);
errors.Clear();
@@ -201,6 +209,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
errors.Clear();
@@ -210,6 +219,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
errors.Clear();
@@ -219,6 +229,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
errors.Clear();
@@ -230,6 +241,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
errors.Clear();
@@ -239,6 +251,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
errors.Clear();
@@ -250,6 +263,7 @@ TEST(IntRangePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::StringValue("invalid"),
NULL);
errors.Clear();
@@ -271,6 +285,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
prefs.Clear();
@@ -282,6 +297,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
prefs.Clear();
@@ -293,6 +309,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
prefs.Clear();
@@ -306,6 +323,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
prefs.Clear();
@@ -317,6 +335,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
prefs.Clear();
@@ -340,6 +359,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
prefs.Clear();
@@ -351,6 +371,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
prefs.Clear();
@@ -362,6 +383,7 @@ TEST(IntRangePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
prefs.Clear();
@@ -384,6 +406,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
errors.Clear();
@@ -393,6 +416,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
errors.Clear();
@@ -402,6 +426,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
errors.Clear();
@@ -413,6 +438,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
errors.Clear();
@@ -422,6 +448,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
errors.Clear();
@@ -433,6 +460,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::StringValue("invalid"),
NULL);
errors.Clear();
@@ -453,6 +481,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
errors.Clear();
@@ -462,6 +491,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
errors.Clear();
@@ -471,6 +501,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
errors.Clear();
@@ -482,6 +513,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
errors.Clear();
@@ -491,6 +523,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
errors.Clear();
@@ -502,6 +535,7 @@ TEST(IntPercentageToDoublePolicyHandler, CheckPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::StringValue("invalid"),
NULL);
errors.Clear();
@@ -524,6 +558,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
prefs.Clear();
@@ -535,6 +570,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
prefs.Clear();
@@ -546,6 +582,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
prefs.Clear();
@@ -559,6 +596,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(-5),
NULL);
prefs.Clear();
@@ -570,6 +608,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(15),
NULL);
prefs.Clear();
@@ -594,6 +633,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(0),
NULL);
prefs.Clear();
@@ -605,6 +645,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(5),
NULL);
prefs.Clear();
@@ -616,6 +657,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
policy_map.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
new base::FundamentalValue(10),
NULL);
prefs.Clear();
@@ -661,8 +703,8 @@ TEST(SchemaValidatingPolicyHandlerTest, CheckAndGetValue) {
ASSERT_TRUE(policy_map_value->GetAsDictionary(&policy_map_dict));
PolicyMap policy_map;
- policy_map.LoadFrom(
- policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER);
+ policy_map.LoadFrom(policy_map_dict, POLICY_LEVEL_RECOMMENDED,
+ POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD);
TestSchemaValidatingPolicyHandler handler(schema, SCHEMA_ALLOW_INVALID);
scoped_ptr<base::Value> output_value;
@@ -722,11 +764,13 @@ TEST(SimpleSchemaValidatingPolicyHandlerTest, CheckAndGetValue) {
PolicyMap policy_map_recommended;
policy_map_recommended.LoadFrom(
- policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER);
+ policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD);
PolicyMap policy_map_mandatory;
policy_map_mandatory.LoadFrom(
- policy_map_dict, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
+ policy_map_dict, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD);
SimpleSchemaValidatingPolicyHandler handler_all(
policy_name,

Powered by Google App Engine
This is Rietveld 408576698