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

Side by Side Diff: chrome/test/base/chrome_test_suite.cc

Issue 56253002: Move ExtensionsProcessManager to src/extensions, part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/test/base/chrome_test_suite.h" 5 #include "chrome/test/base/chrome_test_suite.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #endif 10 #endif
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener { 87 class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener {
88 public: 88 public:
89 ChromeTestSuiteInitializer() { 89 ChromeTestSuiteInitializer() {
90 } 90 }
91 91
92 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { 92 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
93 DCHECK(!g_browser_process); 93 DCHECK(!g_browser_process);
94 g_browser_process = new TestingBrowserProcess; 94 g_browser_process = new TestingBrowserProcess;
95 95
96 SetUpContentClients();
97 SetUpExtensionsClients();
98 }
99
100 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
101 TearDownExtensionsClients();
102 TearDownContentClients();
James Cook 2013/11/01 20:53:12 This teardown has no significant side effects, so
103
104 if (g_browser_process) {
105 BrowserProcess* browser_process = g_browser_process;
106 // g_browser_process must be NULL during its own destruction.
107 g_browser_process = NULL;
108 delete browser_process;
109 }
110 }
111
112 private:
113 void SetUpContentClients() {
96 content_client_.reset(new chrome::ChromeContentClient); 114 content_client_.reset(new chrome::ChromeContentClient);
97 content::SetContentClient(content_client_.get()); 115 content::SetContentClient(content_client_.get());
98 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. 116 // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
99 #if !defined(OS_IOS) 117 #if !defined(OS_IOS)
100 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); 118 browser_content_client_.reset(new chrome::ChromeContentBrowserClient());
101 content::SetBrowserClientForTesting(browser_content_client_.get()); 119 content::SetBrowserClientForTesting(browser_content_client_.get());
102 utility_content_client_.reset(new chrome::ChromeContentUtilityClient()); 120 utility_content_client_.reset(new chrome::ChromeContentUtilityClient());
103 content::SetUtilityClientForTesting(utility_content_client_.get()); 121 content::SetUtilityClientForTesting(utility_content_client_.get());
104 #endif 122 #endif
105 } 123 }
106 124
107 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { 125 void TearDownContentClients() {
108 if (g_browser_process) {
109 BrowserProcess* browser_process = g_browser_process;
110 // g_browser_process must be NULL during its own destruction.
111 g_browser_process = NULL;
112 delete browser_process;
113 }
114
115 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. 126 // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
116 #if !defined(OS_IOS) 127 #if !defined(OS_IOS)
117 browser_content_client_.reset(); 128 browser_content_client_.reset();
118 utility_content_client_.reset(); 129 utility_content_client_.reset();
119 #endif 130 #endif
120 content_client_.reset(); 131 content_client_.reset();
121 content::SetContentClient(NULL); 132 content::SetContentClient(NULL);
122 } 133 }
123 134
124 private: 135 void SetUpExtensionsClients() {
136 #if defined(ENABLE_EXTENSIONS)
137 extensions_browser_client_.reset(
138 new extensions::ChromeExtensionsBrowserClient);
139 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
James Cook 2013/11/01 20:53:12 This must be done after content is initialized bec
140 #endif
141 }
142
143 void TearDownExtensionsClients() {
144 #if defined(ENABLE_EXTENSIONS)
145 extensions_browser_client_.reset();
146 extensions::ExtensionsBrowserClient::Set(NULL);
147 #endif
148 }
149
150 // Client implementations for the content module.
125 scoped_ptr<chrome::ChromeContentClient> content_client_; 151 scoped_ptr<chrome::ChromeContentClient> content_client_;
126 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. 152 // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
127 #if !defined(OS_IOS) 153 #if !defined(OS_IOS)
128 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; 154 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_;
129 scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_; 155 scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_;
130 #endif 156 #endif
131 157
158 // Client implementations for the extensions module.
159 scoped_ptr<extensions::ChromeExtensionsBrowserClient>
160 extensions_browser_client_;
161
132 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); 162 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer);
133 }; 163 };
134 164
135 } // namespace 165 } // namespace
136 166
137 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) 167 ChromeTestSuite::ChromeTestSuite(int argc, char** argv)
138 : content::ContentTestSuiteBase(argc, argv) { 168 : content::ContentTestSuiteBase(argc, argv) {
139 } 169 }
140 170
141 ChromeTestSuite::~ChromeTestSuite() { 171 ChromeTestSuite::~ChromeTestSuite() {
(...skipping 23 matching lines...) Expand all
165 if (!browser_dir_.empty()) { 195 if (!browser_dir_.empty()) {
166 PathService::Override(base::DIR_EXE, browser_dir_); 196 PathService::Override(base::DIR_EXE, browser_dir_);
167 PathService::Override(base::DIR_MODULE, browser_dir_); 197 PathService::Override(base::DIR_MODULE, browser_dir_);
168 } 198 }
169 199
170 #if !defined(OS_IOS) 200 #if !defined(OS_IOS)
171 extensions::RegisterPathProvider(); 201 extensions::RegisterPathProvider();
172 202
173 extensions::ExtensionsClient::Set( 203 extensions::ExtensionsClient::Set(
174 extensions::ChromeExtensionsClient::GetInstance()); 204 extensions::ChromeExtensionsClient::GetInstance());
175 extensions::ExtensionsBrowserClient::Set(
176 extensions::ChromeExtensionsBrowserClient::GetInstance());
177 205
178 // Only want to do this for unit tests. 206 // Only want to do this for unit tests.
179 if (!content::GetCurrentTestLauncherDelegate()) { 207 if (!content::GetCurrentTestLauncherDelegate()) {
180 // For browser tests, this won't create the right object since 208 // For browser tests, this won't create the right object since
181 // TestChromeWebUIControllerFactory is used. That's created and 209 // TestChromeWebUIControllerFactory is used. That's created and
182 // registered in ChromeBrowserMainParts as in normal startup. 210 // registered in ChromeBrowserMainParts as in normal startup.
183 content::WebUIControllerFactory::RegisterFactory( 211 content::WebUIControllerFactory::RegisterFactory(
184 ChromeWebUIControllerFactory::GetInstance()); 212 ChromeWebUIControllerFactory::GetInstance());
185 } 213 }
186 #endif 214 #endif
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 #if defined(OS_MACOSX) && !defined(OS_IOS) 266 #if defined(OS_MACOSX) && !defined(OS_IOS)
239 base::mac::SetOverrideFrameworkBundle(NULL); 267 base::mac::SetOverrideFrameworkBundle(NULL);
240 #endif 268 #endif
241 269
242 base::StatsTable::set_current(NULL); 270 base::StatsTable::set_current(NULL);
243 stats_table_.reset(); 271 stats_table_.reset();
244 RemoveSharedMemoryFile(stats_filename_); 272 RemoveSharedMemoryFile(stats_filename_);
245 273
246 base::TestSuite::Shutdown(); 274 base::TestSuite::Shutdown();
247 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698