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

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

Issue 10383298: Move RegisterContentSchemes from public url_constants into non-public url_schemes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: allow content/common/savable_url_schemes.h to be included by url_constants.cc Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/chrome_test_suite.h ('k') | content/app/content_main_runner.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) 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 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/metrics/stats_table.h" 10 #include "base/metrics/stats_table.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_content_browser_client.h" 16 #include "chrome/browser/chrome_content_browser_client.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_content_client.h" 18 #include "chrome/common/chrome_content_client.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/test/base/testing_browser_process.h" 21 #include "chrome/test/base/testing_browser_process.h"
22 #include "content/public/common/content_paths.h"
23 #include "net/base/mock_host_resolver.h" 22 #include "net/base/mock_host_resolver.h"
24 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
25 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
26 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/base/resource/resource_handle.h" 27 #include "ui/base/resource/resource_handle.h"
29 #include "ui/base/ui_base_paths.h"
30 28
31 #if defined(OS_MACOSX) 29 #if defined(OS_MACOSX)
32 #include "base/mac/bundle_locations.h" 30 #include "base/mac/bundle_locations.h"
33 #include "base/mac/mac_util.h" 31 #include "base/mac/mac_util.h"
34 #include "base/mac/scoped_nsautorelease_pool.h" 32 #include "base/mac/scoped_nsautorelease_pool.h"
35 #include "chrome/browser/chrome_browser_application_mac.h" 33 #include "chrome/browser/chrome_browser_application_mac.h"
36 #endif 34 #endif
37 35
38 #if defined(OS_POSIX) 36 #if defined(OS_POSIX)
39 #include "base/shared_memory.h" 37 #include "base/shared_memory.h"
40 #endif 38 #endif
41 39
42 #include "ui/compositor/compositor_setup.h"
43
44 namespace { 40 namespace {
45 41
46 void RemoveSharedMemoryFile(const std::string& filename) { 42 void RemoveSharedMemoryFile(const std::string& filename) {
47 // Stats uses SharedMemory under the hood. On posix, this results in a file 43 // Stats uses SharedMemory under the hood. On posix, this results in a file
48 // on disk. 44 // on disk.
49 #if defined(OS_POSIX) 45 #if defined(OS_POSIX)
50 base::SharedMemory memory; 46 base::SharedMemory memory;
51 memory.Delete(filename); 47 memory.Delete(filename);
52 #endif 48 #endif
53 } 49 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; 146 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_;
151 147
152 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); 148 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer);
153 }; 149 };
154 150
155 } // namespace 151 } // namespace
156 152
157 const char ChromeTestSuite::kLaunchAsBrowser[] = "as-browser"; 153 const char ChromeTestSuite::kLaunchAsBrowser[] = "as-browser";
158 154
159 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) 155 ChromeTestSuite::ChromeTestSuite(int argc, char** argv)
160 : base::TestSuite(argc, argv) { 156 : content::ContentTestSuiteBase(argc, argv) {
161 } 157 }
162 158
163 ChromeTestSuite::~ChromeTestSuite() { 159 ChromeTestSuite::~ChromeTestSuite() {
164 } 160 }
165 161
166 void ChromeTestSuite::Initialize() { 162 void ChromeTestSuite::Initialize() {
167 #if defined(OS_MACOSX) 163 #if defined(OS_MACOSX)
168 base::mac::ScopedNSAutoreleasePool autorelease_pool; 164 base::mac::ScopedNSAutoreleasePool autorelease_pool;
169 chrome_browser_application_mac::RegisterBrowserCrApp(); 165 chrome_browser_application_mac::RegisterBrowserCrApp();
170 #endif 166 #endif
171 167
172 base::TestSuite::Initialize(); 168 content::ContentTestSuiteBase::Initialize();
173
174 chrome::ChromeContentClient client_for_init;
175 content::SetContentClient(&client_for_init);
176 content::RegisterContentSchemes(false);
177 content::SetContentClient(NULL);
178 169
179 chrome::RegisterPathProvider(); 170 chrome::RegisterPathProvider();
180 content::RegisterPathProvider();
181 ui::RegisterPathProvider();
182 171
183 if (!browser_dir_.empty()) { 172 if (!browser_dir_.empty()) {
184 PathService::Override(base::DIR_EXE, browser_dir_); 173 PathService::Override(base::DIR_EXE, browser_dir_);
185 PathService::Override(base::DIR_MODULE, browser_dir_); 174 PathService::Override(base::DIR_MODULE, browser_dir_);
186 } 175 }
187 176
188 #if defined(OS_MACOSX) 177 #if defined(OS_MACOSX)
189 // Look in the framework bundle for resources. 178 // Look in the framework bundle for resources.
190 FilePath path; 179 FilePath path;
191 PathService::Get(base::DIR_EXE, &path); 180 PathService::Get(base::DIR_EXE, &path);
192 path = path.Append(chrome::kFrameworkName); 181 path = path.Append(chrome::kFrameworkName);
193 base::mac::SetOverrideFrameworkBundlePath(path); 182 base::mac::SetOverrideFrameworkBundlePath(path);
194 #endif 183 #endif
195 184
196 // Force unittests to run using en-US so if we test against string 185 // Force unittests to run using en-US so if we test against string
197 // output, it'll pass regardless of the system language. 186 // output, it'll pass regardless of the system language.
198 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); 187 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
199 FilePath resources_pack_path; 188 FilePath resources_pack_path;
200 PathService::Get(base::DIR_MODULE, &resources_pack_path); 189 PathService::Get(base::DIR_MODULE, &resources_pack_path);
201 resources_pack_path = 190 resources_pack_path =
202 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); 191 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
203 ResourceBundle::GetSharedInstance().AddDataPack( 192 ResourceBundle::GetSharedInstance().AddDataPack(
204 resources_pack_path, ui::SCALE_FACTOR_100P); 193 resources_pack_path, ui::SCALE_FACTOR_100P);
205 194
206 // Mock out the compositor on platforms that use it.
207 ui::SetupTestCompositor();
208
209 stats_filename_ = base::StringPrintf("unit_tests-%d", 195 stats_filename_ = base::StringPrintf("unit_tests-%d",
210 base::GetCurrentProcId()); 196 base::GetCurrentProcId());
211 RemoveSharedMemoryFile(stats_filename_); 197 RemoveSharedMemoryFile(stats_filename_);
212 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); 198 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200));
213 base::StatsTable::set_current(stats_table_.get()); 199 base::StatsTable::set_current(stats_table_.get());
214 200
215 testing::TestEventListeners& listeners = 201 testing::TestEventListeners& listeners =
216 testing::UnitTest::GetInstance()->listeners(); 202 testing::UnitTest::GetInstance()->listeners();
217 listeners.Append(new ChromeTestSuiteInitializer); 203 listeners.Append(new ChromeTestSuiteInitializer);
218 } 204 }
219 205
206 content::ContentClient* ChromeTestSuite::CreateClientForInitialization() {
207 return new chrome::ChromeContentClient();
208 }
209
220 void ChromeTestSuite::Shutdown() { 210 void ChromeTestSuite::Shutdown() {
221 ResourceBundle::CleanupSharedInstance(); 211 ResourceBundle::CleanupSharedInstance();
222 212
223 #if defined(OS_MACOSX) 213 #if defined(OS_MACOSX)
224 base::mac::SetOverrideFrameworkBundle(NULL); 214 base::mac::SetOverrideFrameworkBundle(NULL);
225 #endif 215 #endif
226 216
227 base::StatsTable::set_current(NULL); 217 base::StatsTable::set_current(NULL);
228 stats_table_.reset(); 218 stats_table_.reset();
229 RemoveSharedMemoryFile(stats_filename_); 219 RemoveSharedMemoryFile(stats_filename_);
230 220
231 base::TestSuite::Shutdown(); 221 base::TestSuite::Shutdown();
232 } 222 }
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_test_suite.h ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698