Chromium Code Reviews| Index: cc/test/pixel_test_utils.cc |
| diff --git a/cc/test/pixel_test_utils.cc b/cc/test/pixel_test_utils.cc |
| index 99970b864b70738d6f8e913147fa64349bb2302e..9fbc86a79a34787b548c46288a81adb0060c6ae5 100644 |
| --- a/cc/test/pixel_test_utils.cc |
| +++ b/cc/test/pixel_test_utils.cc |
| @@ -7,6 +7,7 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/base64.h" |
| #include "base/file_util.h" |
| #include "base/logging.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| @@ -28,6 +29,17 @@ bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path, |
| return false; |
| } |
| +std::string GetPNGDataUrl(const SkBitmap& bitmap) { |
| + std::vector<unsigned char> png_data; |
| + gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_data); |
| + std::string data_url; |
| + data_url.insert(data_url.end(), png_data.begin(), png_data.end()); |
| + base::Base64Encode(data_url, &data_url); |
| + data_url.insert(0, "data:image/png;base64,"); |
| + |
| + return data_url; |
| +} |
| + |
| bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) { |
| DCHECK(bitmap); |
| std::string png_data; |
| @@ -60,6 +72,12 @@ bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path, |
| if (gen_bmp.width() == 0 || gen_bmp.height() == 0) |
| return true; |
| + std::string gen_bmp_data_url = GetPNGDataUrl(gen_bmp); |
| + std::string ref_bmp_data_url = GetPNGDataUrl(ref_bmp); |
| + LOG(ERROR) << "Pixels do not match!"; |
|
vmpstr
2014/07/11 02:57:04
Is this meant to be printed only if comparator.Com
sohanjg
2014/07/11 05:15:21
Yeah, right! its better to log it based on Compare
|
| + LOG(ERROR) << "Actual: " << gen_bmp_data_url; |
| + LOG(ERROR) << "Expected: " << ref_bmp_data_url; |
| + |
| return comparator.Compare(gen_bmp, ref_bmp); |
| } |