| 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 #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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/metrics/stats_table.h" | 10 #include "base/metrics/stats_table.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/mac/bundle_locations.h" | 31 #include "base/mac/bundle_locations.h" |
| 32 #include "base/mac/mac_util.h" | 32 #include "base/mac/mac_util.h" |
| 33 #include "base/mac/scoped_nsautorelease_pool.h" | 33 #include "base/mac/scoped_nsautorelease_pool.h" |
| 34 #include "chrome/browser/chrome_browser_application_mac.h" | 34 #include "chrome/browser/chrome_browser_application_mac.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if defined(OS_POSIX) | 37 #if defined(OS_POSIX) |
| 38 #include "base/shared_memory.h" | 38 #include "base/shared_memory.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #if defined(USE_WEBKIT_COMPOSITOR) | |
| 42 #include "ui/gfx/compositor/compositor_setup.h" | 41 #include "ui/gfx/compositor/compositor_setup.h" |
| 43 #else | |
| 44 #include "ui/gfx/test/gfx_test_utils.h" | |
| 45 #endif | |
| 46 | 42 |
| 47 namespace { | 43 namespace { |
| 48 | 44 |
| 49 void RemoveSharedMemoryFile(const std::string& filename) { | 45 void RemoveSharedMemoryFile(const std::string& filename) { |
| 50 // Stats uses SharedMemory under the hood. On posix, this results in a file | 46 // Stats uses SharedMemory under the hood. On posix, this results in a file |
| 51 // on disk. | 47 // on disk. |
| 52 #if defined(OS_POSIX) | 48 #if defined(OS_POSIX) |
| 53 base::SharedMemory memory; | 49 base::SharedMemory memory; |
| 54 memory.Delete(filename); | 50 memory.Delete(filename); |
| 55 #endif | 51 #endif |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // Force unittests to run using en-US so if we test against string | 188 // Force unittests to run using en-US so if we test against string |
| 193 // output, it'll pass regardless of the system language. | 189 // output, it'll pass regardless of the system language. |
| 194 ResourceBundle::InitSharedInstance("en-US"); | 190 ResourceBundle::InitSharedInstance("en-US"); |
| 195 FilePath resources_pack_path; | 191 FilePath resources_pack_path; |
| 196 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 192 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 197 resources_pack_path = | 193 resources_pack_path = |
| 198 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 194 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 199 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); | 195 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); |
| 200 | 196 |
| 201 // Mock out the compositor on platforms that use it. | 197 // Mock out the compositor on platforms that use it. |
| 202 #if defined(USE_WEBKIT_COMPOSITOR) | |
| 203 ui::SetupTestCompositor(); | 198 ui::SetupTestCompositor(); |
| 204 #else | |
| 205 ui::gfx_test_utils::SetupTestCompositor(); | |
| 206 #endif | |
| 207 | 199 |
| 208 stats_filename_ = base::StringPrintf("unit_tests-%d", | 200 stats_filename_ = base::StringPrintf("unit_tests-%d", |
| 209 base::GetCurrentProcId()); | 201 base::GetCurrentProcId()); |
| 210 RemoveSharedMemoryFile(stats_filename_); | 202 RemoveSharedMemoryFile(stats_filename_); |
| 211 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); | 203 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); |
| 212 base::StatsTable::set_current(stats_table_.get()); | 204 base::StatsTable::set_current(stats_table_.get()); |
| 213 | 205 |
| 214 testing::TestEventListeners& listeners = | 206 testing::TestEventListeners& listeners = |
| 215 testing::UnitTest::GetInstance()->listeners(); | 207 testing::UnitTest::GetInstance()->listeners(); |
| 216 listeners.Append(new ChromeTestSuiteInitializer); | 208 listeners.Append(new ChromeTestSuiteInitializer); |
| 217 } | 209 } |
| 218 | 210 |
| 219 void ChromeTestSuite::Shutdown() { | 211 void ChromeTestSuite::Shutdown() { |
| 220 ResourceBundle::CleanupSharedInstance(); | 212 ResourceBundle::CleanupSharedInstance(); |
| 221 | 213 |
| 222 #if defined(OS_MACOSX) | 214 #if defined(OS_MACOSX) |
| 223 base::mac::SetOverrideFrameworkBundle(NULL); | 215 base::mac::SetOverrideFrameworkBundle(NULL); |
| 224 #endif | 216 #endif |
| 225 | 217 |
| 226 base::StatsTable::set_current(NULL); | 218 base::StatsTable::set_current(NULL); |
| 227 stats_table_.reset(); | 219 stats_table_.reset(); |
| 228 RemoveSharedMemoryFile(stats_filename_); | 220 RemoveSharedMemoryFile(stats_filename_); |
| 229 | 221 |
| 230 base::TestSuite::Shutdown(); | 222 base::TestSuite::Shutdown(); |
| 231 } | 223 } |
| OLD | NEW |