OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/extensions/extension_event_router.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/test_extension_service.h" |
| 16 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/test/base/testing_profile.h" |
| 18 |
| 19 class ExtensionSettingsFrontend; |
| 20 |
| 21 // Utilities for extension settings API tests. |
| 22 namespace extension_settings_test_util { |
| 23 |
| 24 // Synchronously gets the storage area for an extension from |frontend|. |
| 25 ExtensionSettingsStorage* GetStorage( |
| 26 const std::string& extension_id, ExtensionSettingsFrontend* frontend); |
| 27 |
| 28 // An ExtensionService which allows extensions to be hand-added to be returned |
| 29 // by GetExtensionById. |
| 30 class MockExtensionService : public TestExtensionService { |
| 31 public: |
| 32 MockExtensionService(); |
| 33 virtual ~MockExtensionService(); |
| 34 |
| 35 // Adds an extension with id |id| to be returned by GetExtensionById. |
| 36 void AddExtension(const std::string& id, Extension::Type type); |
| 37 |
| 38 virtual const Extension* GetExtensionById( |
| 39 const std::string& id, bool include_disabled) const OVERRIDE; |
| 40 |
| 41 private: |
| 42 std::map<std::string, scoped_refptr<Extension> > extensions_; |
| 43 }; |
| 44 |
| 45 // A Profile which returns ExtensionService and ExtensionEventRouters with |
| 46 // enough functionality for the tests. |
| 47 class MockProfile : public TestingProfile { |
| 48 public: |
| 49 explicit MockProfile(const FilePath& file_path); |
| 50 virtual ~MockProfile(); |
| 51 |
| 52 // Returns the same object as GetExtensionService, but not coaxed into an |
| 53 // ExtensionService; use this method from tests. |
| 54 MockExtensionService* GetMockExtensionService(); |
| 55 |
| 56 virtual ExtensionService* GetExtensionService() OVERRIDE; |
| 57 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; |
| 58 |
| 59 private: |
| 60 MockExtensionService extension_service_; |
| 61 scoped_ptr<ExtensionEventRouter> event_router_; |
| 62 }; |
| 63 |
| 64 } // namespace extension_settings_test_util |
| 65 |
| 66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_ |
OLD | NEW |