OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 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_TESTING_PREF_STORE_H_ | |
6 #define CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/scoped_ptr.h" | |
11 #include "chrome/common/pref_store_base.h" | |
12 | |
13 class DictionaryValue; | |
14 | |
15 // |TestingPrefStore| is a stub implementation of the |PrefStore| interface. | |
16 // It allows to get and set the state of the |PrefStore| as well as triggering | |
17 // notifications. | |
18 class TestingPrefStore : public PrefStoreBase { | |
19 public: | |
20 TestingPrefStore(); | |
21 virtual ~TestingPrefStore() {} | |
22 | |
23 virtual DictionaryValue* prefs() const { return prefs_.get(); } | |
24 | |
25 virtual PrefStore::PrefReadError ReadPrefs(); | |
26 | |
27 virtual bool ReadOnly() const { return read_only_; } | |
28 | |
29 virtual bool WritePrefs(); | |
30 | |
31 // Getter and Setter methods for setting and getting the state of the | |
32 // |DummyPrefStore|. | |
33 virtual void set_read_only(bool read_only) { read_only_ = read_only; } | |
34 virtual void set_prefs(DictionaryValue* prefs) { prefs_.reset(prefs); } | |
35 virtual void set_prefs_written(bool status) { prefs_written_ = status; } | |
36 virtual bool get_prefs_written() { return prefs_written_; } | |
37 | |
38 // Publish these functions so tests can call them from the outside. | |
39 void NotifyPrefValueChanged(const std::string& key); | |
40 void NotifyInitializationCompleted(); | |
danno
2010/12/06 09:20:14
Doesn't the compiler complain about name hiding he
Mattias Nissler (ping if slow)
2010/12/06 10:58:12
No name hiding problems, these are just regular ov
| |
41 | |
42 // Whether the store has completed all asynchronous initialization. | |
43 virtual bool IsInitializationComplete() { return init_complete_; } | |
44 | |
45 // Mark the store as having completed initialization. | |
46 void SetInitializationCompleted(); | |
47 | |
48 private: | |
49 scoped_ptr<DictionaryValue> prefs_; | |
50 | |
51 // Flag that indicates if the PrefStore is read-only | |
52 bool read_only_; | |
53 | |
54 // Flag that indicates if the method WritePrefs was called. | |
55 bool prefs_written_; | |
56 | |
57 // Whether initialization has been completed. | |
58 bool init_complete_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); | |
61 }; | |
62 | |
63 #endif // CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | |
OLD | NEW |