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 "base/test/test_suite.h" | 5 #include "base/test/test_suite.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "testing/multiprocess_func_list.h" | 23 #include "testing/multiprocess_func_list.h" |
24 | 24 |
25 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
26 #include "base/mac/scoped_nsautorelease_pool.h" | 26 #include "base/mac/scoped_nsautorelease_pool.h" |
27 #include "base/test/mock_chrome_application_mac.h" | 27 #include "base/test/mock_chrome_application_mac.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
31 #include "base/test/test_stub_android.h" | 31 #include "base/test/test_support_android.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(TOOLKIT_GTK) | 34 #if defined(TOOLKIT_GTK) |
35 #include <gtk/gtk.h> | 35 #include <gtk/gtk.h> |
36 #endif | 36 #endif |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 class MaybeTestDisabler : public testing::EmptyTestEventListener { | 40 class MaybeTestDisabler : public testing::EmptyTestEventListener { |
41 public: | 41 public: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 testing::InitGoogleTest(&argc, argv); | 95 testing::InitGoogleTest(&argc, argv); |
96 #if defined(OS_LINUX) && defined(USE_AURA) | 96 #if defined(OS_LINUX) && defined(USE_AURA) |
97 // When calling native char conversion functions (e.g wrctomb) we need to | 97 // When calling native char conversion functions (e.g wrctomb) we need to |
98 // have the locale set. In the absence of such a call the "C" locale is the | 98 // have the locale set. In the absence of such a call the "C" locale is the |
99 // default. In the gtk code (below) gtk_init() implicitly sets a locale. | 99 // default. In the gtk code (below) gtk_init() implicitly sets a locale. |
100 setlocale(LC_ALL, ""); | 100 setlocale(LC_ALL, ""); |
101 #elif defined(TOOLKIT_GTK) | 101 #elif defined(TOOLKIT_GTK) |
102 gtk_init_check(&argc, &argv); | 102 gtk_init_check(&argc, &argv); |
103 #endif // defined(TOOLKIT_GTK) | 103 #endif // defined(TOOLKIT_GTK) |
104 if (create_at_exit_manager) | 104 if (create_at_exit_manager) |
105 at_exit_manager_.reset(new base::AtExitManager); | 105 at_exit_manager_.reset(new base::ShadowingAtExitManager); |
Paweł Hajdan Jr.
2012/05/25 19:06:08
This looks Very Bad to me. You should not need tha
Xianzhu
2012/05/29 17:15:55
Now use #if !defined(ANDROID_APK_TEST_TARGET). Wil
| |
106 | 106 |
107 // Don't add additional code to this function. Instead add it to | 107 // Don't add additional code to this function. Instead add it to |
108 // Initialize(). See bug 6436. | 108 // Initialize(). See bug 6436. |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 // static | 112 // static |
113 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { | 113 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { |
114 return strncmp(test.name(), "FLAKY_", 6) == 0; | 114 return strncmp(test.name(), "FLAKY_", 6) == 0; |
115 } | 115 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 #endif // defined(OS_WIN) | 230 #endif // defined(OS_WIN) |
231 } | 231 } |
232 | 232 |
233 void TestSuite::Initialize() { | 233 void TestSuite::Initialize() { |
234 #if defined(OS_MACOSX) | 234 #if defined(OS_MACOSX) |
235 // Some of the app unit tests spin runloops. | 235 // Some of the app unit tests spin runloops. |
236 mock_cr_app::RegisterMockCrApp(); | 236 mock_cr_app::RegisterMockCrApp(); |
237 #endif | 237 #endif |
238 | 238 |
239 #if defined(OS_ANDROID) | 239 #if defined(OS_ANDROID) |
240 InitAndroidTestStub(); | 240 InitAndroidTest(); |
241 #endif | 241 #else |
242 | |
243 // Initialize logging. | 242 // Initialize logging. |
244 FilePath exe; | 243 FilePath exe; |
245 PathService::Get(base::FILE_EXE, &exe); | 244 PathService::Get(base::FILE_EXE, &exe); |
246 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); | 245 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); |
247 logging::InitLogging( | 246 logging::InitLogging( |
248 log_filename.value().c_str(), | 247 log_filename.value().c_str(), |
249 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 248 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
250 logging::LOCK_LOG_FILE, | 249 logging::LOCK_LOG_FILE, |
251 logging::DELETE_OLD_LOG_FILE, | 250 logging::DELETE_OLD_LOG_FILE, |
252 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 251 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
253 // We want process and thread IDs because we may have multiple processes. | 252 // We want process and thread IDs because we may have multiple processes. |
254 // Note: temporarily enabled timestamps in an effort to catch bug 6361. | 253 // Note: temporarily enabled timestamps in an effort to catch bug 6361. |
255 logging::SetLogItems(true, true, true, true); | 254 logging::SetLogItems(true, true, true, true); |
255 #endif // else defined(OS_ANDROID) | |
256 | 256 |
257 CHECK(base::EnableInProcessStackDumping()); | 257 CHECK(base::EnableInProcessStackDumping()); |
258 #if defined(OS_WIN) | 258 #if defined(OS_WIN) |
259 // Make sure we run with high resolution timer to minimize differences | 259 // Make sure we run with high resolution timer to minimize differences |
260 // between production code and test code. | 260 // between production code and test code. |
261 base::Time::EnableHighResolutionTimer(true); | 261 base::Time::EnableHighResolutionTimer(true); |
262 #endif // defined(OS_WIN) | 262 #endif // defined(OS_WIN) |
263 | 263 |
264 // In some cases, we do not want to see standard error dialogs. | 264 // In some cases, we do not want to see standard error dialogs. |
265 if (!base::debug::BeingDebugged() && | 265 if (!base::debug::BeingDebugged() && |
266 !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { | 266 !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { |
267 SuppressErrorDialogs(); | 267 SuppressErrorDialogs(); |
268 base::debug::SetSuppressDebugUI(true); | 268 base::debug::SetSuppressDebugUI(true); |
269 logging::SetLogAssertHandler(UnitTestAssertHandler); | 269 logging::SetLogAssertHandler(UnitTestAssertHandler); |
270 } | 270 } |
271 | 271 |
272 #if !defined(OS_ANDROID) | |
273 // TODO(michaelbai): The icu can not be compiled in Android now, this should | |
274 // be enabled once icu is ready. http://b/5406077. | |
275 icu_util::Initialize(); | 272 icu_util::Initialize(); |
276 #endif | |
277 | 273 |
278 CatchMaybeTests(); | 274 CatchMaybeTests(); |
279 ResetCommandLine(); | 275 ResetCommandLine(); |
280 | 276 |
281 TestTimeouts::Initialize(); | 277 TestTimeouts::Initialize(); |
282 } | 278 } |
283 | 279 |
284 void TestSuite::Shutdown() { | 280 void TestSuite::Shutdown() { |
285 } | 281 } |
OLD | NEW |