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

Unified Diff: content/shell/layout_test_controller.cc

Issue 10824351: [content shell] Add support for layout tests using content_shell on Android (first step). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/shell/layout_test_controller_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/layout_test_controller.cc
diff --git a/content/shell/layout_test_controller.cc b/content/shell/layout_test_controller.cc
index 2ec0d3a09645514d2725baa55bc73c19aa641c47..e96324677fd1d9593bc99328037b89c90412415b 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));
« no previous file with comments | « no previous file | content/shell/layout_test_controller_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698