Chromium Code Reviews| 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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 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/common/content_paths.h" | 23 #include "content/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 |
| 31 #if defined(VIEWS_COMPOSITOR) | |
| 32 #include "ui/gfx/compositor/compositor.h" | |
| 33 #include "ui/gfx/compositor/test_compositor.h" | |
| 34 #endif | |
| 35 | |
| 31 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
| 32 #include "views/view.h" | 37 #include "views/view.h" |
| 33 #endif | 38 #endif |
| 34 | 39 |
| 40 #if defined(OS_LINUX) | |
| 41 #include "ui/gfx/gl/gl_switches.h" | |
| 42 #endif | |
| 43 | |
| 35 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 36 #include "base/mac/mac_util.h" | 45 #include "base/mac/mac_util.h" |
| 37 #include "content/common/chrome_application_mac.h" | 46 #include "content/common/chrome_application_mac.h" |
| 38 #endif | 47 #endif |
| 39 | 48 |
| 40 #if defined(OS_POSIX) | 49 #if defined(OS_POSIX) |
| 41 #include "base/shared_memory.h" | 50 #include "base/shared_memory.h" |
| 42 #endif | 51 #endif |
| 43 | 52 |
| 44 namespace { | 53 namespace { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 : base::TestSuite(argc, argv) { | 165 : base::TestSuite(argc, argv) { |
| 157 } | 166 } |
| 158 | 167 |
| 159 ChromeTestSuite::~ChromeTestSuite() { | 168 ChromeTestSuite::~ChromeTestSuite() { |
| 160 } | 169 } |
| 161 | 170 |
| 162 void ChromeTestSuite::Initialize() { | 171 void ChromeTestSuite::Initialize() { |
| 163 #if defined(OS_MACOSX) | 172 #if defined(OS_MACOSX) |
| 164 chrome_application_mac::RegisterCrApp(); | 173 chrome_application_mac::RegisterCrApp(); |
| 165 #endif | 174 #endif |
| 175 #if defined(OS_LINUX) | |
|
sky
2011/10/14 20:52:41
#elif
danakj
2011/10/17 14:52:13
Done.
| |
| 176 // trybots don't have DesktopGL | |
| 177 EXPECT_TRUE(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)); | |
| 178 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 179 switches::kUseGL, gfx::kGLImplementationOSMesaName); | |
| 180 #endif | |
| 166 | 181 |
| 167 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 182 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 168 | 183 |
| 169 base::TestSuite::Initialize(); | 184 base::TestSuite::Initialize(); |
| 170 | 185 |
| 171 chrome::RegisterChromeSchemes(); | 186 chrome::RegisterChromeSchemes(); |
| 172 | 187 |
| 173 chrome::RegisterPathProvider(); | 188 chrome::RegisterPathProvider(); |
| 174 content::RegisterPathProvider(); | 189 content::RegisterPathProvider(); |
| 175 ui::RegisterPathProvider(); | 190 ui::RegisterPathProvider(); |
| 176 | 191 |
| 177 if (!browser_dir_.empty()) { | 192 if (!browser_dir_.empty()) { |
| 178 PathService::Override(base::DIR_EXE, browser_dir_); | 193 PathService::Override(base::DIR_EXE, browser_dir_); |
| 179 PathService::Override(base::DIR_MODULE, browser_dir_); | 194 PathService::Override(base::DIR_MODULE, browser_dir_); |
| 180 } | 195 } |
| 181 | 196 |
| 182 #if defined(OS_MACOSX) | 197 #if defined(OS_MACOSX) |
| 183 // Look in the framework bundle for resources. | 198 // Look in the framework bundle for resources. |
| 184 FilePath path; | 199 FilePath path; |
| 185 PathService::Get(base::DIR_EXE, &path); | 200 PathService::Get(base::DIR_EXE, &path); |
| 186 path = path.Append(chrome::kFrameworkName); | 201 path = path.Append(chrome::kFrameworkName); |
| 187 base::mac::SetOverrideAppBundlePath(path); | 202 base::mac::SetOverrideAppBundlePath(path); |
| 188 #endif | 203 #endif |
| 189 | 204 |
| 205 #if defined(VIEWS_COMPOSITOR) | |
| 206 // Use a mock compositor that noops draws. | |
| 207 ui::Compositor::set_compositor_factory_for_testing( | |
| 208 ui::TestCompositor::Create); | |
| 209 #endif | |
| 210 | |
| 190 // Force unittests to run using en-US so if we test against string | 211 // Force unittests to run using en-US so if we test against string |
| 191 // output, it'll pass regardless of the system language. | 212 // output, it'll pass regardless of the system language. |
| 192 ResourceBundle::InitSharedInstance("en-US"); | 213 ResourceBundle::InitSharedInstance("en-US"); |
| 193 FilePath resources_pack_path; | 214 FilePath resources_pack_path; |
| 194 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 215 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 195 resources_pack_path = | 216 resources_pack_path = |
| 196 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 217 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 197 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); | 218 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); |
| 198 | 219 |
| 199 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) | |
| 200 // Turn of GPU compositing in browser during unit tests. | |
| 201 views::View::set_use_acceleration_when_possible(false); | |
| 202 #endif | |
| 203 | |
| 204 stats_filename_ = base::StringPrintf("unit_tests-%d", | 220 stats_filename_ = base::StringPrintf("unit_tests-%d", |
| 205 base::GetCurrentProcId()); | 221 base::GetCurrentProcId()); |
| 206 RemoveSharedMemoryFile(stats_filename_); | 222 RemoveSharedMemoryFile(stats_filename_); |
| 207 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); | 223 stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200)); |
| 208 base::StatsTable::set_current(stats_table_.get()); | 224 base::StatsTable::set_current(stats_table_.get()); |
| 209 | 225 |
| 210 testing::TestEventListeners& listeners = | 226 testing::TestEventListeners& listeners = |
| 211 testing::UnitTest::GetInstance()->listeners(); | 227 testing::UnitTest::GetInstance()->listeners(); |
| 212 listeners.Append(new ChromeTestSuiteInitializer); | 228 listeners.Append(new ChromeTestSuiteInitializer); |
| 213 } | 229 } |
| 214 | 230 |
| 215 void ChromeTestSuite::Shutdown() { | 231 void ChromeTestSuite::Shutdown() { |
| 216 ResourceBundle::CleanupSharedInstance(); | 232 ResourceBundle::CleanupSharedInstance(); |
| 217 | 233 |
| 218 #if defined(OS_MACOSX) | 234 #if defined(OS_MACOSX) |
| 219 base::mac::SetOverrideAppBundle(NULL); | 235 base::mac::SetOverrideAppBundle(NULL); |
| 220 #endif | 236 #endif |
| 221 | 237 |
| 222 base::StatsTable::set_current(NULL); | 238 base::StatsTable::set_current(NULL); |
| 223 stats_table_.reset(); | 239 stats_table_.reset(); |
| 224 RemoveSharedMemoryFile(stats_filename_); | 240 RemoveSharedMemoryFile(stats_filename_); |
| 225 | 241 |
| 226 base::TestSuite::Shutdown(); | 242 base::TestSuite::Shutdown(); |
| 227 } | 243 } |
| OLD | NEW |