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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/prefs/json_pref_store.h" | 7 #include "base/prefs/json_pref_store.h" |
8 #include "base/prefs/mock_pref_change_callback.h" | 8 #include "base/prefs/mock_pref_change_callback.h" |
9 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // values to it. | 232 // values to it. |
233 class WriteFlagChecker : public TestingPrefStore { | 233 class WriteFlagChecker : public TestingPrefStore { |
234 public: | 234 public: |
235 WriteFlagChecker() {} | 235 WriteFlagChecker() {} |
236 | 236 |
237 void ReportValueChanged(const std::string& key, uint32 flags) override { | 237 void ReportValueChanged(const std::string& key, uint32 flags) override { |
238 SetLastWriteFlags(flags); | 238 SetLastWriteFlags(flags); |
239 } | 239 } |
240 | 240 |
241 void SetValue(const std::string& key, | 241 void SetValue(const std::string& key, |
242 base::Value* value, | 242 scoped_ptr<base::Value> value, |
243 uint32 flags) override { | 243 uint32 flags) override { |
244 SetLastWriteFlags(flags); | 244 SetLastWriteFlags(flags); |
245 delete value; | |
246 } | 245 } |
247 | 246 |
248 void SetValueSilently(const std::string& key, | 247 void SetValueSilently(const std::string& key, |
249 base::Value* value, | 248 scoped_ptr<base::Value> value, |
250 uint32 flags) override { | 249 uint32 flags) override { |
251 SetLastWriteFlags(flags); | 250 SetLastWriteFlags(flags); |
252 delete value; | |
253 } | 251 } |
254 | 252 |
255 void RemoveValue(const std::string& key, uint32 flags) override { | 253 void RemoveValue(const std::string& key, uint32 flags) override { |
256 SetLastWriteFlags(flags); | 254 SetLastWriteFlags(flags); |
257 } | 255 } |
258 | 256 |
259 uint32 GetLastFlagsAndClear() { | 257 uint32 GetLastFlagsAndClear() { |
260 CHECK(last_write_flags_set_); | 258 CHECK(last_write_flags_set_); |
261 uint32 result = last_write_flags_; | 259 uint32 result = last_write_flags_; |
262 last_write_flags_set_ = false; | 260 last_write_flags_set_ = false; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 417 |
420 EXPECT_CALL(observer_, OnPreferenceChanged(_)).Times(0); | 418 EXPECT_CALL(observer_, OnPreferenceChanged(_)).Times(0); |
421 prefs_.Set(kName, new_value); | 419 prefs_.Set(kName, new_value); |
422 Mock::VerifyAndClearExpectations(&observer_); | 420 Mock::VerifyAndClearExpectations(&observer_); |
423 | 421 |
424 base::ListValue empty; | 422 base::ListValue empty; |
425 observer_.Expect(kName, &empty); | 423 observer_.Expect(kName, &empty); |
426 prefs_.Set(kName, empty); | 424 prefs_.Set(kName, empty); |
427 Mock::VerifyAndClearExpectations(&observer_); | 425 Mock::VerifyAndClearExpectations(&observer_); |
428 } | 426 } |
OLD | NEW |