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..85c6d58efc998d74a0e8dd54e9061c02b902cedb 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,35 +153,29 @@ TEST_F(PolicyValueStoreTest, ReadOnly) { |
} |
TEST_F(PolicyValueStoreTest, NotifyOnChanges) { |
+ // Notify when setting the initial policy. |
+ ValueStoreChangeList changes; |
+ base::StringValue value("111"); |
+ changes.push_back(ValueStoreChange("aaa", NULL, value.DeepCopy())); |
+ EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId, |
+ settings_namespace::MANAGED, |
+ ValueStoreChange::ToJson(changes))); |
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_); |
- |
- // And no notifications on changes when not asked for. |
- 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.clear(); |
changes.push_back(ValueStoreChange("ccc", NULL, value.DeepCopy())); |
bartfab (slow)
2013/11/11 14:40:08
Nit: I guess this could be "bbb" now since you sni
Joao da Silva
2013/11/12 15:26:33
Done.
|
- policies.Set("ccc", 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); |
+ policies.Set("ccc", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
+ value.DeepCopy(), NULL); |
+ store_->SetCurrentPolicy(policies); |
loop_.RunUntilIdle(); |
Mock::VerifyAndClearExpectations(&observer_); |
@@ -190,29 +184,29 @@ TEST_F(PolicyValueStoreTest, NotifyOnChanges) { |
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, |
- new_value.DeepCopy(), NULL); |
EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId, |
settings_namespace::MANAGED, |
ValueStoreChange::ToJson(changes))); |
- store_->SetCurrentPolicy(policies, true); |
+ policies.Set("ccc", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
+ new_value.DeepCopy(), NULL); |
+ 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); |
+ policies.Erase("ccc"); |
+ store_->SetCurrentPolicy(policies); |
loop_.RunUntilIdle(); |
Mock::VerifyAndClearExpectations(&observer_); |
// Don't notify when there aren't changes. |
bartfab (slow)
2013/11/11 14:40:08
Nit: s/arent't/aren't any/
Joao da Silva
2013/11/12 15:26:33
Done.
|
EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0); |
- store_->SetCurrentPolicy(policies, true); |
+ store_->SetCurrentPolicy(policies); |
loop_.RunUntilIdle(); |
Mock::VerifyAndClearExpectations(&observer_); |
} |