| 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/metrics/stats_table.h" | |
| 10 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 11 #include "chrome/browser/chrome_content_browser_client.h" | 10 #include "chrome/browser/chrome_content_browser_client.h" |
| 12 #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
" |
| 13 #include "chrome/common/chrome_content_client.h" | 12 #include "chrome/common/chrome_content_client.h" |
| 14 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "chrome/utility/chrome_content_utility_client.h" | 15 #include "chrome/utility/chrome_content_utility_client.h" |
| 17 #include "components/omaha_query_params/omaha_query_params.h" | 16 #include "components/omaha_query_params/omaha_query_params.h" |
| 18 #include "content/public/common/content_paths.h" | 17 #include "content/public/common/content_paths.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // Add an additional listener to do the extra initialization for unit tests. | 92 // Add an additional listener to do the extra initialization for unit tests. |
| 94 // It will be started before the base class listeners and ended after the | 93 // It will be started before the base class listeners and ended after the |
| 95 // base class listeners. | 94 // base class listeners. |
| 96 testing::TestEventListeners& listeners = | 95 testing::TestEventListeners& listeners = |
| 97 testing::UnitTest::GetInstance()->listeners(); | 96 testing::UnitTest::GetInstance()->listeners(); |
| 98 listeners.Append(new ChromeUnitTestSuiteInitializer); | 97 listeners.Append(new ChromeUnitTestSuiteInitializer); |
| 99 | 98 |
| 100 InitializeProviders(); | 99 InitializeProviders(); |
| 101 RegisterInProcessThreads(); | 100 RegisterInProcessThreads(); |
| 102 | 101 |
| 103 // Create an anonymous stats table since we don't need to share between | |
| 104 // processes. | |
| 105 stats_table_.reset( | |
| 106 new base::StatsTable(base::StatsTable::TableIdentifier(), 20, 200)); | |
| 107 base::StatsTable::set_current(stats_table_.get()); | |
| 108 | |
| 109 ChromeTestSuite::Initialize(); | 102 ChromeTestSuite::Initialize(); |
| 110 | 103 |
| 111 // This needs to run after ChromeTestSuite::Initialize which calls content's | 104 // This needs to run after ChromeTestSuite::Initialize which calls content's |
| 112 // intialization which calls base's which initializes ICU. | 105 // intialization which calls base's which initializes ICU. |
| 113 InitializeResourceBundle(); | 106 InitializeResourceBundle(); |
| 114 } | 107 } |
| 115 | 108 |
| 116 void ChromeUnitTestSuite::Shutdown() { | 109 void ChromeUnitTestSuite::Shutdown() { |
| 117 ResourceBundle::CleanupSharedInstance(); | 110 ResourceBundle::CleanupSharedInstance(); |
| 118 | |
| 119 base::StatsTable::set_current(NULL); | |
| 120 stats_table_.reset(); | |
| 121 | |
| 122 ChromeTestSuite::Shutdown(); | 111 ChromeTestSuite::Shutdown(); |
| 123 } | 112 } |
| 124 | 113 |
| 125 void ChromeUnitTestSuite::InitializeProviders() { | 114 void ChromeUnitTestSuite::InitializeProviders() { |
| 126 { | 115 { |
| 127 ChromeContentClient content_client; | 116 ChromeContentClient content_client; |
| 128 RegisterContentSchemes(&content_client); | 117 RegisterContentSchemes(&content_client); |
| 129 } | 118 } |
| 130 | 119 |
| 131 chrome::RegisterPathProvider(); | 120 chrome::RegisterPathProvider(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 160 #if defined(OS_MACOSX) && !defined(OS_IOS) | 149 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 161 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 150 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 162 resources_pack_path = | 151 resources_pack_path = |
| 163 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 152 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 164 #else | 153 #else |
| 165 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 154 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 166 #endif | 155 #endif |
| 167 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 156 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 168 resources_pack_path, ui::SCALE_FACTOR_NONE); | 157 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 169 } | 158 } |
| OLD | NEW |