OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/ref_counted.h" |
11 #include "chrome/common/persistent_pref_store.h" | 11 #include "chrome/common/persistent_pref_store.h" |
12 #include "chrome/common/pref_store.h" | 12 #include "chrome/common/pref_store.h" |
13 | 13 |
14 class CommandLine; | 14 class CommandLine; |
15 class FilePath; | 15 class FilePath; |
16 class PrefService; | 16 class PrefService; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace policy { | 19 namespace policy { |
20 class ConfigurationPolicyProvider; | 20 class ConfigurationPolicyProvider; |
21 } | 21 } |
22 | 22 |
23 // A helper that allows convenient building of custom PrefServices in tests. | 23 // A helper that allows convenient building of custom PrefServices in tests. |
24 class PrefServiceMockBuilder { | 24 class PrefServiceMockBuilder { |
25 public: | 25 public: |
26 PrefServiceMockBuilder(); | 26 PrefServiceMockBuilder(); |
27 | 27 |
28 // Functions for setting the various parameters of the PrefService to build. | 28 // Functions for setting the various parameters of the PrefService to build. |
29 // These take ownership of the |store| parameter. | 29 // These take ownership of the |store| parameter. |
30 PrefServiceMockBuilder& WithManagedPlatformPrefs(PrefStore* store); | 30 PrefServiceMockBuilder& WithManagedPlatformPrefs( |
31 PrefServiceMockBuilder& WithDeviceManagementPrefs(PrefStore* store); | 31 scoped_refptr<PrefStore> store); |
Mattias Nissler (ping if slow)
2010/12/20 14:50:02
Plain pointer parameters here.
battre
2010/12/21 18:51:59
Done.
| |
32 PrefServiceMockBuilder& WithExtensionPrefs(PrefStore* store); | 32 PrefServiceMockBuilder& WithDeviceManagementPrefs( |
33 PrefServiceMockBuilder& WithCommandLinePrefs(PrefStore* store); | 33 scoped_refptr<PrefStore> store); |
34 PrefServiceMockBuilder& WithUserPrefs(PersistentPrefStore* store); | 34 PrefServiceMockBuilder& WithExtensionPrefs(scoped_refptr<PrefStore> store); |
35 PrefServiceMockBuilder& WithRecommendedPrefs(PrefStore* store); | 35 PrefServiceMockBuilder& WithCommandLinePrefs(scoped_refptr<PrefStore> store); |
36 PrefServiceMockBuilder& WithUserPrefs( | |
37 scoped_refptr<PersistentPrefStore> store); | |
38 PrefServiceMockBuilder& WithRecommendedPrefs(scoped_refptr<PrefStore> store); | |
36 | 39 |
37 // Set up policy pref stores using the given policy provider. | 40 // Set up policy pref stores using the given policy provider. |
38 PrefServiceMockBuilder& WithManagedPlatformProvider( | 41 PrefServiceMockBuilder& WithManagedPlatformProvider( |
39 policy::ConfigurationPolicyProvider* provider); | 42 policy::ConfigurationPolicyProvider* provider); |
40 PrefServiceMockBuilder& WithDeviceManagementProvider( | 43 PrefServiceMockBuilder& WithDeviceManagementProvider( |
41 policy::ConfigurationPolicyProvider* provider); | 44 policy::ConfigurationPolicyProvider* provider); |
42 PrefServiceMockBuilder& WithRecommendedProvider( | 45 PrefServiceMockBuilder& WithRecommendedProvider( |
43 policy::ConfigurationPolicyProvider* provider); | 46 policy::ConfigurationPolicyProvider* provider); |
44 | 47 |
45 // Specifies to use an actual command-line backed command-line pref store. | 48 // Specifies to use an actual command-line backed command-line pref store. |
46 PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); | 49 PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); |
47 | 50 |
48 // Specifies to use an actual file-backed user pref store. | 51 // Specifies to use an actual file-backed user pref store. |
49 PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file); | 52 PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file); |
50 | 53 |
51 // Sets the profile to pass to the PrefService. | 54 // Sets the profile to pass to the PrefService. |
52 PrefServiceMockBuilder& WithRecommendedPrefs(Profile* profile); | 55 PrefServiceMockBuilder& WithRecommendedPrefs(Profile* profile); |
53 | 56 |
54 // Creates the PrefService, invalidating the entire builder configuration. | 57 // Creates the PrefService, invalidating the entire builder configuration. |
55 PrefService* Create(); | 58 PrefService* Create(); |
56 | 59 |
57 private: | 60 private: |
58 scoped_ptr<PrefStore> managed_platform_prefs_; | 61 scoped_refptr<PrefStore> managed_platform_prefs_; |
59 scoped_ptr<PrefStore> device_management_prefs_; | 62 scoped_refptr<PrefStore> device_management_prefs_; |
60 scoped_ptr<PrefStore> extension_prefs_; | 63 scoped_refptr<PrefStore> extension_prefs_; |
61 scoped_ptr<PrefStore> command_line_prefs_; | 64 scoped_refptr<PrefStore> command_line_prefs_; |
62 scoped_ptr<PersistentPrefStore> user_prefs_; | 65 scoped_refptr<PersistentPrefStore> user_prefs_; |
63 scoped_ptr<PrefStore> recommended_prefs_; | 66 scoped_refptr<PrefStore> recommended_prefs_; |
64 Profile* profile_; | 67 Profile* profile_; |
65 | 68 |
66 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); | 69 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); |
67 }; | 70 }; |
68 | 71 |
69 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ | 72 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |
OLD | NEW |