Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / test_extension_environment.h
blobad026785b1989f58ba8ce881a1c77f32fb70c25d
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"
11 #if defined(OS_CHROMEOS)
12 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
13 #include "chrome/browser/chromeos/settings/cros_settings.h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
15 #endif
17 #if defined(OS_WIN)
18 #include "ui/base/win/scoped_ole_initializer.h"
19 #endif
21 class ExtensionService;
22 class TestingProfile;
24 namespace base {
25 class Value;
28 namespace content {
29 class WebContents;
30 class TestBrowserThreadBundle;
33 namespace extensions {
35 class Extension;
36 class ExtensionPrefs;
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 {
42 public:
43 // Fetches the TestExtensionSystem in |profile| and creates a default
44 // ExtensionService there,
45 static ExtensionService* CreateExtensionServiceForProfile(
46 TestingProfile* profile);
48 TestExtensionEnvironment();
50 // Allows a test harness to pass its own message loop (typically
51 // base::MessageLoopForUI::current()), rather than have
52 // TestExtensionEnvironment create and own a TestBrowserThreadBundle.
53 explicit TestExtensionEnvironment(base::MessageLoopForUI* message_loop);
55 ~TestExtensionEnvironment();
57 TestingProfile* profile() const;
59 // Returns the TestExtensionSystem created by the TestingProfile.
60 TestExtensionSystem* GetExtensionSystem();
62 // Returns an ExtensionService created (and owned) by the
63 // TestExtensionSystem created by the TestingProfile.
64 ExtensionService* GetExtensionService();
66 // Returns ExtensionPrefs created (and owned) by the
67 // TestExtensionSystem created by the TestingProfile.
68 ExtensionPrefs* GetExtensionPrefs();
70 // Creates an Extension and registers it with the ExtensionService.
71 // The Extension has a default manifest of {name: "Extension",
72 // version: "1.0", manifest_version: 2}, and values in
73 // manifest_extra override these defaults.
74 const Extension* MakeExtension(const base::Value& manifest_extra);
76 // Use a specific extension ID instead of the default generated in
77 // Extension::Create.
78 const Extension* MakeExtension(const base::Value& manifest_extra,
79 const std::string& id);
81 // Generates a valid packaged app manifest with the given ID. If |install|
82 // it gets added to the ExtensionService in |profile|.
83 scoped_refptr<Extension> MakePackagedApp(const std::string& id, bool install);
85 // Returns a test web contents that has a tab id.
86 scoped_ptr<content::WebContents> MakeTab() const;
88 // Deletes the testing profile to test profile teardown.
89 void DeleteProfile();
91 private:
92 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
94 #if defined(OS_CHROMEOS)
95 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
96 chromeos::ScopedTestCrosSettings test_cros_settings_;
97 chromeos::ScopedTestUserManager test_user_manager_;
98 #endif
100 #if defined(OS_WIN)
101 ui::ScopedOleInitializer ole_initializer_;
102 #endif
103 scoped_ptr<TestingProfile> profile_;
104 ExtensionService* extension_service_;
106 DISALLOW_COPY_AND_ASSIGN(TestExtensionEnvironment);
109 } // namespace extensions
111 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_