Chromium Code Reviews| 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..9142829138e7dde88c2ee7148b1fe69898891112 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,60 @@ 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.push_back(ValueStoreChange("ccc", NULL, value.DeepCopy())); |
| - policies.Set("ccc", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| - value.DeepCopy(), NULL); |
| + changes.clear(); |
|
not at google - send to devlin
2013/11/13 00:30:18
I prefer scoping these sorts of thing explicitly u
Joao da Silva
2013/11/13 08:56:47
Done.
|
| + changes.push_back(ValueStoreChange("bbb", NULL, value.DeepCopy())); |
| EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId, |
| settings_namespace::MANAGED, |
| ValueStoreChange::ToJson(changes))); |
| - store_->SetCurrentPolicy(policies, true); |
| + policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| + value.DeepCopy(), NULL); |
| + store_->SetCurrentPolicy(policies); |
| loop_.RunUntilIdle(); |
| Mock::VerifyAndClearExpectations(&observer_); |
| // Notify when policies change. |
| changes.clear(); |
| - base::StringValue new_value("444"); |
| + base::StringValue new_value("222"); |
| 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); |
| + ValueStoreChange("bbb", value.DeepCopy(), new_value.DeepCopy())); |
| EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId, |
| settings_namespace::MANAGED, |
| ValueStoreChange::ToJson(changes))); |
| - store_->SetCurrentPolicy(policies, true); |
| + policies.Set("bbb", 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"); |
| + changes.push_back(ValueStoreChange("bbb", new_value.DeepCopy(), NULL)); |
| EXPECT_CALL(observer_, OnSettingsChanged(kTestExtensionId, |
| settings_namespace::MANAGED, |
| ValueStoreChange::ToJson(changes))); |
| - store_->SetCurrentPolicy(policies, true); |
| + 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_); |
| } |