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

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

Issue 383263005: Remove more CreateIntegerValue calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/SetBoolean/SetInteger 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/policy_service_impl_unittest.cc
diff --git a/components/policy/core/common/policy_service_impl_unittest.cc b/components/policy/core/common/policy_service_impl_unittest.cc
index d8350b8d4ec87c121be13aa4b3c947ad3bcb41a2..6c3ac21217bf4a0e2380e7c56e94433cb16753ac 100644
--- a/components/policy/core/common/policy_service_impl_unittest.cc
+++ b/components/policy/core/common/policy_service_impl_unittest.cc
@@ -74,8 +74,11 @@ class ChangePolicyObserver : public PolicyService::Observer {
const PolicyMap& previous,
const PolicyMap& current) OVERRIDE {
PolicyMap new_policy;
- new_policy.Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(14), NULL);
+ new_policy.Set("foo",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(14),
+ NULL);
provider_->UpdateChromePolicy(new_policy);
observer_invoked_ = true;
}
@@ -104,8 +107,11 @@ class PolicyServiceTest : public testing::Test {
provider1_.Init();
provider2_.Init();
- policy0_.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(13), NULL);
+ policy0_.Set("pre",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(13),
+ NULL);
provider0_.UpdateChromePolicy(policy0_);
PolicyServiceImpl::Providers providers;
@@ -153,8 +159,11 @@ class PolicyServiceTest : public testing::Test {
TEST_F(PolicyServiceTest, LoadsPoliciesBeforeProvidersRefresh) {
PolicyMap expected;
- expected.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(13), NULL);
+ expected.Set("pre",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(13),
+ NULL);
EXPECT_TRUE(VerifyPolicies(
PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()), expected));
}
@@ -164,15 +173,24 @@ TEST_F(PolicyServiceTest, NotifyObservers) {
policy_service_->AddObserver(POLICY_DOMAIN_CHROME, &observer);
PolicyMap expectedPrevious;
- expectedPrevious.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(13), NULL);
+ expectedPrevious.Set("pre",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(13),
+ NULL);
PolicyMap expectedCurrent;
expectedCurrent.CopyFrom(expectedPrevious);
- expectedCurrent.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(123), NULL);
- policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(123), NULL);
+ expectedCurrent.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(123),
+ NULL);
+ policy0_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(123),
+ NULL);
EXPECT_CALL(observer, OnPolicyUpdated(PolicyNamespace(POLICY_DOMAIN_CHROME,
std::string()),
PolicyEquals(&expectedPrevious),
@@ -189,10 +207,16 @@ TEST_F(PolicyServiceTest, NotifyObservers) {
// New policy.
expectedPrevious.CopyFrom(expectedCurrent);
- expectedCurrent.Set("bbb", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(456), NULL);
- policy0_.Set("bbb", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(456), NULL);
+ expectedCurrent.Set("bbb",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(456),
+ NULL);
+ policy0_.Set("bbb",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(456),
+ NULL);
EXPECT_CALL(observer, OnPolicyUpdated(PolicyNamespace(POLICY_DOMAIN_CHROME,
std::string()),
PolicyEquals(&expectedPrevious),
@@ -213,10 +237,16 @@ TEST_F(PolicyServiceTest, NotifyObservers) {
// Changed policy.
expectedPrevious.CopyFrom(expectedCurrent);
- expectedCurrent.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(789), NULL);
- policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(789), NULL);
+ expectedCurrent.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(789),
+ NULL);
+ policy0_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(789),
+ NULL);
EXPECT_CALL(observer, OnPolicyUpdated(PolicyNamespace(POLICY_DOMAIN_CHROME,
std::string()),
@@ -245,8 +275,11 @@ TEST_F(PolicyServiceTest, NotifyObserversInMultipleNamespaces) {
policy_service_->AddObserver(POLICY_DOMAIN_EXTENSIONS, &extension_observer);
PolicyMap previous_policy_map;
- previous_policy_map.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(13), NULL);
+ previous_policy_map.Set("pre",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(13),
+ NULL);
PolicyMap policy_map;
policy_map.CopyFrom(previous_policy_map);
policy_map.Set("policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
@@ -324,10 +357,16 @@ TEST_F(PolicyServiceTest, NotifyObserversInMultipleNamespaces) {
TEST_F(PolicyServiceTest, ObserverChangesPolicy) {
ChangePolicyObserver observer(&provider0_);
policy_service_->AddObserver(POLICY_DOMAIN_CHROME, &observer);
- policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(123), NULL);
- policy0_.Set("bbb", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(1234), NULL);
+ policy0_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(123),
+ NULL);
+ policy0_.Set("bbb",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(1234),
+ NULL);
// Should not crash.
provider0_.UpdateChromePolicy(policy0_);
policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, &observer);
@@ -336,33 +375,57 @@ TEST_F(PolicyServiceTest, ObserverChangesPolicy) {
TEST_F(PolicyServiceTest, Priorities) {
PolicyMap expected;
- expected.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(13), NULL);
- expected.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(0), NULL);
- policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(0), NULL);
- policy1_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(1), NULL);
- policy2_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(2), NULL);
+ expected.Set("pre",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(13),
+ NULL);
+ expected.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(0),
+ NULL);
+ policy0_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(0),
+ NULL);
+ policy1_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(1),
+ NULL);
+ policy2_.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(2),
+ NULL);
provider0_.UpdateChromePolicy(policy0_);
provider1_.UpdateChromePolicy(policy1_);
provider2_.UpdateChromePolicy(policy2_);
EXPECT_TRUE(VerifyPolicies(
PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()), expected));
- expected.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(1), NULL);
+ expected.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(1),
+ NULL);
policy0_.Erase("aaa");
provider0_.UpdateChromePolicy(policy0_);
EXPECT_TRUE(VerifyPolicies(
PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()), expected));
- expected.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(2), NULL);
- policy1_.Set("aaa", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(1), NULL);
+ expected.Set("aaa",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(2),
+ NULL);
+ policy1_.Set("aaa",
+ POLICY_LEVEL_RECOMMENDED,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(1),
+ NULL);
provider1_.UpdateChromePolicy(policy1_);
EXPECT_TRUE(VerifyPolicies(
PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()), expected));
@@ -611,8 +674,11 @@ TEST_F(PolicyServiceTest, FixDeprecatedPolicies) {
PolicyMap& policy_map = policy_bundle->Get(chrome_namespace);
// Individual proxy policy values in the Chrome namespace should be collected
// into a dictionary.
- policy_map.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, base::Value::CreateIntegerValue(3), NULL);
+ policy_map.Set(key::kProxyServerMode,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(3),
+ NULL);
// Both these policies should be ignored, since there's a higher priority
// policy available.
@@ -623,9 +689,11 @@ TEST_F(PolicyServiceTest, FixDeprecatedPolicies) {
NULL);
// Add a value to a non-Chrome namespace.
- policy_bundle->Get(extension_namespace)
- .Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateIntegerValue(3), NULL);
+ policy_bundle->Get(extension_namespace).Set(key::kProxyServerMode,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(3),
+ NULL);
// The resulting Chrome namespace map should have the collected policy.
PolicyMap expected_chrome;
@@ -636,8 +704,10 @@ TEST_F(PolicyServiceTest, FixDeprecatedPolicies) {
// The resulting Extensions namespace map shouldn't have been modified.
PolicyMap expected_extension;
- expected_extension.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER, base::Value::CreateIntegerValue(3),
+ expected_extension.Set(key::kProxyServerMode,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(3),
NULL);
provider0_.UpdatePolicy(policy_bundle.Pass());
« no previous file with comments | « components/policy/core/common/policy_bundle_unittest.cc ('k') | components/policy/core/common/preg_parser_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698