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 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/event_router.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/settings/settings_namespace.h" | 17 #include "chrome/browser/extensions/settings/settings_namespace.h" |
18 #include "chrome/browser/extensions/settings/settings_storage_factory.h" | 18 #include "chrome/browser/extensions/settings/settings_storage_factory.h" |
19 #include "chrome/browser/extensions/test_extension_service.h" | 19 #include "chrome/browser/extensions/test_extension_service.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
22 | 22 |
23 class ValueStore; | 23 class ValueStore; |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
(...skipping 30 matching lines...) Expand all Loading... |
56 Extension::Type type, | 56 Extension::Type type, |
57 const std::set<std::string>& permissions); | 57 const std::set<std::string>& permissions); |
58 | 58 |
59 virtual const Extension* GetExtensionById( | 59 virtual const Extension* GetExtensionById( |
60 const std::string& id, bool include_disabled) const OVERRIDE; | 60 const std::string& id, bool include_disabled) const OVERRIDE; |
61 | 61 |
62 private: | 62 private: |
63 std::map<std::string, scoped_refptr<Extension> > extensions_; | 63 std::map<std::string, scoped_refptr<Extension> > extensions_; |
64 }; | 64 }; |
65 | 65 |
66 // A Profile which returns ExtensionService and ExtensionEventRouters with | 66 // A Profile which returns ExtensionService and EventRouters with |
67 // enough functionality for the tests. | 67 // enough functionality for the tests. |
68 class MockProfile : public TestingProfile { | 68 class MockProfile : public TestingProfile { |
69 public: | 69 public: |
70 explicit MockProfile(const FilePath& file_path); | 70 explicit MockProfile(const FilePath& file_path); |
71 virtual ~MockProfile(); | 71 virtual ~MockProfile(); |
72 | 72 |
73 // Returns the same object as GetExtensionService, but not coaxed into an | 73 // Returns the same object as GetExtensionService, but not coaxed into an |
74 // ExtensionService; use this method from tests. | 74 // ExtensionService; use this method from tests. |
75 MockExtensionService* GetMockExtensionService(); | 75 MockExtensionService* GetMockExtensionService(); |
76 | 76 |
77 virtual ExtensionService* GetExtensionService() OVERRIDE; | 77 virtual ExtensionService* GetExtensionService() OVERRIDE; |
78 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; | 78 virtual EventRouter* GetExtensionEventRouter() OVERRIDE; |
79 | 79 |
80 private: | 80 private: |
81 MockExtensionService extension_service_; | 81 MockExtensionService extension_service_; |
82 scoped_ptr<ExtensionEventRouter> event_router_; | 82 scoped_ptr<EventRouter> event_router_; |
83 }; | 83 }; |
84 | 84 |
85 // SettingsStorageFactory which acts as a wrapper for other factories. | 85 // SettingsStorageFactory which acts as a wrapper for other factories. |
86 class ScopedSettingsStorageFactory : public SettingsStorageFactory { | 86 class ScopedSettingsStorageFactory : public SettingsStorageFactory { |
87 public: | 87 public: |
88 ScopedSettingsStorageFactory(); | 88 ScopedSettingsStorageFactory(); |
89 | 89 |
90 explicit ScopedSettingsStorageFactory( | 90 explicit ScopedSettingsStorageFactory( |
91 const scoped_refptr<SettingsStorageFactory>& delegate); | 91 const scoped_refptr<SettingsStorageFactory>& delegate); |
92 | 92 |
93 // Sets the delegate factory (equivalent to scoped_ptr::reset). | 93 // Sets the delegate factory (equivalent to scoped_ptr::reset). |
94 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); | 94 void Reset(const scoped_refptr<SettingsStorageFactory>& delegate); |
95 | 95 |
96 // SettingsStorageFactory implementation. | 96 // SettingsStorageFactory implementation. |
97 virtual ValueStore* Create( | 97 virtual ValueStore* Create( |
98 const FilePath& base_path, const std::string& extension_id) OVERRIDE; | 98 const FilePath& base_path, const std::string& extension_id) OVERRIDE; |
99 | 99 |
100 private: | 100 private: |
101 // SettingsStorageFactory is refcounted. | 101 // SettingsStorageFactory is refcounted. |
102 virtual ~ScopedSettingsStorageFactory(); | 102 virtual ~ScopedSettingsStorageFactory(); |
103 | 103 |
104 scoped_refptr<SettingsStorageFactory> delegate_; | 104 scoped_refptr<SettingsStorageFactory> delegate_; |
105 }; | 105 }; |
106 | 106 |
107 } // namespace settings_test_util | 107 } // namespace settings_test_util |
108 | 108 |
109 } // namespace extensions | 109 } // namespace extensions |
110 | 110 |
111 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
OLD | NEW |