diff options
-rw-r--r-- | content/shell/layout_test_controller.cc | 17 | ||||
-rw-r--r-- | content/shell/layout_test_controller_host.cc | 35 | ||||
-rw-r--r-- | content/shell/shell_browser_main.cc | 12 |
3 files changed, 43 insertions, 21 deletions
diff --git a/content/shell/layout_test_controller.cc b/content/shell/layout_test_controller.cc index 2ec0d3a..e963246 100644 --- a/content/shell/layout_test_controller.cc +++ b/content/shell/layout_test_controller.cc @@ -5,6 +5,7 @@ #include "content/shell/layout_test_controller.h" #include "base/md5.h" +#include "base/memory/scoped_ptr.h" #include "base/stringprintf.h" #include "content/public/renderer/render_view.h" #include "content/shell/shell_messages.h" @@ -188,13 +189,29 @@ void LayoutTestController::OnCaptureImageDump( SkAutoLockPixels snapshot_lock(snapshot); base::MD5Digest digest; +#if defined(OS_ANDROID) + // On Android, pixel layout is RGBA, however, other Chrome platforms use BGRA. + const uint8_t* raw_pixels = + reinterpret_cast<const uint8_t*>(snapshot.getPixels()); + size_t snapshot_size = snapshot.getSize(); + scoped_array<uint8_t> reordered_pixels(new uint8_t[snapshot_size]); + for (size_t i = 0; i < snapshot_size; i += 4) { + reordered_pixels[i] = raw_pixels[i + 2]; + reordered_pixels[i + 1] = raw_pixels[i + 1]; + reordered_pixels[i + 2] = raw_pixels[i]; + reordered_pixels[i + 3] = raw_pixels[i + 3]; + } + base::MD5Sum(reordered_pixels.get(), snapshot_size, &digest); +#else base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); +#endif std::string actual_pixel_hash = base::MD5DigestToBase16(digest); if (actual_pixel_hash == expected_pixel_hash) { SkBitmap empty_image; Send(new ShellViewHostMsg_ImageDump( routing_id(), actual_pixel_hash, empty_image)); + return; } Send(new ShellViewHostMsg_ImageDump( routing_id(), actual_pixel_hash, snapshot)); diff --git a/content/shell/layout_test_controller_host.cc b/content/shell/layout_test_controller_host.cc index 92a912f..34636f3 100644 --- a/content/shell/layout_test_controller_host.cc +++ b/content/shell/layout_test_controller_host.cc @@ -118,11 +118,6 @@ void LayoutTestControllerHost::OnTextDump(const std::string& dump) { void LayoutTestControllerHost::OnImageDump( const std::string& actual_pixel_hash, const SkBitmap& image) { -#if !defined(OS_ANDROID) - // DumpRenderTree is not currently supported for Android. Also, on Android - // the required webkit_support methods are not defined, so this method just - // doesn't compile. - SkAutoLockPixels image_lock(image); printf("\nActualHash: %s\n", actual_pixel_hash.c_str()); @@ -141,14 +136,27 @@ void LayoutTestControllerHost::OnImageDump( bool discard_transparency = true; #endif - if (webkit_support::EncodeBGRAPNGWithChecksum( - reinterpret_cast<const unsigned char*>(image.getPixels()), - image.width(), - image.height(), - static_cast<int>(image.rowBytes()), - discard_transparency, - actual_pixel_hash, - &png)) { + bool success = false; +#if defined(OS_ANDROID) + success = webkit_support::EncodeRGBAPNGWithChecksum( + reinterpret_cast<const unsigned char*>(image.getPixels()), + image.width(), + image.height(), + static_cast<int>(image.rowBytes()), + discard_transparency, + actual_pixel_hash, + &png); +#else + success = webkit_support::EncodeBGRAPNGWithChecksum( + reinterpret_cast<const unsigned char*>(image.getPixels()), + image.width(), + image.height(), + static_cast<int>(image.rowBytes()), + discard_transparency, + actual_pixel_hash, + &png); +#endif + if (success) { printf("Content-Type: image/png\n"); printf("Content-Length: %u\n", static_cast<unsigned>(png.size())); fwrite(&png[0], 1, png.size(), stdout); @@ -156,7 +164,6 @@ void LayoutTestControllerHost::OnImageDump( } MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); -#endif } void LayoutTestControllerHost::OnNotifyDone() { diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc index 62f1fb1..8628d95 100644 --- a/content/shell/shell_browser_main.cc +++ b/content/shell/shell_browser_main.cc @@ -20,12 +20,6 @@ namespace { GURL GetURLForLayoutTest(const char* test_name, std::string* expected_pixel_hash) { -#if defined(OS_ANDROID) - // DumpRenderTree is not currently supported for Android using the content - // shell. - NOTIMPLEMENTED(); - return GURL::EmptyGURL(); -#else std::string path_or_url = test_name; std::string pixel_hash; std::string::size_type separator_position = path_or_url.find('\''); @@ -42,7 +36,6 @@ GURL GetURLForLayoutTest(const char* test_name, webkit_support::SetCurrentDirectoryForFileURL(test_url); } return test_url; -#endif } } // namespace @@ -71,6 +64,11 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters) { static_cast<content::ShellContentBrowserClient*>( content::GetContentClient()->browser())->browser_context(); +#if defined(OS_ANDROID) + puts("#READY"); + fflush(stdout); +#endif + while (fgets(test_string, sizeof(test_string), stdin)) { char *new_line_position = strchr(test_string, '\n'); if (new_line_position) |