OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 11 matching lines...) Expand all Loading... |
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 ~PrefServiceMockBuilder(); | 27 ~PrefServiceMockBuilder(); |
28 | 28 |
29 // Functions for setting the various parameters of the PrefService to build. | 29 // Functions for setting the various parameters of the PrefService to build. |
30 // These take ownership of the |store| parameter. | 30 // These take ownership of the |store| parameter. |
31 PrefServiceMockBuilder& WithManagedPlatformPrefs(PrefStore* store); | 31 PrefServiceMockBuilder& WithManagedPlatformPrefs(PrefStore* store); |
32 PrefServiceMockBuilder& WithDeviceManagementPrefs(PrefStore* store); | 32 PrefServiceMockBuilder& WithManagedCloudPrefs(PrefStore* store); |
33 PrefServiceMockBuilder& WithExtensionPrefs(PrefStore* store); | 33 PrefServiceMockBuilder& WithExtensionPrefs(PrefStore* store); |
34 PrefServiceMockBuilder& WithCommandLinePrefs(PrefStore* store); | 34 PrefServiceMockBuilder& WithCommandLinePrefs(PrefStore* store); |
35 PrefServiceMockBuilder& WithUserPrefs(PersistentPrefStore* store); | 35 PrefServiceMockBuilder& WithUserPrefs(PersistentPrefStore* store); |
36 PrefServiceMockBuilder& WithRecommendedPrefs(PrefStore* store); | 36 PrefServiceMockBuilder& WithRecommendedPlatformPrefs(PrefStore* store); |
| 37 PrefServiceMockBuilder& WithRecommendedCloudPrefs(PrefStore* store); |
37 | 38 |
38 // Set up policy pref stores using the given policy provider. | 39 // Set up policy pref stores using the given policy provider. |
39 PrefServiceMockBuilder& WithManagedPlatformProvider( | 40 PrefServiceMockBuilder& WithManagedPlatformProvider( |
40 policy::ConfigurationPolicyProvider* provider); | 41 policy::ConfigurationPolicyProvider* provider); |
41 PrefServiceMockBuilder& WithDeviceManagementProvider( | 42 PrefServiceMockBuilder& WithManagedCloudProvider( |
42 policy::ConfigurationPolicyProvider* provider); | 43 policy::ConfigurationPolicyProvider* provider); |
43 PrefServiceMockBuilder& WithRecommendedProvider( | 44 PrefServiceMockBuilder& WithRecommendedPlatformProvider( |
| 45 policy::ConfigurationPolicyProvider* provider); |
| 46 PrefServiceMockBuilder& WithRecommendedCloudProvider( |
44 policy::ConfigurationPolicyProvider* provider); | 47 policy::ConfigurationPolicyProvider* provider); |
45 | 48 |
46 // Specifies to use an actual command-line backed command-line pref store. | 49 // Specifies to use an actual command-line backed command-line pref store. |
47 PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); | 50 PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); |
48 | 51 |
49 // Specifies to use an actual file-backed user pref store. | 52 // Specifies to use an actual file-backed user pref store. |
50 PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file); | 53 PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file); |
51 | 54 |
52 // Sets the profile to pass to the PrefService. | |
53 PrefServiceMockBuilder& WithRecommendedPrefs(Profile* profile); | |
54 | |
55 // Creates the PrefService, invalidating the entire builder configuration. | 55 // Creates the PrefService, invalidating the entire builder configuration. |
56 PrefService* Create(); | 56 PrefService* Create(); |
57 | 57 |
58 private: | 58 private: |
59 scoped_refptr<PrefStore> managed_platform_prefs_; | 59 scoped_refptr<PrefStore> managed_platform_prefs_; |
60 scoped_refptr<PrefStore> device_management_prefs_; | 60 scoped_refptr<PrefStore> managed_cloud_prefs_; |
61 scoped_refptr<PrefStore> extension_prefs_; | 61 scoped_refptr<PrefStore> extension_prefs_; |
62 scoped_refptr<PrefStore> command_line_prefs_; | 62 scoped_refptr<PrefStore> command_line_prefs_; |
63 scoped_refptr<PersistentPrefStore> user_prefs_; | 63 scoped_refptr<PersistentPrefStore> user_prefs_; |
64 scoped_refptr<PrefStore> recommended_prefs_; | 64 scoped_refptr<PrefStore> recommended_platform_prefs_; |
| 65 scoped_refptr<PrefStore> recommended_cloud_prefs_; |
65 | 66 |
66 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); | 67 DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); |
67 }; | 68 }; |
68 | 69 |
69 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ | 70 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |
OLD | NEW |