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; |
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 | |
88 // Returns the same object as GetExtensionService, but not coaxed into an | |
89 // ExtensionService; use this method from tests. | |
90 MockExtensionService* GetMockExtensionService(); | |
91 virtual ExtensionService* GetExtensionService() OVERRIDE; | |
92 | |
93 private: | |
94 MockExtensionService extension_service_; | |
95 }; | 89 }; |
96 | 90 |
97 // SettingsStorageFactory which acts as a wrapper for other factories. | 91 // SettingsStorageFactory which acts as a wrapper for other factories. |
98 class ScopedSettingsStorageFactory : public SettingsStorageFactory { | 92 class ScopedSettingsStorageFactory : public SettingsStorageFactory { |
99 public: | 93 public: |
100 ScopedSettingsStorageFactory(); | 94 ScopedSettingsStorageFactory(); |
101 | 95 |
102 explicit ScopedSettingsStorageFactory( | 96 explicit ScopedSettingsStorageFactory( |
103 const scoped_refptr<SettingsStorageFactory>& delegate); | 97 const scoped_refptr<SettingsStorageFactory>& delegate); |
104 | 98 |
105 // Sets the delegate factory (equivalent to scoped_ptr::reset). | 99 // Sets the delegate factory (equivalent to scoped_ptr::reset). |
106 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); | 100 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); |
107 | 101 |
108 // SettingsStorageFactory implementation. | 102 // SettingsStorageFactory implementation. |
109 virtual ValueStore* Create(const FilePath& base_path, | 103 virtual ValueStore* Create(const FilePath& base_path, |
110 const std::string& extension_id) OVERRIDE; | 104 const std::string& extension_id) OVERRIDE; |
111 | 105 |
112 private: | 106 private: |
113 // SettingsStorageFactory is refcounted. | 107 // SettingsStorageFactory is refcounted. |
114 virtual ~ScopedSettingsStorageFactory(); | 108 virtual ~ScopedSettingsStorageFactory(); |
115 | 109 |
116 scoped_refptr<SettingsStorageFactory> delegate_; | 110 scoped_refptr<SettingsStorageFactory> delegate_; |
117 }; | 111 }; |
118 | 112 |
119 } // namespace settings_test_util | 113 } // namespace settings_test_util |
120 | 114 |
121 } // namespace extensions | 115 } // namespace extensions |
122 | 116 |
123 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 117 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
OLD | NEW |