OLD | NEW |
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 |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/metrics/stats_table.h" | 15 #include "base/metrics/stats_table.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chrome_content_browser_client.h" | 21 #include "chrome/browser/chrome_content_browser_client.h" |
| 22 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_content_client.h" | 24 #include "chrome/common/chrome_content_client.h" |
24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "chrome/test/base/testing_browser_process.h" | 27 #include "chrome/test/base/testing_browser_process.h" |
| 28 #include "content/public/test/test_launcher.h" |
27 #include "net/base/mock_host_resolver.h" | 29 #include "net/base/mock_host_resolver.h" |
28 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
29 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/base/resource/resource_handle.h" | 34 #include "ui/base/resource/resource_handle.h" |
33 | 35 |
34 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
35 #include "base/android/jni_android.h" | 37 #include "base/android/jni_android.h" |
36 #include "chrome/browser/android/chrome_jni_registrar.h" | 38 #include "chrome/browser/android/chrome_jni_registrar.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 net::android::RegisterJni(base::android::AttachCurrentThread()); | 206 net::android::RegisterJni(base::android::AttachCurrentThread()); |
205 chrome::android::RegisterJni(base::android::AttachCurrentThread()); | 207 chrome::android::RegisterJni(base::android::AttachCurrentThread()); |
206 #endif | 208 #endif |
207 | 209 |
208 chrome::RegisterPathProvider(); | 210 chrome::RegisterPathProvider(); |
209 if (!browser_dir_.empty()) { | 211 if (!browser_dir_.empty()) { |
210 PathService::Override(base::DIR_EXE, browser_dir_); | 212 PathService::Override(base::DIR_EXE, browser_dir_); |
211 PathService::Override(base::DIR_MODULE, browser_dir_); | 213 PathService::Override(base::DIR_MODULE, browser_dir_); |
212 } | 214 } |
213 | 215 |
| 216 #if !defined(OS_IOS) |
| 217 if (!content::GetCurrentTestLauncherDelegate()) { |
| 218 // Only want to do this for unit tests. For browser tests, this won't create |
| 219 // the right object since TestChromeWebUIControllerFactory is used. That's |
| 220 // created and registered in ChromeBrowserMainParts as in normal startup. |
| 221 content::WebUIControllerFactory::RegisterFactory( |
| 222 ChromeWebUIControllerFactory::GetInstance()); |
| 223 } |
| 224 #endif |
| 225 |
214 // Disable external libraries load if we are under python process in | 226 // Disable external libraries load if we are under python process in |
215 // ChromeOS. That means we are autotest and, if ASAN is used, | 227 // ChromeOS. That means we are autotest and, if ASAN is used, |
216 // external libraries load crashes. | 228 // external libraries load crashes. |
217 content::ContentTestSuiteBase::set_external_libraries_enabled( | 229 content::ContentTestSuiteBase::set_external_libraries_enabled( |
218 !IsCrosPythonProcess()); | 230 !IsCrosPythonProcess()); |
219 | 231 |
220 // Initialize after overriding paths as some content paths depend on correct | 232 // Initialize after overriding paths as some content paths depend on correct |
221 // values for DIR_EXE and DIR_MODULE. | 233 // values for DIR_EXE and DIR_MODULE. |
222 content::ContentTestSuiteBase::Initialize(); | 234 content::ContentTestSuiteBase::Initialize(); |
223 | 235 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 #if defined(OS_MACOSX) && !defined(OS_IOS) | 272 #if defined(OS_MACOSX) && !defined(OS_IOS) |
261 base::mac::SetOverrideFrameworkBundle(NULL); | 273 base::mac::SetOverrideFrameworkBundle(NULL); |
262 #endif | 274 #endif |
263 | 275 |
264 base::StatsTable::set_current(NULL); | 276 base::StatsTable::set_current(NULL); |
265 stats_table_.reset(); | 277 stats_table_.reset(); |
266 RemoveSharedMemoryFile(stats_filename_); | 278 RemoveSharedMemoryFile(stats_filename_); |
267 | 279 |
268 base::TestSuite::Shutdown(); | 280 base::TestSuite::Shutdown(); |
269 } | 281 } |
OLD | NEW |