Index: chrome/browser/prefs/pref_service_unittest.cc |
diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc |
index 1286f9f76bbafc49286b3371af63e0e6a2c143e3..5f97a8ee0f0203fa64ed3b739bcfc7e9336e6e29 100644 |
--- a/chrome/browser/prefs/pref_service_unittest.cc |
+++ b/chrome/browser/prefs/pref_service_unittest.cc |
@@ -96,10 +96,12 @@ TEST(PrefServiceTest, HasPrefPath) { |
TEST(PrefServiceTest, Observers) { |
const char pref_name[] = "homepage"; |
+ const char pref_name_two[] = "homepage2"; |
TestingPrefService prefs; |
prefs.SetUserPref(pref_name, Value::CreateStringValue("http://www.cnn.com")); |
prefs.RegisterStringPref(pref_name, std::string()); |
+ prefs.RegisterStringPref(pref_name_two, std::string()); |
const char new_pref_value[] = "http://www.google.com/"; |
const StringValue expected_new_pref_value(new_pref_value); |
@@ -118,29 +120,31 @@ TEST(PrefServiceTest, Observers) { |
const StringValue expected_new_pref_value2(new_pref_value2); |
PrefObserverMock obs2; |
obs.Expect(&prefs, pref_name, &expected_new_pref_value2); |
- obs2.Expect(&prefs, pref_name, &expected_new_pref_value2); |
- registrar.Add(pref_name, &obs2); |
+ obs2.Expect(&prefs, pref_name_two, &expected_new_pref_value2); |
+ registrar.Add(pref_name_two, &obs2); |
Mattias Nissler (ping if slow)
2012/11/07 16:02:24
I think we should just declare a second registrar
Jói
2012/11/08 11:03:14
Done.
|
// This should fire the checks in obs and obs2. |
prefs.SetString(pref_name, new_pref_value2); |
+ prefs.SetString(pref_name_two, new_pref_value2); |
Mock::VerifyAndClearExpectations(&obs); |
Mock::VerifyAndClearExpectations(&obs2); |
// Set a recommended value. |
const StringValue recommended_pref_value("http://www.gmail.com/"); |
obs.Expect(&prefs, pref_name, &expected_new_pref_value2); |
- obs2.Expect(&prefs, pref_name, &expected_new_pref_value2); |
+ obs2.Expect(&prefs, pref_name_two, &expected_new_pref_value2); |
// This should fire the checks in obs and obs2 but with an unchanged value |
// as the recommended value is being overridden by the user-set value. |
prefs.SetRecommendedPref(pref_name, recommended_pref_value.DeepCopy()); |
+ prefs.SetRecommendedPref(pref_name_two, recommended_pref_value.DeepCopy()); |
Mock::VerifyAndClearExpectations(&obs); |
Mock::VerifyAndClearExpectations(&obs2); |
// Make sure obs2 still works after removing obs. |
- registrar.Remove(pref_name, &obs); |
+ registrar.Remove(pref_name); |
EXPECT_CALL(obs, OnPreferenceChanged(_, _)).Times(0); |
- obs2.Expect(&prefs, pref_name, &expected_new_pref_value); |
+ obs2.Expect(&prefs, pref_name_two, &expected_new_pref_value); |
// This should only fire the observer in obs2. |
- prefs.SetString(pref_name, new_pref_value); |
+ prefs.SetString(pref_name_two, new_pref_value); |
Mock::VerifyAndClearExpectations(&obs); |
Mock::VerifyAndClearExpectations(&obs2); |
} |