xref: /aosp_15_r20/external/cronet/components/prefs/pref_store_observer_mock.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2011 The Chromium Authors
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 COMPONENTS_PREFS_PREF_STORE_OBSERVER_MOCK_H_
6 #define COMPONENTS_PREFS_PREF_STORE_OBSERVER_MOCK_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/compiler_specific.h"
12 #include "components/prefs/pref_store.h"
13 
14 // A mock implementation of PrefStore::Observer.
15 class PrefStoreObserverMock : public PrefStore::Observer {
16  public:
17   PrefStoreObserverMock();
18 
19   PrefStoreObserverMock(const PrefStoreObserverMock&) = delete;
20   PrefStoreObserverMock& operator=(const PrefStoreObserverMock&) = delete;
21 
22   ~PrefStoreObserverMock() override;
23 
24   void VerifyAndResetChangedKey(const std::string& expected);
25 
26   // PrefStore::Observer implementation
27   void OnPrefValueChanged(const std::string& key) override;
28   void OnInitializationCompleted(bool success) override;
29 
30   std::vector<std::string> changed_keys;
31   bool initialized;
32   bool initialization_success;  // Only valid if |initialized|.
33 };
34 
35 #endif  // COMPONENTS_PREFS_PREF_STORE_OBSERVER_MOCK_H_
36