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_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 std::map<std::string, scoped_refptr<Extension> > extensions_; | 64 std::map<std::string, scoped_refptr<Extension> > extensions_; |
65 }; | 65 }; |
66 | 66 |
67 // A mock ExtensionSystem to serve an EventRouter. | 67 // A mock ExtensionSystem to serve an EventRouter. |
68 class MockExtensionSystem : public TestExtensionSystem { | 68 class MockExtensionSystem : public TestExtensionSystem { |
69 public: | 69 public: |
70 explicit MockExtensionSystem(Profile* profile); | 70 explicit MockExtensionSystem(Profile* profile); |
71 virtual ~MockExtensionSystem(); | 71 virtual ~MockExtensionSystem(); |
72 | 72 |
73 virtual EventRouter* event_router() OVERRIDE; | 73 virtual EventRouter* event_router() OVERRIDE; |
74 virtual ExtensionService* extension_service() OVERRIDE; | |
Yoyo Zhou
2012/11/21 00:27:13
This doesn't feel right, in the places that it's u
Miranda Callahan
2012/11/26 22:14:24
Hmm -- this would be nice, but unfortunately I don
| |
74 | 75 |
75 private: | 76 private: |
76 scoped_ptr<EventRouter> event_router_; | 77 scoped_ptr<EventRouter> event_router_; |
78 MockExtensionService extension_service_; | |
77 | 79 |
78 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem); | 80 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem); |
79 }; | 81 }; |
80 | 82 |
81 // A Profile which returns an ExtensionService with enough functionality for | 83 // A Profile which returns an ExtensionService with enough functionality for |
82 // the tests. | 84 // the tests. |
83 class MockProfile : public TestingProfile { | 85 class MockProfile : public TestingProfile { |
84 public: | 86 public: |
85 explicit MockProfile(const FilePath& file_path); | 87 explicit MockProfile(const FilePath& file_path); |
86 virtual ~MockProfile(); | 88 virtual ~MockProfile(); |
87 | 89 |
88 // Returns the same object as GetExtensionService, but not coaxed into an | 90 // Returns the same object as GetExtensionService, but not coaxed into an |
89 // ExtensionService; use this method from tests. | 91 // ExtensionService; use this method from tests. |
90 MockExtensionService* GetMockExtensionService(); | 92 MockExtensionService* GetMockExtensionService(); |
91 virtual ExtensionService* GetExtensionService() OVERRIDE; | 93 virtual ExtensionService* GetExtensionService() OVERRIDE; |
92 | 94 |
93 private: | 95 private: |
94 MockExtensionService extension_service_; | 96 MockExtensionService extension_service_; |
Yoyo Zhou
2012/11/21 00:27:13
If this isn't being used anymore, you can remove i
| |
95 }; | 97 }; |
96 | 98 |
97 // SettingsStorageFactory which acts as a wrapper for other factories. | 99 // SettingsStorageFactory which acts as a wrapper for other factories. |
98 class ScopedSettingsStorageFactory : public SettingsStorageFactory { | 100 class ScopedSettingsStorageFactory : public SettingsStorageFactory { |
99 public: | 101 public: |
100 ScopedSettingsStorageFactory(); | 102 ScopedSettingsStorageFactory(); |
101 | 103 |
102 explicit ScopedSettingsStorageFactory( | 104 explicit ScopedSettingsStorageFactory( |
103 const scoped_refptr<SettingsStorageFactory>& delegate); | 105 const scoped_refptr<SettingsStorageFactory>& delegate); |
104 | 106 |
105 // Sets the delegate factory (equivalent to scoped_ptr::reset). | 107 // Sets the delegate factory (equivalent to scoped_ptr::reset). |
106 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); | 108 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); |
107 | 109 |
108 // SettingsStorageFactory implementation. | 110 // SettingsStorageFactory implementation. |
109 virtual ValueStore* Create(const FilePath& base_path, | 111 virtual ValueStore* Create(const FilePath& base_path, |
110 const std::string& extension_id) OVERRIDE; | 112 const std::string& extension_id) OVERRIDE; |
111 | 113 |
112 private: | 114 private: |
113 // SettingsStorageFactory is refcounted. | 115 // SettingsStorageFactory is refcounted. |
114 virtual ~ScopedSettingsStorageFactory(); | 116 virtual ~ScopedSettingsStorageFactory(); |
115 | 117 |
116 scoped_refptr<SettingsStorageFactory> delegate_; | 118 scoped_refptr<SettingsStorageFactory> delegate_; |
117 }; | 119 }; |
118 | 120 |
119 } // namespace settings_test_util | 121 } // namespace settings_test_util |
120 | 122 |
121 } // namespace extensions | 123 } // namespace extensions |
122 | 124 |
123 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 125 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
OLD | NEW |