1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/user_prefs/tracked/mock_validation_delegate.h"
7 MockValidationDelegate::MockValidationDelegate() {
10 MockValidationDelegate::~MockValidationDelegate() {
13 size_t MockValidationDelegate::CountValidationsOfState(
14 PrefHashStoreTransaction::ValueState value_state
) const {
16 for (size_t i
= 0; i
< validations_
.size(); ++i
) {
17 if (validations_
[i
].value_state
== value_state
)
23 const MockValidationDelegate::ValidationEvent
*
24 MockValidationDelegate::GetEventForPath(const std::string
& pref_path
) const {
25 for (size_t i
= 0; i
< validations_
.size(); ++i
) {
26 if (validations_
[i
].pref_path
== pref_path
)
27 return &validations_
[i
];
32 void MockValidationDelegate::OnAtomicPreferenceValidation(
33 const std::string
& pref_path
,
34 const base::Value
* value
,
35 PrefHashStoreTransaction::ValueState value_state
,
37 RecordValidation(pref_path
, value_state
, is_personal
,
38 PrefHashFilter::TRACKING_STRATEGY_ATOMIC
);
41 void MockValidationDelegate::OnSplitPreferenceValidation(
42 const std::string
& pref_path
,
43 const base::DictionaryValue
* dict_value
,
44 const std::vector
<std::string
>& invalid_keys
,
45 PrefHashStoreTransaction::ValueState value_state
,
47 RecordValidation(pref_path
, value_state
, is_personal
,
48 PrefHashFilter::TRACKING_STRATEGY_SPLIT
);
51 void MockValidationDelegate::RecordValidation(
52 const std::string
& pref_path
,
53 PrefHashStoreTransaction::ValueState value_state
,
55 PrefHashFilter::PrefTrackingStrategy strategy
) {
56 validations_
.push_back(
57 ValidationEvent(pref_path
, value_state
, is_personal
, strategy
));