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

Unified Diff: chrome/browser/extensions/api/storage/policy_value_store_unittest.cc

Issue 60823003: Introduced a ForwardingPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed ios Created 7 years, 1 month 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/extensions/api/storage/policy_value_store_unittest.cc
diff --git a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc b/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc
index d2b19b00e80e37286fc473a911dd3b80420093b9..cbf99ad8e3c64de2564b0fdcce0cacacaa02079b 100644
--- a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc
+++ b/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc
@@ -125,7 +125,7 @@ TEST_F(PolicyValueStoreTest, DontProvideRecommendedPolicies) {
policies.Set("may", policy::POLICY_LEVEL_RECOMMENDED,
policy::POLICY_SCOPE_USER,
new base::FundamentalValue(456), NULL);
- store_->SetCurrentPolicy(policies, false);
+ store_->SetCurrentPolicy(policies);
ValueStore::ReadResult result = store_->Get();
ASSERT_FALSE(result->HasError());
EXPECT_EQ(1u, result->settings().size());
@@ -153,66 +153,76 @@ TEST_F(PolicyValueStoreTest, ReadOnly) {
}
TEST_F(PolicyValueStoreTest, NotifyOnChanges) {
- policy::PolicyMap policies;
- policies.Set("aaa", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
- new base::StringValue("111"), NULL);
- EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0);
- // No notification when setting the initial policy.
- store_->SetCurrentPolicy(policies, false);
- loop_.RunUntilIdle();
- Mock::VerifyAndClearExpectations(&observer_);
+ // Notify when setting the initial policy.
+ const base::StringValue value("111");
+ {
+ ValueStoreChangeList changes;
+ changes.push_back(ValueStoreChange("aaa", NULL, value.DeepCopy()));
+ EXPECT_CALL(observer_,
+ OnSettingsChanged(kTestExtensionId,
+ settings_namespace::MANAGED,
+ ValueStoreChange::ToJson(changes)));
+ }
- // And no notifications on changes when not asked for.
+ policy::PolicyMap policies;
policies.Set("aaa", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
- new base::StringValue("222"), NULL);
- policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
- new base::StringValue("223"), NULL);
- EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0);
- store_->SetCurrentPolicy(policies, false);
+ value.DeepCopy(), NULL);
+ store_->SetCurrentPolicy(policies);
loop_.RunUntilIdle();
Mock::VerifyAndClearExpectations(&observer_);
// Notify when new policies are added.
- ValueStoreChangeList changes;
- base::StringValue value("333");
- changes.push_back(ValueStoreChange("ccc", NULL, value.DeepCopy()));
- policies.Set("ccc", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+ {
+ ValueStoreChangeList changes;
+ changes.push_back(ValueStoreChange("bbb", NULL, value.DeepCopy()));
+ EXPECT_CALL(observer_,
+ OnSettingsChanged(kTestExtensionId,
+ settings_namespace::MANAGED,
+ ValueStoreChange::ToJson(changes)));
+ }
+
+ policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
value.DeepCopy(), NULL);
- EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId,
- settings_namespace::MANAGED,
- ValueStoreChange::ToJson(changes)));
- store_->SetCurrentPolicy(policies, true);
+ store_->SetCurrentPolicy(policies);
loop_.RunUntilIdle();
Mock::VerifyAndClearExpectations(&observer_);
// Notify when policies change.
- changes.clear();
- base::StringValue new_value("444");
- changes.push_back(
- ValueStoreChange("ccc", value.DeepCopy(), new_value.DeepCopy()));
- policies.Set("ccc", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+ const base::StringValue new_value("222");
+ {
+ ValueStoreChangeList changes;
+ changes.push_back(
+ ValueStoreChange("bbb", value.DeepCopy(), new_value.DeepCopy()));
+ EXPECT_CALL(observer_,
+ OnSettingsChanged(kTestExtensionId,
+ settings_namespace::MANAGED,
+ ValueStoreChange::ToJson(changes)));
+ }
+
+ policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
new_value.DeepCopy(), NULL);
- EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId,
- settings_namespace::MANAGED,
- ValueStoreChange::ToJson(changes)));
- store_->SetCurrentPolicy(policies, true);
+ store_->SetCurrentPolicy(policies);
loop_.RunUntilIdle();
Mock::VerifyAndClearExpectations(&observer_);
// Notify when policies are removed.
- changes.clear();
- changes.push_back(ValueStoreChange("ccc", new_value.DeepCopy(), NULL));
- policies.Erase("ccc");
- EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId,
- settings_namespace::MANAGED,
- ValueStoreChange::ToJson(changes)));
- store_->SetCurrentPolicy(policies, true);
+ {
+ ValueStoreChangeList changes;
+ changes.push_back(ValueStoreChange("bbb", new_value.DeepCopy(), NULL));
+ EXPECT_CALL(observer_,
+ OnSettingsChanged(kTestExtensionId,
+ settings_namespace::MANAGED,
+ ValueStoreChange::ToJson(changes)));
+ }
+
+ policies.Erase("bbb");
+ store_->SetCurrentPolicy(policies);
loop_.RunUntilIdle();
Mock::VerifyAndClearExpectations(&observer_);
- // Don't notify when there aren't changes.
+ // Don't notify when there aren't any changes.
EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0);
- store_->SetCurrentPolicy(policies, true);
+ store_->SetCurrentPolicy(policies);
loop_.RunUntilIdle();
Mock::VerifyAndClearExpectations(&observer_);
}
« no previous file with comments | « chrome/browser/extensions/api/storage/policy_value_store.cc ('k') | chrome/browser/extensions/api/storage/settings_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698