| OLD | NEW |
| 1 // |
| 2 // |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 // 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 | 4 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 5 // found in the LICENSE file. |
| 4 | 6 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 7 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 8 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
| 7 #pragma once | 9 #pragma once |
| 8 | 10 |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/settings/settings_storage_factory.h" |
| 15 #include "chrome/browser/extensions/test_extension_service.h" | 18 #include "chrome/browser/extensions/test_extension_service.h" |
| 16 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 18 | 21 |
| 22 namespace extensions { |
| 23 |
| 19 class SettingsFrontend; | 24 class SettingsFrontend; |
| 20 | 25 class SettingsStorage; |
| 21 namespace extensions { | |
| 22 | 26 |
| 23 // Utilities for extension settings API tests. | 27 // Utilities for extension settings API tests. |
| 24 namespace settings_test_util { | 28 namespace settings_test_util { |
| 25 | 29 |
| 26 // Synchronously gets the storage area for an extension from |frontend|. | 30 // Synchronously gets the storage area for an extension from |frontend|. |
| 27 SettingsStorage* GetStorage( | 31 SettingsStorage* GetStorage( |
| 28 const std::string& extension_id, SettingsFrontend* frontend); | 32 const std::string& extension_id, SettingsFrontend* frontend); |
| 29 | 33 |
| 30 // An ExtensionService which allows extensions to be hand-added to be returned | 34 // An ExtensionService which allows extensions to be hand-added to be returned |
| 31 // by GetExtensionById. | 35 // by GetExtensionById. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 56 MockExtensionService* GetMockExtensionService(); | 60 MockExtensionService* GetMockExtensionService(); |
| 57 | 61 |
| 58 virtual ExtensionService* GetExtensionService() OVERRIDE; | 62 virtual ExtensionService* GetExtensionService() OVERRIDE; |
| 59 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; | 63 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 MockExtensionService extension_service_; | 66 MockExtensionService extension_service_; |
| 63 scoped_ptr<ExtensionEventRouter> event_router_; | 67 scoped_ptr<ExtensionEventRouter> event_router_; |
| 64 }; | 68 }; |
| 65 | 69 |
| 70 // A SettingsStorageFactory which delegates to other factories. |
| 71 class DelegatingSettingsStorageFactory : public SettingsStorageFactory { |
| 72 public: |
| 73 // Creates with an initial delegate. |
| 74 DelegatingSettingsStorageFactory( |
| 75 // Ownership taken. |
| 76 SettingsStorageFactory* delegate); |
| 77 |
| 78 virtual ~DelegatingSettingsStorageFactory(); |
| 79 |
| 80 // Sets the delegate for Create calls. The existing delegate is deleted. |
| 81 void Reset( |
| 82 // Ownership taken. |
| 83 SettingsStorageFactory* delegate); |
| 84 |
| 85 // SettingsStorageFactory implementation. |
| 86 virtual SettingsStorage* Create( |
| 87 const FilePath& base_path, const std::string& extension_id) OVERRIDE; |
| 88 |
| 89 private: |
| 90 scoped_ptr<SettingsStorageFactory> delegate_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(DelegatingSettingsStorageFactory); |
| 93 }; |
| 94 |
| 95 // A SettingsStorageFactory which always returns NULL. |
| 96 class NullSettingsStorageFactory : public SettingsStorageFactory { |
| 97 public: |
| 98 NullSettingsStorageFactory() {} |
| 99 virtual ~NullSettingsStorageFactory() {} |
| 100 |
| 101 // SettingsStorageFactory implementation. |
| 102 virtual SettingsStorage* Create( |
| 103 const FilePath& base_path, const std::string& extension_id) OVERRIDE; |
| 104 |
| 105 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(NullSettingsStorageFactory); |
| 107 }; |
| 108 |
| 66 } // namespace settings_test_util | 109 } // namespace settings_test_util |
| 67 | 110 |
| 68 } // namespace extensions | 111 } // namespace extensions |
| 69 | 112 |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ | 113 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ |
| OLD | NEW |