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

Side by Side Diff: chrome/browser/prefs/mock_validation_delegate.h

Issue 266553002: Add TrackedPreferenceValidationDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to r272759 Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_PREFS_MOCK_VALIDATION_DELEGATE_H_
6 #define CHROME_BROWSER_PREFS_MOCK_VALIDATION_DELEGATE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "chrome/browser/prefs/pref_hash_filter.h"
14 #include "chrome/browser/prefs/pref_hash_store_transaction.h"
15 #include "chrome/browser/prefs/tracked/tracked_preference_helper.h"
16 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h"
17
18 // A mock tracked preference validation delegate for use by tests.
19 class MockValidationDelegate : public TrackedPreferenceValidationDelegate {
20 public:
21 struct ValidationEvent {
22 ValidationEvent(const std::string& path,
23 PrefHashStoreTransaction::ValueState state,
24 TrackedPreferenceHelper::ResetAction action,
25 PrefHashFilter::PrefTrackingStrategy tracking_strategy)
26 : pref_path(path),
27 value_state(state),
28 reset_action(action),
29 strategy(tracking_strategy) {}
30
31 std::string pref_path;
32 PrefHashStoreTransaction::ValueState value_state;
33 TrackedPreferenceHelper::ResetAction reset_action;
34 PrefHashFilter::PrefTrackingStrategy strategy;
35 };
36
37 MockValidationDelegate();
38 virtual ~MockValidationDelegate();
39
40 // Returns the number of recorded validations.
41 size_t recorded_validations_count() const { return validations_.size(); }
42
43 // Returns the number of validations of a given value state.
44 size_t CountValidationsOfState(
45 PrefHashStoreTransaction::ValueState value_state) const;
46
47 // Returns the event for the preference with a given path.
48 const ValidationEvent* GetEventForPath(const std::string& pref_path) const;
49
50 // TrackedPreferenceValidationDelegate implementation.
51 virtual void OnAtomicPreferenceValidation(
52 const std::string& pref_path,
53 const base::Value* value,
54 PrefHashStoreTransaction::ValueState value_state,
55 TrackedPreferenceHelper::ResetAction reset_action) OVERRIDE;
56 virtual void OnSplitPreferenceValidation(
57 const std::string& pref_path,
58 const base::DictionaryValue* dict_value,
59 const std::vector<std::string>& invalid_keys,
60 PrefHashStoreTransaction::ValueState value_state,
61 TrackedPreferenceHelper::ResetAction reset_action) OVERRIDE;
62
63 private:
64 // Adds a new validation event.
65 void RecordValidation(const std::string& pref_path,
66 PrefHashStoreTransaction::ValueState value_state,
67 TrackedPreferenceHelper::ResetAction reset_action,
68 PrefHashFilter::PrefTrackingStrategy strategy);
69
70 std::vector<ValidationEvent> validations_;
Mattias Nissler (ping if slow) 2014/05/26 07:01:15 nit: I think the majority of our files put a blank
grt (UTC plus 2) 2014/05/26 13:28:16 Done.
71 DISALLOW_COPY_AND_ASSIGN(MockValidationDelegate);
72 };
73
74 #endif // CHROME_BROWSER_PREFS_MOCK_VALIDATION_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698