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..bf14d353e469457c7d02ead8eed8116464e7855b 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,9 @@ bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path, |
| if (gen_bmp.width() == 0 || gen_bmp.height() == 0) |
| return true; |
| + std::string op_png_url = GetPNGDataUrl(gen_bmp); |
| + LOG(ERROR) << "Output Data URL = " << op_png_url.c_str(); |
|
danakj
2014/07/07 16:07:02
Let's output both pngs so it's easier to compare t
sohanjg
2014/07/08 07:31:08
Done.
|
| + |
| return comparator.Compare(gen_bmp, ref_bmp); |
| } |