diff options
author | wangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 17:20:04 +0000 |
---|---|---|
committer | wangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 17:20:04 +0000 |
commit | 7ed054dbdb861d45a06055483d18d739234efbb1 (patch) | |
tree | 9b384ffd0ebde8890350e1f24f01c491a1e37bab /base/test | |
parent | 3b2b45c0276a8238d1f83e01764d32c5f56cba73 (diff) | |
download | chromium_src-7ed054dbdb861d45a06055483d18d739234efbb1.zip chromium_src-7ed054dbdb861d45a06055483d18d739234efbb1.tar.gz chromium_src-7ed054dbdb861d45a06055483d18d739234efbb1.tar.bz2 |
Chromium support of running DumpRenderTree as an apk on Android
This is an upstream of chromium-android.
The WebKit part is https://bugs.webkit.org/show_bug.cgi?id=86862.
TBR=darin (for base/base.gyp)
BUG=none
TEST=build and run current native tests without error
Review URL: https://chromiumcodereview.appspot.com/10408091
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/test_stub_android.h | 14 | ||||
-rw-r--r-- | base/test/test_suite.cc | 17 | ||||
-rw-r--r-- | base/test/test_support_android.cc (renamed from base/test/test_stub_android.cc) | 55 | ||||
-rw-r--r-- | base/test/test_support_android.h | 20 |
4 files changed, 61 insertions, 45 deletions
diff --git a/base/test/test_stub_android.h b/base/test/test_stub_android.h deleted file mode 100644 index fa897d9..0000000 --- a/base/test/test_stub_android.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_TEST_TEST_STUB_ANDROID_H_ -#define BASE_TEST_TEST_STUB_ANDROID_H_ - -// Initialize the Android test environment. -void InitAndroidTestStub(); - -// Register path providers for tests. -void InitAndroidOSPathStub(); - -#endif // BASE_TEST_TEST_STUB_ANDROID_H_ diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 75e9ff5..83a2549 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -28,7 +28,7 @@ #endif #if defined(OS_ANDROID) -#include "base/test/test_stub_android.h" +#include "base/test/test_support_android.h" #endif #if defined(TOOLKIT_GTK) @@ -101,8 +101,13 @@ void TestSuite::PreInitialize(int argc, char** argv, #elif defined(TOOLKIT_GTK) gtk_init_check(&argc, &argv); #endif // defined(TOOLKIT_GTK) + + // On Android when building tests as apks, AtExitManager is created in + // testing/android/native_test_wrapper.cc before main() is called. +#if !defined(ANDROID_APK_TEST_TARGET) if (create_at_exit_manager) at_exit_manager_.reset(new base::AtExitManager); +#endif // Don't add additional code to this function. Instead add it to // Initialize(). See bug 6436. @@ -237,9 +242,8 @@ void TestSuite::Initialize() { #endif #if defined(OS_ANDROID) - InitAndroidTestStub(); -#endif - + InitAndroidTest(); +#else // Initialize logging. FilePath exe; PathService::Get(base::FILE_EXE, &exe); @@ -253,6 +257,7 @@ void TestSuite::Initialize() { // We want process and thread IDs because we may have multiple processes. // Note: temporarily enabled timestamps in an effort to catch bug 6361. logging::SetLogItems(true, true, true, true); +#endif // else defined(OS_ANDROID) CHECK(base::EnableInProcessStackDumping()); #if defined(OS_WIN) @@ -269,11 +274,7 @@ void TestSuite::Initialize() { logging::SetLogAssertHandler(UnitTestAssertHandler); } -#if !defined(OS_ANDROID) - // TODO(michaelbai): The icu can not be compiled in Android now, this should - // be enabled once icu is ready. http://b/5406077. icu_util::Initialize(); -#endif CatchMaybeTests(); ResetCommandLine(); diff --git a/base/test/test_stub_android.cc b/base/test/test_support_android.cc index aaf952e..5e5a8ae 100644 --- a/base/test/test_stub_android.cc +++ b/base/test/test_support_android.cc @@ -68,16 +68,18 @@ class Waitable { } base::WaitableEvent waitable_event_; + + DISALLOW_COPY_AND_ASSIGN(Waitable); }; // The MessagePumpForUI implementation for test purpose. class MessagePumpForUIStub : public base::MessagePumpForUI { - void Start(base::MessagePump::Delegate* delegate) { + virtual void Start(base::MessagePump::Delegate* delegate) OVERRIDE { NOTREACHED() << "The Start() method shouldn't be called in test, using" " Run() method should be used."; } - void Run(base::MessagePump::Delegate* delegate) { + virtual void Run(base::MessagePump::Delegate* delegate) OVERRIDE { // The following was based on message_pump_glib.cc, except we're using a // WaitableEvent since there are no native message loop to use. RunState state(delegate, g_state ? g_state->run_depth + 1 : 1); @@ -117,21 +119,26 @@ class MessagePumpForUIStub : public base::MessagePumpForUI { g_state = previous_state; } - void Quit() { + virtual void Quit() OVERRIDE { Waitable::GetInstance()->Quit(); } - void ScheduleWork() { + virtual void ScheduleWork() OVERRIDE { Waitable::GetInstance()->Signal(); } - void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) { + virtual void ScheduleDelayedWork( + const base::TimeTicks& delayed_work_time) OVERRIDE { Waitable::GetInstance()->Signal(); } }; +base::MessagePump* CreateMessagePumpForUIStub() { + return new MessagePumpForUIStub(); +}; + // Provides the test path for DIR_MODULE, DIR_CACHE and DIR_ANDROID_APP_DATA. -bool PathTestProviderAndroid(int key, FilePath* result) { +bool GetTestProviderPath(int key, FilePath* result) { switch (key) { case base::DIR_MODULE: { *result = FilePath(kAndroidTestTempDirectory); @@ -154,21 +161,16 @@ bool PathTestProviderAndroid(int key, FilePath* result) { } } -// The factory method to create a MessagePumpForUI. -base::MessagePump* CreateMessagePumpForUIStub() { - return new MessagePumpForUIStub(); +void InitPathProvider(int key) { + FilePath path; + // If failed to override the key, that means the way has not been registered. + if (GetTestProviderPath(key, &path) && !PathService::Override(key, path)) + PathService::RegisterProvider(&GetTestProviderPath, key, key + 1); } } // namespace -void InitAndroidOSPathStub() { - PathService::Override(base::DIR_MODULE, FilePath(kAndroidTestTempDirectory)); - PathService::Override(base::DIR_CACHE, FilePath(kAndroidTestTempDirectory)); - PathService::Override(base::DIR_ANDROID_APP_DATA, - FilePath(kAndroidTestTempDirectory)); -} - -void InitAndroidTestStub() { +void InitAndroidTestLogging() { logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, logging::DONT_LOCK_LOG_FILE, @@ -179,13 +181,20 @@ void InitAndroidTestStub() { false, // Thread ID false, // Timestamp false); // Tick count +} - PathService::RegisterProvider(&PathTestProviderAndroid, base::DIR_MODULE, - base::DIR_MODULE + 1); - PathService::RegisterProvider(&PathTestProviderAndroid, base::DIR_CACHE, - base::DIR_CACHE + 1); - PathService::RegisterProvider(&PathTestProviderAndroid, - base::DIR_ANDROID_APP_DATA, base::DIR_ANDROID_APP_DATA + 1); +void InitAndroidTestPaths() { + InitPathProvider(base::DIR_MODULE); + InitPathProvider(base::DIR_CACHE); + InitPathProvider(base::DIR_ANDROID_APP_DATA); +} +void InitAndroidTestMessageLoop() { MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub); } + +void InitAndroidTest() { + InitAndroidTestLogging(); + InitAndroidTestPaths(); + InitAndroidTestMessageLoop(); +} diff --git a/base/test/test_support_android.h b/base/test/test_support_android.h new file mode 100644 index 0000000..09b188c --- /dev/null +++ b/base/test/test_support_android.h @@ -0,0 +1,20 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TEST_TEST_SUPPORT_ANDROID_H_ +#define BASE_TEST_TEST_SUPPORT_ANDROID_H_ + +// Init logging for tests on Android. Logs will be output into Android's logcat. +void InitAndroidTestLogging(); + +// Init path providers for tests on Android. +void InitAndroidTestPaths(); + +// Init the message loop for tests on Android. +void InitAndroidTestMessageLoop(); + +// Do all of the initializations above. +void InitAndroidTest(); + +#endif // BASE_TEST_TEST_SUPPORT_ANDROID_H_ |