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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "extensions/browser/extension_system.h"
10 #include "extensions/common/one_shot_event.h"
13 class TestingValueStore
;
24 namespace extensions
{
26 // Test ExtensionSystem, for use with TestingProfile.
27 class TestExtensionSystem
: public ExtensionSystem
{
29 explicit TestExtensionSystem(Profile
* profile
);
30 ~TestExtensionSystem() override
;
32 // KeyedService implementation.
33 void Shutdown() override
;
35 // Creates an ExtensionService initialized with the testing profile and
36 // returns it, and creates ExtensionPrefs if it hasn't been created yet.
37 ExtensionService
* CreateExtensionService(
38 const base::CommandLine
* command_line
,
39 const base::FilePath
& install_directory
,
40 bool autoupdate_enabled
);
42 void CreateSocketManager();
44 void InitForRegularProfile(bool extensions_enabled
) override
{}
45 void SetExtensionService(ExtensionService
* service
);
46 ExtensionService
* extension_service() override
;
47 RuntimeData
* runtime_data() override
;
48 ManagementPolicy
* management_policy() override
;
49 SharedUserScriptMaster
* shared_user_script_master() override
;
50 StateStore
* state_store() override
;
51 StateStore
* rules_store() override
;
52 TestingValueStore
* value_store() { return value_store_
; }
53 InfoMap
* info_map() override
;
54 QuotaService
* quota_service() override
;
55 AppSorting
* app_sorting() override
;
56 const OneShotEvent
& ready() const override
;
57 ContentVerifier
* content_verifier() override
;
58 scoped_ptr
<ExtensionSet
> GetDependentExtensions(
59 const Extension
* extension
) override
;
61 // Note that you probably want to use base::RunLoop().RunUntilIdle() right
62 // after this to run all the accumulated tasks.
63 void SetReady() { ready_
.Signal(); }
65 // Factory method for tests to use with SetTestingProfile.
66 static scoped_ptr
<KeyedService
> Build(content::BrowserContext
* profile
);
68 // Used by ExtensionPrefsTest to re-create the AppSorting after it has
69 // re-created the ExtensionPrefs instance (this can never happen in non-test
71 void RecreateAppSorting();
77 scoped_ptr
<StateStore
> state_store_
;
78 // A pointer to the TestingValueStore owned by |state_store_|.
79 TestingValueStore
* value_store_
;
80 scoped_ptr
<ManagementPolicy
> management_policy_
;
81 scoped_ptr
<RuntimeData
> runtime_data_
;
82 scoped_ptr
<ExtensionService
> extension_service_
;
83 scoped_refptr
<InfoMap
> info_map_
;
84 scoped_ptr
<QuotaService
> quota_service_
;
85 scoped_ptr
<AppSorting
> app_sorting_
;
89 } // namespace extensions
91 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_