| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/test/base/chrome_unit_test_suite.h" | 5 #include "chrome/test/base/chrome_unit_test_suite.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/chrome_content_browser_client.h" | 10 #include "chrome/browser/chrome_content_browser_client.h" |
| 11 #include "chrome/browser/omaha_query_params/chrome_omaha_query_params_delegate.h
" | 11 #include "chrome/browser/omaha_query_params/chrome_omaha_query_params_delegate.h
" |
| 12 #include "chrome/common/chrome_content_client.h" | 12 #include "chrome/common/chrome_content_client.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 15 #include "chrome/utility/chrome_content_utility_client.h" | 15 #include "chrome/utility/chrome_content_utility_client.h" |
| 16 #include "components/component_updater/component_updater_paths.h" | 16 #include "components/component_updater/component_updater_paths.h" |
| 17 #include "components/omaha_query_params/omaha_query_params.h" | 17 #include "components/omaha_query_params/omaha_query_params.h" |
| 18 #include "content/public/common/content_paths.h" | 18 #include "content/public/common/content_paths.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/base/resource/resource_handle.h" | 21 #include "ui/base/resource/resource_handle.h" |
| 22 #include "ui/base/ui_base_paths.h" | 22 #include "ui/base/ui_base_paths.h" |
| 23 | 23 |
| 24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 25 #include "chromeos/chromeos_paths.h" | 25 #include "chromeos/chromeos_paths.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #if !defined(OS_IOS) | 28 #if !defined(OS_IOS) |
| 29 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 29 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 30 #include "chrome/common/extensions/chrome_extensions_client.h" | |
| 31 #include "extensions/common/extension_paths.h" | |
| 32 #include "ui/gl/gl_surface.h" | 30 #include "ui/gl/gl_surface.h" |
| 33 #endif | 31 #endif |
| 34 | 32 |
| 35 #if defined(OS_POSIX) | 33 #if defined(OS_POSIX) |
| 36 #include "base/memory/shared_memory.h" | 34 #include "base/memory/shared_memory.h" |
| 37 #endif | 35 #endif |
| 38 | 36 |
| 37 #if defined(ENABLE_EXTENSIONS) |
| 38 #include "chrome/common/extensions/chrome_extensions_client.h" |
| 39 #include "extensions/common/extension_paths.h" |
| 40 #endif |
| 41 |
| 39 namespace { | 42 namespace { |
| 40 | 43 |
| 41 // Creates a TestingBrowserProcess for each test. | 44 // Creates a TestingBrowserProcess for each test. |
| 42 class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { | 45 class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { |
| 43 public: | 46 public: |
| 44 ChromeUnitTestSuiteInitializer() {} | 47 ChromeUnitTestSuiteInitializer() {} |
| 45 virtual ~ChromeUnitTestSuiteInitializer() {} | 48 virtual ~ChromeUnitTestSuiteInitializer() {} |
| 46 | 49 |
| 47 virtual void OnTestStart(const testing::TestInfo& test_info) override { | 50 virtual void OnTestStart(const testing::TestInfo& test_info) override { |
| 48 content_client_.reset(new ChromeContentClient); | 51 content_client_.reset(new ChromeContentClient); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 123 |
| 121 chrome::RegisterPathProvider(); | 124 chrome::RegisterPathProvider(); |
| 122 content::RegisterPathProvider(); | 125 content::RegisterPathProvider(); |
| 123 ui::RegisterPathProvider(); | 126 ui::RegisterPathProvider(); |
| 124 component_updater::RegisterPathProvider(chrome::DIR_USER_DATA); | 127 component_updater::RegisterPathProvider(chrome::DIR_USER_DATA); |
| 125 | 128 |
| 126 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 127 chromeos::RegisterPathProvider(); | 130 chromeos::RegisterPathProvider(); |
| 128 #endif | 131 #endif |
| 129 | 132 |
| 130 #if !defined(OS_IOS) | 133 #if defined(ENABLE_EXTENSIONS) |
| 131 extensions::RegisterPathProvider(); | 134 extensions::RegisterPathProvider(); |
| 132 | 135 |
| 133 extensions::ExtensionsClient::Set( | 136 extensions::ExtensionsClient::Set( |
| 134 extensions::ChromeExtensionsClient::GetInstance()); | 137 extensions::ChromeExtensionsClient::GetInstance()); |
| 138 #endif |
| 135 | 139 |
| 140 #if !defined(OS_IOS) |
| 136 content::WebUIControllerFactory::RegisterFactory( | 141 content::WebUIControllerFactory::RegisterFactory( |
| 137 ChromeWebUIControllerFactory::GetInstance()); | 142 ChromeWebUIControllerFactory::GetInstance()); |
| 138 | 143 |
| 139 gfx::GLSurface::InitializeOneOffForTests(); | 144 gfx::GLSurface::InitializeOneOffForTests(); |
| 140 | 145 |
| 141 omaha_query_params::OmahaQueryParams::SetDelegate( | 146 omaha_query_params::OmahaQueryParams::SetDelegate( |
| 142 ChromeOmahaQueryParamsDelegate::GetInstance()); | 147 ChromeOmahaQueryParamsDelegate::GetInstance()); |
| 143 #endif | 148 #endif |
| 144 } | 149 } |
| 145 | 150 |
| 146 void ChromeUnitTestSuite::InitializeResourceBundle() { | 151 void ChromeUnitTestSuite::InitializeResourceBundle() { |
| 147 // Force unittests to run using en-US so if we test against string | 152 // Force unittests to run using en-US so if we test against string |
| 148 // output, it'll pass regardless of the system language. | 153 // output, it'll pass regardless of the system language. |
| 149 ui::ResourceBundle::InitSharedInstanceWithLocale( | 154 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 150 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 155 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 151 base::FilePath resources_pack_path; | 156 base::FilePath resources_pack_path; |
| 152 #if defined(OS_MACOSX) && !defined(OS_IOS) | 157 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 153 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 158 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 154 resources_pack_path = | 159 resources_pack_path = |
| 155 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 160 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 156 #else | 161 #else |
| 157 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 162 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 158 #endif | 163 #endif |
| 159 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 164 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 160 resources_pack_path, ui::SCALE_FACTOR_NONE); | 165 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 161 } | 166 } |
| OLD | NEW |