1 // Copyright (c) 2013 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_ENVIRONMENT_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
12 #if defined(OS_CHROMEOS)
13 #include "chrome/browser/chromeos/login/users/user_manager.h"
14 #include "chrome/browser/chromeos/settings/cros_settings.h"
15 #include "chrome/browser/chromeos/settings/device_settings_service.h"
19 #include "ui/base/win/scoped_ole_initializer.h"
22 class ExtensionService
;
33 namespace extensions
{
37 class TestExtensionSystem
;
39 // This class provides a minimal environment in which to create
40 // extensions and tabs for extension-related unittests.
41 class TestExtensionEnvironment
{
43 TestExtensionEnvironment();
44 ~TestExtensionEnvironment();
46 TestingProfile
* profile() const;
48 // Returns the TestExtensionSystem created by the TestingProfile.
49 TestExtensionSystem
* GetExtensionSystem();
51 // Returns an ExtensionService created (and owned) by the
52 // TestExtensionSystem created by the TestingProfile.
53 ExtensionService
* GetExtensionService();
55 // Returns ExtensionPrefs created (and owned) by the
56 // TestExtensionSystem created by the TestingProfile.
57 ExtensionPrefs
* GetExtensionPrefs();
59 // Creates an Extension and registers it with the ExtensionService.
60 // The Extension has a default manifest of {name: "Extension",
61 // version: "1.0", manifest_version: 2}, and values in
62 // manifest_extra override these defaults.
63 const Extension
* MakeExtension(const base::Value
& manifest_extra
);
65 // Returns a test web contents that has a tab id.
66 scoped_ptr
<content::WebContents
> MakeTab() const;
69 content::TestBrowserThreadBundle thread_bundle_
;
71 #if defined(OS_CHROMEOS)
72 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_
;
73 chromeos::ScopedTestCrosSettings test_cros_settings_
;
74 chromeos::ScopedTestUserManager test_user_manager_
;
78 ui::ScopedOleInitializer ole_initializer_
;
80 scoped_ptr
<TestingProfile
> profile_
;
81 ExtensionService
* extension_service_
;
82 ExtensionPrefs
* extension_prefs_
;
85 } // namespace extensions
87 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_