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

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

Issue 210063003: Refactor TestingPrefStore to make it useful to some tests of load errors and asynchrony. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adopt a non-gmock approach in the clients. Created 6 years, 9 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
« base/prefs/testing_pref_store.cc ('K') | « base/prefs/testing_pref_store.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/browser/configuration_policy_pref_store_unittest.cc
diff --git a/components/policy/core/browser/configuration_policy_pref_store_unittest.cc b/components/policy/core/browser/configuration_policy_pref_store_unittest.cc
index c277253246504a7a0b167dbb81d229247eb41052..7415788e00c885bccfb0168ee54fd19bcf0ce725 100644
--- a/components/policy/core/browser/configuration_policy_pref_store_unittest.cc
+++ b/components/policy/core/browser/configuration_policy_pref_store_unittest.cc
@@ -176,7 +176,6 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) {
const base::Value* value = NULL;
EXPECT_FALSE(store_->GetValue(kTestPolicy, NULL));
- EXPECT_CALL(observer_, OnPrefValueChanged(kTestPref)).Times(1);
PolicyMap policy;
policy.Set(kTestPolicy,
POLICY_LEVEL_MANDATORY,
@@ -184,18 +183,22 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) {
base::Value::CreateStringValue("http://www.chromium.org"),
NULL);
UpdateProviderPolicy(policy);
- Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_EQ(1u, observer_.changed_keys.size());
+ if (observer_.changed_keys.size() >= 1)
+ EXPECT_EQ(kTestPref, observer_.changed_keys[0]);
+ observer_.changed_keys.clear();
Mattias Nissler (ping if slow) 2014/03/27 20:28:05 Let's add a Reset() member function to PrefStoreOb
erikwright (departed) 2014/03/28 12:29:22 I assume you mean the VerifyChangedKeyAndReset(),
Mattias Nissler (ping if slow) 2014/03/28 12:32:53 Yes, sounds good.
EXPECT_TRUE(store_->GetValue(kTestPref, &value));
EXPECT_TRUE(base::StringValue("http://www.chromium.org").Equals(value));
- EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0);
UpdateProviderPolicy(policy);
- Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_TRUE(observer_.changed_keys.empty());
- EXPECT_CALL(observer_, OnPrefValueChanged(kTestPref)).Times(1);
policy.Erase(kTestPolicy);
UpdateProviderPolicy(policy);
- Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_EQ(1u, observer_.changed_keys.size());
+ if (observer_.changed_keys.size() >= 1)
+ EXPECT_EQ(kTestPref, observer_.changed_keys[0]);
+ observer_.changed_keys.clear();
EXPECT_FALSE(store_->GetValue(kTestPref, NULL));
}
@@ -203,9 +206,10 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) {
EXPECT_FALSE(store_->IsInitializationComplete());
EXPECT_CALL(provider_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
.WillRepeatedly(Return(true));
- EXPECT_CALL(observer_, OnInitializationCompleted(true)).Times(1);
PolicyMap policy;
UpdateProviderPolicy(policy);
+ EXPECT_TRUE(observer_.initialized);
+ EXPECT_TRUE(observer_.initialization_success);
Mock::VerifyAndClearExpectations(&observer_);
EXPECT_TRUE(store_->IsInitializationComplete());
}
« base/prefs/testing_pref_store.cc ('K') | « base/prefs/testing_pref_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698