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 /webkit | |
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 'webkit')
-rw-r--r-- | webkit/support/DEPS | 1 | ||||
-rw-r--r-- | webkit/support/platform_support_android.cc | 31 | ||||
-rw-r--r-- | webkit/support/webkit_support.cc | 13 |
3 files changed, 37 insertions, 8 deletions
diff --git a/webkit/support/DEPS b/webkit/support/DEPS index 29ea35e..c110041 100644 --- a/webkit/support/DEPS +++ b/webkit/support/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+media", + "+net", "+ui", "+third_party/libpng", "+third_party/zlib", diff --git a/webkit/support/platform_support_android.cc b/webkit/support/platform_support_android.cc index dd6c914..7298b81 100644 --- a/webkit/support/platform_support_android.cc +++ b/webkit/support/platform_support_android.cc @@ -4,34 +4,50 @@ #include "webkit/support/platform_support.h" +#include "base/android/jni_android.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" #include "base/string16.h" #include "base/string_piece.h" -#include "base/test/test_stub_android.h" +#include "base/test/test_support_android.h" #include "googleurl/src/gurl.h" #include "grit/webkit_resources.h" +#include "net/android/network_library.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/support/test_webkit_platform_support.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" +namespace { + +// The place where the Android layout test script will put the required tools +// and resources. Must keep consistent with DEVICE_DRT_DIR in +// WebKit/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py. +// TODO(wangxianzhu): Allow running DRT on non-rooted device by putting +// the tools and resources into the apk or under /data/local/tmp. +const char kDumpRenderTreeDir[] = "/data/drt"; + +} + namespace webkit_support { void BeforeInitialize(bool unit_test_mode) { - InitAndroidOSPathStub(); + InitAndroidTestPaths(); + // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from // loading and complaining the non-exsistent /etc/xml/catalog file. setenv("XML_CATALOG_FILES", "", 0); + + JNIEnv* env = base::android::AttachCurrentThread(); + net::android::RegisterNetworkLibrary(env); } void AfterInitialize(bool unit_test_mode) { if (unit_test_mode) return; // We don't have a resource pack when running the unit-tests. - FilePath data_path; - PathService::Get(base::DIR_EXE, &data_path); + FilePath data_path(kDumpRenderTreeDir); data_path = data_path.Append("DumpRenderTree.pak"); ResourceBundle::InitSharedInstanceWithPakFile(data_path); @@ -64,12 +80,11 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { base::StringPiece TestWebKitPlatformSupport::GetDataResource( int resource_id, ui::ScaleFactor scale_factor) { - FilePath resources_path; - PathService::Get(base::DIR_EXE, &resources_path); + FilePath resources_path(kDumpRenderTreeDir); resources_path = resources_path.Append("DumpRenderTree_resources"); switch (resource_id) { case IDR_BROKENIMAGE: { - static std::string broken_image_data; + CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); if (broken_image_data.empty()) { FilePath path = resources_path.Append("missingImage.gif"); bool success = file_util::ReadFileToString(path, &broken_image_data); @@ -79,7 +94,7 @@ base::StringPiece TestWebKitPlatformSupport::GetDataResource( return broken_image_data; } case IDR_TEXTAREA_RESIZER: { - static std::string resize_corner_data; + CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); if (resize_corner_data.empty()) { FilePath path = resources_path.Append("textAreaResizeCorner.png"); bool success = file_util::ReadFileToString(path, &resize_corner_data); diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index 282ac86..ff3fd40 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -71,6 +71,10 @@ #include "webkit/tools/test_shell/simple_file_system.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" +#if defined(OS_ANDROID) +#include "base/test/test_support_android.h" +#endif + using WebKit::WebCString; using WebKit::WebDevToolsAgentClient; using WebKit::WebFileSystem; @@ -104,6 +108,10 @@ void InitLogging() { } #endif +#if defined(OS_ANDROID) + // On Android we expect the log to appear in logcat. + InitAndroidTestLogging(); +#else FilePath log_filename; PathService::Get(base::DIR_EXE, &log_filename); log_filename = log_filename.AppendASCII("DumpRenderTree.log"); @@ -123,6 +131,7 @@ void InitLogging() { const bool kTimestamp = true; const bool kTickcount = true; logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount); +#endif // else defined(OS_ANDROID) } class TestEnvironment { @@ -272,11 +281,15 @@ void SetUpTestEnvironmentImpl(bool unit_test_mode) { // at same time. url_util::Initialize(); base::AtExitManager* at_exit_manager = NULL; + // In Android DumpRenderTree, AtExitManager is created in + // testing/android/native_test_wrapper.cc before main() is called. +#if !defined(OS_ANDROID) // Some initialization code may use a AtExitManager before initializing // TestEnvironment, so we create a AtExitManager early and pass its ownership // to TestEnvironment. if (!unit_test_mode) at_exit_manager = new base::AtExitManager; +#endif webkit_support::BeforeInitialize(unit_test_mode); test_environment = new TestEnvironment(unit_test_mode, at_exit_manager); webkit_support::AfterInitialize(unit_test_mode); |