| Index: chrome/test/base/testing_pref_service.h
|
| diff --git a/chrome/test/base/testing_pref_service.h b/chrome/test/base/testing_pref_service.h
|
| index 478a4a9536e4588b3b5ef2d2bc60a28bcf35000d..5c921bfd4319e5a8a840569fb78b708486ecd62f 100644
|
| --- a/chrome/test/base/testing_pref_service.h
|
| +++ b/chrome/test/base/testing_pref_service.h
|
| @@ -6,6 +6,7 @@
|
| #define CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
|
|
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/prefs/testing_pref_store.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
|
|
| class DefaultPrefStore;
|
| @@ -17,7 +18,11 @@ class TestingPrefStore;
|
| // A PrefService subclass for testing. It operates totally in memory and
|
| // provides additional API for manipulating preferences at the different levels
|
| // (managed, extension, user) conveniently.
|
| -class TestingPrefServiceBase : public PrefService {
|
| +//
|
| +// Use this via its specializations, TestingPrefServiceSimple and
|
| +// TestingPrefServiceSyncable.
|
| +template <class SuperPrefService>
|
| +class TestingPrefServiceBase : public SuperPrefService {
|
| public:
|
| virtual ~TestingPrefServiceBase();
|
|
|
| @@ -49,7 +54,6 @@ class TestingPrefServiceBase : public PrefService {
|
| TestingPrefStore* user_prefs,
|
| TestingPrefStore* recommended_prefs,
|
| DefaultPrefStore* default_store,
|
| - PrefModelAssociator* pref_sync_associator,
|
| PrefNotifierImpl* pref_notifier);
|
|
|
| private:
|
| @@ -71,14 +75,26 @@ class TestingPrefServiceBase : public PrefService {
|
| DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase);
|
| };
|
|
|
| -// Class for simplified construction of TestPrefServiceBase objects.
|
| -class TestingPrefService : public TestingPrefServiceBase {
|
| +// Test version of PrefServiceSimple.
|
| +class TestingPrefServiceSimple
|
| + : public TestingPrefServiceBase<PrefServiceSimple> {
|
| public:
|
| - TestingPrefService();
|
| - virtual ~TestingPrefService();
|
| + TestingPrefServiceSimple();
|
| + virtual ~TestingPrefServiceSimple();
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(TestingPrefService);
|
| + DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple);
|
| +};
|
| +
|
| +// Test version of PrefServiceSyncable.
|
| +class TestingPrefServiceSyncable
|
| + : public TestingPrefServiceBase<PrefServiceSyncable> {
|
| + public:
|
| + TestingPrefServiceSyncable();
|
| + virtual ~TestingPrefServiceSyncable();
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable);
|
| };
|
|
|
| // Helper class to temporarily set up a |local_state| in the global
|
| @@ -88,15 +104,108 @@ class ScopedTestingLocalState {
|
| explicit ScopedTestingLocalState(TestingBrowserProcess* browser_process);
|
| ~ScopedTestingLocalState();
|
|
|
| - TestingPrefService* Get() {
|
| + TestingPrefServiceSimple* Get() {
|
| return &local_state_;
|
| }
|
|
|
| private:
|
| TestingBrowserProcess* browser_process_;
|
| - TestingPrefService local_state_;
|
| + TestingPrefServiceSimple local_state_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState);
|
| };
|
|
|
| +template<>
|
| +TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase(
|
| + TestingPrefStore* managed_prefs,
|
| + TestingPrefStore* user_prefs,
|
| + TestingPrefStore* recommended_prefs,
|
| + DefaultPrefStore* default_store,
|
| + PrefNotifierImpl* pref_notifier);
|
| +
|
| +template<>
|
| +TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
|
| + TestingPrefStore* managed_prefs,
|
| + TestingPrefStore* user_prefs,
|
| + TestingPrefStore* recommended_prefs,
|
| + DefaultPrefStore* default_store,
|
| + PrefNotifierImpl* pref_notifier);
|
| +
|
| +template<class SuperPrefService>
|
| +TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() {
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref(
|
| + const char* path) const {
|
| + return GetPref(managed_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::SetManagedPref(
|
| + const char* path, Value* value) {
|
| + SetPref(managed_prefs_, path, value);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::RemoveManagedPref(
|
| + const char* path) {
|
| + RemovePref(managed_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +const Value* TestingPrefServiceBase<SuperPrefService>::GetUserPref(
|
| + const char* path) const {
|
| + return GetPref(user_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::SetUserPref(
|
| + const char* path, Value* value) {
|
| + SetPref(user_prefs_, path, value);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::RemoveUserPref(
|
| + const char* path) {
|
| + RemovePref(user_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +const Value* TestingPrefServiceBase<SuperPrefService>::GetRecommendedPref(
|
| + const char* path) const {
|
| + return GetPref(recommended_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::SetRecommendedPref(
|
| + const char* path, Value* value) {
|
| + SetPref(recommended_prefs_, path, value);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::RemoveRecommendedPref(
|
| + const char* path) {
|
| + RemovePref(recommended_prefs_, path);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +const Value* TestingPrefServiceBase<SuperPrefService>::GetPref(
|
| + TestingPrefStore* pref_store, const char* path) const {
|
| + const Value* res;
|
| + return pref_store->GetValue(path, &res) ? res : NULL;
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::SetPref(
|
| + TestingPrefStore* pref_store, const char* path, Value* value) {
|
| + pref_store->SetValue(path, value);
|
| +}
|
| +
|
| +template<class SuperPrefService>
|
| +void TestingPrefServiceBase<SuperPrefService>::RemovePref(
|
| + TestingPrefStore* pref_store, const char* path) {
|
| + pref_store->RemoveValue(path);
|
| +}
|
| +
|
| #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
|
|
|