OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac/scoped_nsautorelease_pool.h" | 9 #include "base/mac/scoped_nsautorelease_pool.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/metrics/stats_table.h" | 11 #include "base/metrics/stats_table.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_content_browser_client.h" | 17 #include "chrome/browser/chrome_content_browser_client.h" |
18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_content_client.h" | 19 #include "chrome/common/chrome_content_client.h" |
20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
23 #include "content/public/common/content_paths.h" | 23 #include "content/public/common/content_paths.h" |
24 #include "net/base/mock_host_resolver.h" | 24 #include "net/base/mock_host_resolver.h" |
25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
26 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/base/ui_base_paths.h" | 29 #include "ui/base/ui_base_paths.h" |
30 | 30 #include "ui/gfx/compositor/compositor_test_support.h" |
31 #if defined(TOOLKIT_VIEWS) | |
32 #include "views/view.h" | |
33 #endif | |
34 | 31 |
35 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
36 #include "base/mac/mac_util.h" | 33 #include "base/mac/mac_util.h" |
37 #include "content/common/chrome_application_mac.h" | 34 #include "content/common/chrome_application_mac.h" |
38 #endif | 35 #endif |
39 | 36 |
40 #if defined(OS_POSIX) | 37 #if defined(OS_POSIX) |
41 #include "base/shared_memory.h" | 38 #include "base/shared_memory.h" |
42 #endif | 39 #endif |
43 | 40 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 186 |
190 // Force unittests to run using en-US so if we test against string | 187 // Force unittests to run using en-US so if we test against string |
191 // output, it'll pass regardless of the system language. | 188 // output, it'll pass regardless of the system language. |
192 ResourceBundle::InitSharedInstance("en-US"); | 189 ResourceBundle::InitSharedInstance("en-US"); |
193 FilePath resources_pack_path; | 190 FilePath resources_pack_path; |
194 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 191 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
195 resources_pack_path = | 192 resources_pack_path = |
196 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 193 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
197 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); | 194 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); |
198 | 195 |
199 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) | 196 // Mock out the compositor on platforms that use it. |
200 // Turn of GPU compositing in browser during unit tests. | 197 ui::CompositorTestSupport::SetupMockCompositor(); |
201 views::View::set_use_acceleration_when_possible(false); | |
202 #endif | |
203 | 198 |
204 stats_filename_ = base::StringPrintf("unit_tests-%d", | 199 stats_filename_ = base::StringPrintf("unit_tests-%d", |
205 base::GetCurrentProcId()); | 200 base::GetCurrentProcId()); |
206 RemoveSharedMemoryFile(stats_filename_); | 201 RemoveSharedMemoryFile(stats_filename_); |
207 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); | 202 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); |
208 base::StatsTable::set_current(stats_table_.get()); | 203 base::StatsTable::set_current(stats_table_.get()); |
209 | 204 |
210 testing::TestEventListeners& listeners = | 205 testing::TestEventListeners& listeners = |
211 testing::UnitTest::GetInstance()->listeners(); | 206 testing::UnitTest::GetInstance()->listeners(); |
212 listeners.Append(new ChromeTestSuiteInitializer); | 207 listeners.Append(new ChromeTestSuiteInitializer); |
213 } | 208 } |
214 | 209 |
215 void ChromeTestSuite::Shutdown() { | 210 void ChromeTestSuite::Shutdown() { |
216 ResourceBundle::CleanupSharedInstance(); | 211 ResourceBundle::CleanupSharedInstance(); |
217 | 212 |
218 #if defined(OS_MACOSX) | 213 #if defined(OS_MACOSX) |
219 base::mac::SetOverrideAppBundle(NULL); | 214 base::mac::SetOverrideAppBundle(NULL); |
220 #endif | 215 #endif |
221 | 216 |
222 base::StatsTable::set_current(NULL); | 217 base::StatsTable::set_current(NULL); |
223 stats_table_.reset(); | 218 stats_table_.reset(); |
224 RemoveSharedMemoryFile(stats_filename_); | 219 RemoveSharedMemoryFile(stats_filename_); |
225 | 220 |
226 base::TestSuite::Shutdown(); | 221 base::TestSuite::Shutdown(); |
227 } | 222 } |
OLD | NEW |