Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: base/test/test_suite.cc

Issue 10408091: Chromium support of running DumpRenderTree as an apk on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and move out net dependency from testing/android Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/test_stub_android.cc ('k') | base/test/test_support_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 initialized_command_line_ = CommandLine::Init(argc, argv); 94 initialized_command_line_ = CommandLine::Init(argc, argv);
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
105 // On Android when building tests as apks, AtExitManager is created in
106 // testing/android/native_test_wrapper.cc before main() is called.
107 #if !defined(ANDROID_APK_TEST_TARGET)
104 if (create_at_exit_manager) 108 if (create_at_exit_manager)
105 at_exit_manager_.reset(new base::AtExitManager); 109 at_exit_manager_.reset(new base::AtExitManager);
110 #endif
106 111
107 // Don't add additional code to this function. Instead add it to 112 // Don't add additional code to this function. Instead add it to
108 // Initialize(). See bug 6436. 113 // Initialize(). See bug 6436.
109 } 114 }
110 115
111 116
112 // static 117 // static
113 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { 118 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) {
114 return strncmp(test.name(), "FLAKY_", 6) == 0; 119 return strncmp(test.name(), "FLAKY_", 6) == 0;
115 } 120 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 #endif // defined(OS_WIN) 235 #endif // defined(OS_WIN)
231 } 236 }
232 237
233 void TestSuite::Initialize() { 238 void TestSuite::Initialize() {
234 #if defined(OS_MACOSX) 239 #if defined(OS_MACOSX)
235 // Some of the app unit tests spin runloops. 240 // Some of the app unit tests spin runloops.
236 mock_cr_app::RegisterMockCrApp(); 241 mock_cr_app::RegisterMockCrApp();
237 #endif 242 #endif
238 243
239 #if defined(OS_ANDROID) 244 #if defined(OS_ANDROID)
240 InitAndroidTestStub(); 245 InitAndroidTest();
241 #endif 246 #else
242
243 // Initialize logging. 247 // Initialize logging.
244 FilePath exe; 248 FilePath exe;
245 PathService::Get(base::FILE_EXE, &exe); 249 PathService::Get(base::FILE_EXE, &exe);
246 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); 250 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
247 logging::InitLogging( 251 logging::InitLogging(
248 log_filename.value().c_str(), 252 log_filename.value().c_str(),
249 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, 253 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
250 logging::LOCK_LOG_FILE, 254 logging::LOCK_LOG_FILE,
251 logging::DELETE_OLD_LOG_FILE, 255 logging::DELETE_OLD_LOG_FILE,
252 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); 256 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
253 // We want process and thread IDs because we may have multiple processes. 257 // We want process and thread IDs because we may have multiple processes.
254 // Note: temporarily enabled timestamps in an effort to catch bug 6361. 258 // Note: temporarily enabled timestamps in an effort to catch bug 6361.
255 logging::SetLogItems(true, true, true, true); 259 logging::SetLogItems(true, true, true, true);
260 #endif // else defined(OS_ANDROID)
256 261
257 CHECK(base::EnableInProcessStackDumping()); 262 CHECK(base::EnableInProcessStackDumping());
258 #if defined(OS_WIN) 263 #if defined(OS_WIN)
259 // Make sure we run with high resolution timer to minimize differences 264 // Make sure we run with high resolution timer to minimize differences
260 // between production code and test code. 265 // between production code and test code.
261 base::Time::EnableHighResolutionTimer(true); 266 base::Time::EnableHighResolutionTimer(true);
262 #endif // defined(OS_WIN) 267 #endif // defined(OS_WIN)
263 268
264 // In some cases, we do not want to see standard error dialogs. 269 // In some cases, we do not want to see standard error dialogs.
265 if (!base::debug::BeingDebugged() && 270 if (!base::debug::BeingDebugged() &&
266 !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { 271 !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) {
267 SuppressErrorDialogs(); 272 SuppressErrorDialogs();
268 base::debug::SetSuppressDebugUI(true); 273 base::debug::SetSuppressDebugUI(true);
269 logging::SetLogAssertHandler(UnitTestAssertHandler); 274 logging::SetLogAssertHandler(UnitTestAssertHandler);
270 } 275 }
271 276
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(); 277 icu_util::Initialize();
276 #endif
277 278
278 CatchMaybeTests(); 279 CatchMaybeTests();
279 ResetCommandLine(); 280 ResetCommandLine();
280 281
281 TestTimeouts::Initialize(); 282 TestTimeouts::Initialize();
282 } 283 }
283 284
284 void TestSuite::Shutdown() { 285 void TestSuite::Shutdown() {
285 } 286 }
OLDNEW
« no previous file with comments | « base/test/test_stub_android.cc ('k') | base/test/test_support_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698