| 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_client/chrome_omaha_query_params_delegate.h" | 11 #include "chrome/browser/update_client/chrome_update_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_client/omaha_query_params.h" | |
| 18 #include "components/translate/content/browser/browser_cld_data_provider_factory
.h" | 17 #include "components/translate/content/browser/browser_cld_data_provider_factory
.h" |
| 19 #include "components/translate/content/common/cld_data_source.h" | 18 #include "components/translate/content/common/cld_data_source.h" |
| 19 #include "components/update_client/update_query_params.h" |
| 20 #include "content/public/common/content_paths.h" | 20 #include "content/public/common/content_paths.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/base/resource/resource_handle.h" | 23 #include "ui/base/resource/resource_handle.h" |
| 24 #include "ui/base/ui_base_paths.h" | 24 #include "ui/base/ui_base_paths.h" |
| 25 | 25 |
| 26 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 27 #include "chromeos/chromeos_paths.h" | 27 #include "chromeos/chromeos_paths.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // Creates a TestingBrowserProcess for each test. | 46 // Creates a TestingBrowserProcess for each test. |
| 47 class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { | 47 class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { |
| 48 public: | 48 public: |
| 49 ChromeUnitTestSuiteInitializer() {} | 49 ChromeUnitTestSuiteInitializer() {} |
| 50 virtual ~ChromeUnitTestSuiteInitializer() {} | 50 virtual ~ChromeUnitTestSuiteInitializer() {} |
| 51 | 51 |
| 52 virtual void OnTestStart(const testing::TestInfo& test_info) override { | 52 void OnTestStart(const testing::TestInfo& test_info) override { |
| 53 content_client_.reset(new ChromeContentClient); | 53 content_client_.reset(new ChromeContentClient); |
| 54 content::SetContentClient(content_client_.get()); | 54 content::SetContentClient(content_client_.get()); |
| 55 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. | 55 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
| 56 #if !defined(OS_IOS) | 56 #if !defined(OS_IOS) |
| 57 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); | 57 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
| 58 content::SetBrowserClientForTesting(browser_content_client_.get()); | 58 content::SetBrowserClientForTesting(browser_content_client_.get()); |
| 59 utility_content_client_.reset(new ChromeContentUtilityClient()); | 59 utility_content_client_.reset(new ChromeContentUtilityClient()); |
| 60 content::SetUtilityClientForTesting(utility_content_client_.get()); | 60 content::SetUtilityClientForTesting(utility_content_client_.get()); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 TestingBrowserProcess::CreateInstance(); | 63 TestingBrowserProcess::CreateInstance(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void OnTestEnd(const testing::TestInfo& test_info) override { | 66 void OnTestEnd(const testing::TestInfo& test_info) override { |
| 67 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. | 67 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
| 68 #if !defined(OS_IOS) | 68 #if !defined(OS_IOS) |
| 69 browser_content_client_.reset(); | 69 browser_content_client_.reset(); |
| 70 utility_content_client_.reset(); | 70 utility_content_client_.reset(); |
| 71 #endif | 71 #endif |
| 72 content_client_.reset(); | 72 content_client_.reset(); |
| 73 content::SetContentClient(NULL); | 73 content::SetContentClient(NULL); |
| 74 | 74 |
| 75 TestingBrowserProcess::DeleteInstance(); | 75 TestingBrowserProcess::DeleteInstance(); |
| 76 } | 76 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 extensions::ExtensionsClient::Set( | 142 extensions::ExtensionsClient::Set( |
| 143 extensions::ChromeExtensionsClient::GetInstance()); | 143 extensions::ChromeExtensionsClient::GetInstance()); |
| 144 #endif | 144 #endif |
| 145 | 145 |
| 146 #if !defined(OS_IOS) | 146 #if !defined(OS_IOS) |
| 147 content::WebUIControllerFactory::RegisterFactory( | 147 content::WebUIControllerFactory::RegisterFactory( |
| 148 ChromeWebUIControllerFactory::GetInstance()); | 148 ChromeWebUIControllerFactory::GetInstance()); |
| 149 | 149 |
| 150 gfx::GLSurface::InitializeOneOffForTests(); | 150 gfx::GLSurface::InitializeOneOffForTests(); |
| 151 | 151 |
| 152 omaha_client::OmahaQueryParams::SetDelegate( | 152 update_client::UpdateQueryParams::SetDelegate( |
| 153 ChromeOmahaQueryParamsDelegate::GetInstance()); | 153 ChromeUpdateQueryParamsDelegate::GetInstance()); |
| 154 #endif | 154 #endif |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ChromeUnitTestSuite::InitializeResourceBundle() { | 157 void ChromeUnitTestSuite::InitializeResourceBundle() { |
| 158 // Force unittests to run using en-US so if we test against string | 158 // Force unittests to run using en-US so if we test against string |
| 159 // output, it'll pass regardless of the system language. | 159 // output, it'll pass regardless of the system language. |
| 160 ui::ResourceBundle::InitSharedInstanceWithLocale( | 160 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 161 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 161 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 162 base::FilePath resources_pack_path; | 162 base::FilePath resources_pack_path; |
| 163 #if defined(OS_MACOSX) && !defined(OS_IOS) | 163 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 164 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 164 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 165 resources_pack_path = | 165 resources_pack_path = |
| 166 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 166 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 167 #else | 167 #else |
| 168 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 168 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 169 #endif | 169 #endif |
| 170 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 170 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 171 resources_pack_path, ui::SCALE_FACTOR_NONE); | 171 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 172 } | 172 } |
| OLD | NEW |