OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/prefs/overlay_user_pref_store.h" | 5 #include "base/prefs/overlay_user_pref_store.h" |
6 | 6 |
7 #include "base/prefs/pref_store_observer_mock.h" | 7 #include "base/prefs/pref_store_observer_mock.h" |
8 #include "base/prefs/testing_pref_store.h" | 8 #include "base/prefs/testing_pref_store.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 scoped_refptr<TestingPrefStore> underlay_; | 42 scoped_refptr<TestingPrefStore> underlay_; |
43 scoped_refptr<OverlayUserPrefStore> overlay_; | 43 scoped_refptr<OverlayUserPrefStore> overlay_; |
44 }; | 44 }; |
45 | 45 |
46 TEST_F(OverlayUserPrefStoreTest, Observer) { | 46 TEST_F(OverlayUserPrefStoreTest, Observer) { |
47 PrefStoreObserverMock obs; | 47 PrefStoreObserverMock obs; |
48 overlay_->AddObserver(&obs); | 48 overlay_->AddObserver(&obs); |
49 | 49 |
50 // Check that underlay first value is reported. | 50 // Check that underlay first value is reported. |
51 underlay_->SetValue(overlay_key, new FundamentalValue(42), | 51 underlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(42)), |
52 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 52 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
53 obs.VerifyAndResetChangedKey(overlay_key); | 53 obs.VerifyAndResetChangedKey(overlay_key); |
54 | 54 |
55 // Check that underlay overwriting is reported. | 55 // Check that underlay overwriting is reported. |
56 underlay_->SetValue(overlay_key, new FundamentalValue(43), | 56 underlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(43)), |
57 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 57 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
58 obs.VerifyAndResetChangedKey(overlay_key); | 58 obs.VerifyAndResetChangedKey(overlay_key); |
59 | 59 |
60 // Check that overwriting change in overlay is reported. | 60 // Check that overwriting change in overlay is reported. |
61 overlay_->SetValue(overlay_key, new FundamentalValue(44), | 61 overlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(44)), |
62 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 62 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
63 obs.VerifyAndResetChangedKey(overlay_key); | 63 obs.VerifyAndResetChangedKey(overlay_key); |
64 | 64 |
65 // Check that hidden underlay change is not reported. | 65 // Check that hidden underlay change is not reported. |
66 underlay_->SetValue(overlay_key, new FundamentalValue(45), | 66 underlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(45)), |
67 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 67 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
68 EXPECT_TRUE(obs.changed_keys.empty()); | 68 EXPECT_TRUE(obs.changed_keys.empty()); |
69 | 69 |
70 // Check that overlay remove is reported. | 70 // Check that overlay remove is reported. |
71 overlay_->RemoveValue(overlay_key, | 71 overlay_->RemoveValue(overlay_key, |
72 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 72 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
73 obs.VerifyAndResetChangedKey(overlay_key); | 73 obs.VerifyAndResetChangedKey(overlay_key); |
74 | 74 |
75 // Check that underlay remove is reported. | 75 // Check that underlay remove is reported. |
76 underlay_->RemoveValue(overlay_key, | 76 underlay_->RemoveValue(overlay_key, |
77 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 77 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
78 obs.VerifyAndResetChangedKey(overlay_key); | 78 obs.VerifyAndResetChangedKey(overlay_key); |
79 | 79 |
80 // Check respecting of silence. | 80 // Check respecting of silence. |
81 overlay_->SetValueSilently(overlay_key, new FundamentalValue(46), | 81 overlay_->SetValueSilently(overlay_key, |
| 82 make_scoped_ptr(new FundamentalValue(46)), |
82 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 83 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
83 EXPECT_TRUE(obs.changed_keys.empty()); | 84 EXPECT_TRUE(obs.changed_keys.empty()); |
84 | 85 |
85 overlay_->RemoveObserver(&obs); | 86 overlay_->RemoveObserver(&obs); |
86 | 87 |
87 // Check successful unsubscription. | 88 // Check successful unsubscription. |
88 underlay_->SetValue(overlay_key, new FundamentalValue(47), | 89 underlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(47)), |
89 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 90 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
90 overlay_->SetValue(overlay_key, new FundamentalValue(48), | 91 overlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(48)), |
91 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 92 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
92 EXPECT_TRUE(obs.changed_keys.empty()); | 93 EXPECT_TRUE(obs.changed_keys.empty()); |
93 } | 94 } |
94 | 95 |
95 TEST_F(OverlayUserPrefStoreTest, GetAndSet) { | 96 TEST_F(OverlayUserPrefStoreTest, GetAndSet) { |
96 const Value* value = NULL; | 97 const Value* value = NULL; |
97 EXPECT_FALSE(overlay_->GetValue(overlay_key, &value)); | 98 EXPECT_FALSE(overlay_->GetValue(overlay_key, &value)); |
98 EXPECT_FALSE(underlay_->GetValue(overlay_key, &value)); | 99 EXPECT_FALSE(underlay_->GetValue(overlay_key, &value)); |
99 | 100 |
100 underlay_->SetValue(overlay_key, new FundamentalValue(42), | 101 underlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(42)), |
101 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 102 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
102 | 103 |
103 // Value shines through: | 104 // Value shines through: |
104 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); | 105 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); |
105 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); | 106 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); |
106 | 107 |
107 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); | 108 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); |
108 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); | 109 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); |
109 | 110 |
110 overlay_->SetValue(overlay_key, new FundamentalValue(43), | 111 overlay_->SetValue(overlay_key, make_scoped_ptr(new FundamentalValue(43)), |
111 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 112 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
112 | 113 |
113 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); | 114 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); |
114 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 115 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
115 | 116 |
116 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); | 117 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); |
117 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); | 118 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); |
118 | 119 |
119 overlay_->RemoveValue(overlay_key, | 120 overlay_->RemoveValue(overlay_key, |
120 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 121 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
121 | 122 |
122 // Value shines through: | 123 // Value shines through: |
123 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); | 124 EXPECT_TRUE(overlay_->GetValue(overlay_key, &value)); |
124 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); | 125 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); |
125 | 126 |
126 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); | 127 EXPECT_TRUE(underlay_->GetValue(overlay_key, &value)); |
127 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); | 128 EXPECT_TRUE(base::FundamentalValue(42).Equals(value)); |
128 } | 129 } |
129 | 130 |
130 // Check that GetMutableValue does not return the dictionary of the underlay. | 131 // Check that GetMutableValue does not return the dictionary of the underlay. |
131 TEST_F(OverlayUserPrefStoreTest, ModifyDictionaries) { | 132 TEST_F(OverlayUserPrefStoreTest, ModifyDictionaries) { |
132 underlay_->SetValue(overlay_key, new DictionaryValue, | 133 underlay_->SetValue(overlay_key, make_scoped_ptr(new DictionaryValue), |
133 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 134 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
134 | 135 |
135 Value* modify = NULL; | 136 Value* modify = NULL; |
136 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modify)); | 137 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modify)); |
137 ASSERT_TRUE(modify); | 138 ASSERT_TRUE(modify); |
138 ASSERT_TRUE(modify->IsType(Value::TYPE_DICTIONARY)); | 139 ASSERT_TRUE(modify->IsType(Value::TYPE_DICTIONARY)); |
139 static_cast<DictionaryValue*>(modify)->SetInteger(overlay_key, 42); | 140 static_cast<DictionaryValue*>(modify)->SetInteger(overlay_key, 42); |
140 | 141 |
141 Value* original_in_underlay = NULL; | 142 Value* original_in_underlay = NULL; |
142 EXPECT_TRUE(underlay_->GetMutableValue(overlay_key, &original_in_underlay)); | 143 EXPECT_TRUE(underlay_->GetMutableValue(overlay_key, &original_in_underlay)); |
143 ASSERT_TRUE(original_in_underlay); | 144 ASSERT_TRUE(original_in_underlay); |
144 ASSERT_TRUE(original_in_underlay->IsType(Value::TYPE_DICTIONARY)); | 145 ASSERT_TRUE(original_in_underlay->IsType(Value::TYPE_DICTIONARY)); |
145 EXPECT_TRUE(static_cast<DictionaryValue*>(original_in_underlay)->empty()); | 146 EXPECT_TRUE(static_cast<DictionaryValue*>(original_in_underlay)->empty()); |
146 | 147 |
147 Value* modified = NULL; | 148 Value* modified = NULL; |
148 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modified)); | 149 EXPECT_TRUE(overlay_->GetMutableValue(overlay_key, &modified)); |
149 ASSERT_TRUE(modified); | 150 ASSERT_TRUE(modified); |
150 ASSERT_TRUE(modified->IsType(Value::TYPE_DICTIONARY)); | 151 ASSERT_TRUE(modified->IsType(Value::TYPE_DICTIONARY)); |
151 EXPECT_TRUE(Value::Equals(modify, static_cast<DictionaryValue*>(modified))); | 152 EXPECT_TRUE(Value::Equals(modify, static_cast<DictionaryValue*>(modified))); |
152 } | 153 } |
153 | 154 |
154 // Here we consider a global preference that is not overlayed. | 155 // Here we consider a global preference that is not overlayed. |
155 TEST_F(OverlayUserPrefStoreTest, GlobalPref) { | 156 TEST_F(OverlayUserPrefStoreTest, GlobalPref) { |
156 PrefStoreObserverMock obs; | 157 PrefStoreObserverMock obs; |
157 overlay_->AddObserver(&obs); | 158 overlay_->AddObserver(&obs); |
158 | 159 |
159 const Value* value = NULL; | 160 const Value* value = NULL; |
160 | 161 |
161 // Check that underlay first value is reported. | 162 // Check that underlay first value is reported. |
162 underlay_->SetValue(regular_key, new FundamentalValue(42), | 163 underlay_->SetValue(regular_key, make_scoped_ptr(new FundamentalValue(42)), |
163 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 164 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
164 obs.VerifyAndResetChangedKey(regular_key); | 165 obs.VerifyAndResetChangedKey(regular_key); |
165 | 166 |
166 // Check that underlay overwriting is reported. | 167 // Check that underlay overwriting is reported. |
167 underlay_->SetValue(regular_key, new FundamentalValue(43), | 168 underlay_->SetValue(regular_key, make_scoped_ptr(new FundamentalValue(43)), |
168 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 169 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
169 obs.VerifyAndResetChangedKey(regular_key); | 170 obs.VerifyAndResetChangedKey(regular_key); |
170 | 171 |
171 // Check that we get this value from the overlay | 172 // Check that we get this value from the overlay |
172 EXPECT_TRUE(overlay_->GetValue(regular_key, &value)); | 173 EXPECT_TRUE(overlay_->GetValue(regular_key, &value)); |
173 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 174 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
174 | 175 |
175 // Check that overwriting change in overlay is reported. | 176 // Check that overwriting change in overlay is reported. |
176 overlay_->SetValue(regular_key, new FundamentalValue(44), | 177 overlay_->SetValue(regular_key, make_scoped_ptr(new FundamentalValue(44)), |
177 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 178 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
178 obs.VerifyAndResetChangedKey(regular_key); | 179 obs.VerifyAndResetChangedKey(regular_key); |
179 | 180 |
180 // Check that we get this value from the overlay and the underlay. | 181 // Check that we get this value from the overlay and the underlay. |
181 EXPECT_TRUE(overlay_->GetValue(regular_key, &value)); | 182 EXPECT_TRUE(overlay_->GetValue(regular_key, &value)); |
182 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); | 183 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); |
183 EXPECT_TRUE(underlay_->GetValue(regular_key, &value)); | 184 EXPECT_TRUE(underlay_->GetValue(regular_key, &value)); |
184 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); | 185 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); |
185 | 186 |
186 // Check that overlay remove is reported. | 187 // Check that overlay remove is reported. |
187 overlay_->RemoveValue(regular_key, | 188 overlay_->RemoveValue(regular_key, |
188 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 189 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
189 obs.VerifyAndResetChangedKey(regular_key); | 190 obs.VerifyAndResetChangedKey(regular_key); |
190 | 191 |
191 // Check that value was removed from overlay and underlay | 192 // Check that value was removed from overlay and underlay |
192 EXPECT_FALSE(overlay_->GetValue(regular_key, &value)); | 193 EXPECT_FALSE(overlay_->GetValue(regular_key, &value)); |
193 EXPECT_FALSE(underlay_->GetValue(regular_key, &value)); | 194 EXPECT_FALSE(underlay_->GetValue(regular_key, &value)); |
194 | 195 |
195 // Check respecting of silence. | 196 // Check respecting of silence. |
196 overlay_->SetValueSilently(regular_key, new FundamentalValue(46), | 197 overlay_->SetValueSilently(regular_key, |
| 198 make_scoped_ptr(new FundamentalValue(46)), |
197 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 199 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
198 EXPECT_TRUE(obs.changed_keys.empty()); | 200 EXPECT_TRUE(obs.changed_keys.empty()); |
199 | 201 |
200 overlay_->RemoveObserver(&obs); | 202 overlay_->RemoveObserver(&obs); |
201 | 203 |
202 // Check successful unsubscription. | 204 // Check successful unsubscription. |
203 underlay_->SetValue(regular_key, new FundamentalValue(47), | 205 underlay_->SetValue(regular_key, make_scoped_ptr(new FundamentalValue(47)), |
204 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 206 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
205 overlay_->SetValue(regular_key, new FundamentalValue(48), | 207 overlay_->SetValue(regular_key, make_scoped_ptr(new FundamentalValue(48)), |
206 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 208 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
207 EXPECT_TRUE(obs.changed_keys.empty()); | 209 EXPECT_TRUE(obs.changed_keys.empty()); |
208 } | 210 } |
209 | 211 |
210 // Check that names mapping works correctly. | 212 // Check that names mapping works correctly. |
211 TEST_F(OverlayUserPrefStoreTest, NamesMapping) { | 213 TEST_F(OverlayUserPrefStoreTest, NamesMapping) { |
212 PrefStoreObserverMock obs; | 214 PrefStoreObserverMock obs; |
213 overlay_->AddObserver(&obs); | 215 overlay_->AddObserver(&obs); |
214 | 216 |
215 const Value* value = NULL; | 217 const Value* value = NULL; |
216 | 218 |
217 // Check that if there is no override in the overlay, changing underlay value | 219 // Check that if there is no override in the overlay, changing underlay value |
218 // is reported as changing an overlay value. | 220 // is reported as changing an overlay value. |
219 underlay_->SetValue(mapped_underlay_key, new FundamentalValue(42), | 221 underlay_->SetValue(mapped_underlay_key, |
| 222 make_scoped_ptr(new FundamentalValue(42)), |
220 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 223 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
221 obs.VerifyAndResetChangedKey(mapped_overlay_key); | 224 obs.VerifyAndResetChangedKey(mapped_overlay_key); |
222 | 225 |
223 // Check that underlay overwriting is reported. | 226 // Check that underlay overwriting is reported. |
224 underlay_->SetValue(mapped_underlay_key, new FundamentalValue(43), | 227 underlay_->SetValue(mapped_underlay_key, |
| 228 make_scoped_ptr(new FundamentalValue(43)), |
225 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 229 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
226 obs.VerifyAndResetChangedKey(mapped_overlay_key); | 230 obs.VerifyAndResetChangedKey(mapped_overlay_key); |
227 | 231 |
228 // Check that we get this value from the overlay with both keys | 232 // Check that we get this value from the overlay with both keys |
229 EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value)); | 233 EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value)); |
230 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 234 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
231 // In this case, overlay reads directly from the underlay. | 235 // In this case, overlay reads directly from the underlay. |
232 EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value)); | 236 EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value)); |
233 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 237 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
234 | 238 |
235 // Check that overwriting change in overlay is reported. | 239 // Check that overwriting change in overlay is reported. |
236 overlay_->SetValue(mapped_overlay_key, new FundamentalValue(44), | 240 overlay_->SetValue(mapped_overlay_key, |
| 241 make_scoped_ptr(new FundamentalValue(44)), |
237 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 242 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
238 obs.VerifyAndResetChangedKey(mapped_overlay_key); | 243 obs.VerifyAndResetChangedKey(mapped_overlay_key); |
239 | 244 |
240 // Check that we get an overriden value from overlay, while reading the | 245 // Check that we get an overriden value from overlay, while reading the |
241 // value from underlay still holds an old value. | 246 // value from underlay still holds an old value. |
242 EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value)); | 247 EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value)); |
243 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); | 248 EXPECT_TRUE(base::FundamentalValue(44).Equals(value)); |
244 EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value)); | 249 EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value)); |
245 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 250 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
246 EXPECT_TRUE(underlay_->GetValue(mapped_underlay_key, &value)); | 251 EXPECT_TRUE(underlay_->GetValue(mapped_underlay_key, &value)); |
247 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); | 252 EXPECT_TRUE(base::FundamentalValue(43).Equals(value)); |
248 | 253 |
249 // Check that hidden underlay change is not reported. | 254 // Check that hidden underlay change is not reported. |
250 underlay_->SetValue(mapped_underlay_key, new FundamentalValue(45), | 255 underlay_->SetValue(mapped_underlay_key, |
| 256 make_scoped_ptr(new FundamentalValue(45)), |
251 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 257 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
252 EXPECT_TRUE(obs.changed_keys.empty()); | 258 EXPECT_TRUE(obs.changed_keys.empty()); |
253 | 259 |
254 // Check that overlay remove is reported. | 260 // Check that overlay remove is reported. |
255 overlay_->RemoveValue(mapped_overlay_key, | 261 overlay_->RemoveValue(mapped_overlay_key, |
256 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 262 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
257 obs.VerifyAndResetChangedKey(mapped_overlay_key); | 263 obs.VerifyAndResetChangedKey(mapped_overlay_key); |
258 | 264 |
259 // Check that underlay remove is reported. | 265 // Check that underlay remove is reported. |
260 underlay_->RemoveValue(mapped_underlay_key, | 266 underlay_->RemoveValue(mapped_underlay_key, |
261 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 267 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
262 obs.VerifyAndResetChangedKey(mapped_overlay_key); | 268 obs.VerifyAndResetChangedKey(mapped_overlay_key); |
263 | 269 |
264 // Check that value was removed. | 270 // Check that value was removed. |
265 EXPECT_FALSE(overlay_->GetValue(mapped_overlay_key, &value)); | 271 EXPECT_FALSE(overlay_->GetValue(mapped_overlay_key, &value)); |
266 EXPECT_FALSE(overlay_->GetValue(mapped_underlay_key, &value)); | 272 EXPECT_FALSE(overlay_->GetValue(mapped_underlay_key, &value)); |
267 | 273 |
268 // Check respecting of silence. | 274 // Check respecting of silence. |
269 overlay_->SetValueSilently(mapped_overlay_key, new FundamentalValue(46), | 275 overlay_->SetValueSilently(mapped_overlay_key, |
| 276 make_scoped_ptr(new FundamentalValue(46)), |
270 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 277 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
271 EXPECT_TRUE(obs.changed_keys.empty()); | 278 EXPECT_TRUE(obs.changed_keys.empty()); |
272 | 279 |
273 overlay_->RemoveObserver(&obs); | 280 overlay_->RemoveObserver(&obs); |
274 | 281 |
275 // Check successful unsubscription. | 282 // Check successful unsubscription. |
276 underlay_->SetValue(mapped_underlay_key, new FundamentalValue(47), | 283 underlay_->SetValue(mapped_underlay_key, |
| 284 make_scoped_ptr(new FundamentalValue(47)), |
277 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 285 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
278 overlay_->SetValue(mapped_overlay_key, new FundamentalValue(48), | 286 overlay_->SetValue(mapped_overlay_key, |
| 287 make_scoped_ptr(new FundamentalValue(48)), |
279 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 288 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
280 EXPECT_TRUE(obs.changed_keys.empty()); | 289 EXPECT_TRUE(obs.changed_keys.empty()); |
281 } | 290 } |
282 | 291 |
283 } // namespace base | 292 } // namespace base |
OLD | NEW |