Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/extensions/test_extension_environment.h

Issue 1175783003: Split out Ash dependency in app info dialog unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split out ScopedViewsTestHelper Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/test_extension_environment.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
11 10
12 #if defined(OS_CHROMEOS) 11 #if defined(OS_CHROMEOS)
13 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 12 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
14 #include "chrome/browser/chromeos/settings/cros_settings.h" 13 #include "chrome/browser/chromeos/settings/cros_settings.h"
15 #include "chrome/browser/chromeos/settings/device_settings_service.h" 14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
16 #endif 15 #endif
17 16
18 #if defined(OS_WIN) 17 #if defined(OS_WIN)
19 #include "ui/base/win/scoped_ole_initializer.h" 18 #include "ui/base/win/scoped_ole_initializer.h"
20 #endif 19 #endif
21 20
22 class ExtensionService; 21 class ExtensionService;
23 class TestingProfile; 22 class TestingProfile;
24 23
25 namespace base { 24 namespace base {
26 class Value; 25 class Value;
27 } 26 }
28 27
29 namespace content { 28 namespace content {
30 class WebContents; 29 class WebContents;
30 class TestBrowserThreadBundle;
31 } 31 }
32 32
33 namespace extensions { 33 namespace extensions {
34 34
35 class Extension; 35 class Extension;
36 class ExtensionPrefs; 36 class ExtensionPrefs;
37 class TestExtensionSystem; 37 class TestExtensionSystem;
38 38
39 // This class provides a minimal environment in which to create 39 // This class provides a minimal environment in which to create
40 // extensions and tabs for extension-related unittests. 40 // extensions and tabs for extension-related unittests.
41 class TestExtensionEnvironment { 41 class TestExtensionEnvironment {
42 public: 42 public:
43 // Fetches the TestExtensionSystem in |profile| and creates a default
44 // ExtensionService there,
45 static ExtensionService* CreateExtensionServiceForProfile(
46 TestingProfile* profile);
47
43 TestExtensionEnvironment(); 48 TestExtensionEnvironment();
49
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);
54
44 ~TestExtensionEnvironment(); 55 ~TestExtensionEnvironment();
45 56
46 TestingProfile* profile() const; 57 TestingProfile* profile() const;
47 58
48 // Returns the TestExtensionSystem created by the TestingProfile. 59 // Returns the TestExtensionSystem created by the TestingProfile.
49 TestExtensionSystem* GetExtensionSystem(); 60 TestExtensionSystem* GetExtensionSystem();
50 61
51 // Returns an ExtensionService created (and owned) by the 62 // Returns an ExtensionService created (and owned) by the
52 // TestExtensionSystem created by the TestingProfile. 63 // TestExtensionSystem created by the TestingProfile.
53 ExtensionService* GetExtensionService(); 64 ExtensionService* GetExtensionService();
54 65
55 // Returns ExtensionPrefs created (and owned) by the 66 // Returns ExtensionPrefs created (and owned) by the
56 // TestExtensionSystem created by the TestingProfile. 67 // TestExtensionSystem created by the TestingProfile.
57 ExtensionPrefs* GetExtensionPrefs(); 68 ExtensionPrefs* GetExtensionPrefs();
58 69
59 // Creates an Extension and registers it with the ExtensionService. 70 // Creates an Extension and registers it with the ExtensionService.
60 // The Extension has a default manifest of {name: "Extension", 71 // The Extension has a default manifest of {name: "Extension",
61 // version: "1.0", manifest_version: 2}, and values in 72 // version: "1.0", manifest_version: 2}, and values in
62 // manifest_extra override these defaults. 73 // manifest_extra override these defaults.
63 const Extension* MakeExtension(const base::Value& manifest_extra); 74 const Extension* MakeExtension(const base::Value& manifest_extra);
64 75
65 // Use a specific extension ID instead of the default generated in 76 // Use a specific extension ID instead of the default generated in
66 // Extension::Create. 77 // Extension::Create.
67 const Extension* MakeExtension(const base::Value& manifest_extra, 78 const Extension* MakeExtension(const base::Value& manifest_extra,
68 const std::string& id); 79 const std::string& id);
69 80
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);
84
70 // Returns a test web contents that has a tab id. 85 // Returns a test web contents that has a tab id.
71 scoped_ptr<content::WebContents> MakeTab() const; 86 scoped_ptr<content::WebContents> MakeTab() const;
72 87
88 // Deletes the testing profile to test profile teardown.
89 void DeleteProfile();
90
73 private: 91 private:
74 content::TestBrowserThreadBundle thread_bundle_; 92 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
75 93
76 #if defined(OS_CHROMEOS) 94 #if defined(OS_CHROMEOS)
77 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 95 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
78 chromeos::ScopedTestCrosSettings test_cros_settings_; 96 chromeos::ScopedTestCrosSettings test_cros_settings_;
79 chromeos::ScopedTestUserManager test_user_manager_; 97 chromeos::ScopedTestUserManager test_user_manager_;
80 #endif 98 #endif
81 99
82 #if defined(OS_WIN) 100 #if defined(OS_WIN)
83 ui::ScopedOleInitializer ole_initializer_; 101 ui::ScopedOleInitializer ole_initializer_;
84 #endif 102 #endif
85 scoped_ptr<TestingProfile> profile_; 103 scoped_ptr<TestingProfile> profile_;
86 ExtensionService* extension_service_; 104 ExtensionService* extension_service_;
87 ExtensionPrefs* extension_prefs_; 105
106 DISALLOW_COPY_AND_ASSIGN(TestExtensionEnvironment);
88 }; 107 };
89 108
90 } // namespace extensions 109 } // namespace extensions
91 110
92 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_ 111 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_ENVIRONMENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/test_extension_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698