| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |
| 6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "chrome/browser/prefs/pref_service_syncable_builder.h" |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/prefs/persistent_pref_store.h" | |
| 11 #include "base/prefs/pref_store.h" | |
| 12 #include "chrome/browser/prefs/pref_service_builder.h" | |
| 13 | 9 |
| 14 class CommandLine; | 10 class PrefServiceSimple; |
| 15 class FilePath; | 11 class PrefServiceSyncable; |
| 16 class PrefService; | |
| 17 | |
| 18 namespace base { | |
| 19 class SequencedTaskRunner; | |
| 20 } | |
| 21 | |
| 22 namespace policy { | |
| 23 class PolicyService; | |
| 24 } | |
| 25 | 12 |
| 26 // A helper that allows convenient building of custom PrefServices in tests. | 13 // A helper that allows convenient building of custom PrefServices in tests. |
| 27 class PrefServiceMockBuilder : public PrefServiceBuilder { | 14 class PrefServiceMockBuilder : public PrefServiceSyncableBuilder { |
| 28 public: | 15 public: |
| 29 PrefServiceMockBuilder(); | 16 PrefServiceMockBuilder(); |
| 30 virtual ~PrefServiceMockBuilder(); | 17 virtual ~PrefServiceMockBuilder(); |
| 31 | 18 |
| 32 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 33 // Set up policy pref stores using the given policy service. | |
| 34 PrefServiceMockBuilder& WithManagedPolicies( | |
| 35 policy::PolicyService* service); | |
| 36 PrefServiceMockBuilder& WithRecommendedPolicies( | |
| 37 policy::PolicyService* service); | |
| 38 #endif | |
| 39 | |
| 40 // Specifies to use an actual command-line backed command-line pref store. | |
| 41 PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); | |
| 42 | |
| 43 // Creates a PrefService for testing, invalidating the entire | 19 // Creates a PrefService for testing, invalidating the entire |
| 44 // builder configuration. | 20 // builder configuration. |
| 45 virtual PrefService* Create() OVERRIDE; | 21 virtual PrefServiceSimple* CreateSimple() OVERRIDE; |
| 22 virtual PrefServiceSyncable* CreateSyncable() OVERRIDE; |
| 46 | 23 |
| 47 private: | 24 private: |
| 48 void ResetTestingState(); | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); | 25 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); |
| 51 }; | 26 }; |
| 52 | 27 |
| 53 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ | 28 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |
| OLD | NEW |