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

Unified Diff: ui/gfx/codec/png_codec_unittest.cc

Issue 11028064: Resize images for hi-dpi based on a custom PNG chunk added by GRIT r78, and roll GRIT r78 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: back out ChromeBrowserMainPartsLinux::PreProfileInit change, add RoundToInt, move image loading to … Created 8 years, 2 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
Index: ui/gfx/codec/png_codec_unittest.cc
diff --git a/ui/gfx/codec/png_codec_unittest.cc b/ui/gfx/codec/png_codec_unittest.cc
index 83f535e6ae3e4d7a0180b516ca5cbda7516d34b1..43cddb695b4521b3832bce3db13e230feda97049 100644
--- a/ui/gfx/codec/png_codec_unittest.cc
+++ b/ui/gfx/codec/png_codec_unittest.cc
@@ -909,7 +909,7 @@ TEST(PNGCodec, DecodeCorrupted) {
std::vector<unsigned char> original;
MakeRGBImage(w, h, &original);
- // It should fail when given non-JPEG compressed data.
+ // It should fail when given non-PNG compressed data.
std::vector<unsigned char> output;
int outw, outh;
EXPECT_FALSE(PNGCodec::Decode(&original[0], original.size(),
@@ -1129,5 +1129,32 @@ TEST(PNGCodec, EncodeDecodeWithVaryingCompressionLevels) {
ASSERT_TRUE(original == decoded);
}
+TEST(PNGCodec, CustomScaleChunkDetection) {
+ const int w = 20, h = 20;
+ static const unsigned char png_scale_chunk[12] =
+ { 0, 0, 0, 0, 'c', 's', 'C', 'l', 0xc1, 0x30, 0x60, 0x4d };
+
+ // Compress some random data.
+ SkBitmap original;
+ std::vector<unsigned char> compressed;
+ MakeTestSkBitmap(w, h, &original);
+ PNGCodec::EncodeBGRASkBitmap(original, false, &compressed);
+
+ // Without the custom chunk, fell_back_to_1x should be false.
+ SkBitmap decompressed;
+ bool fell_back_to_1x = true;
+ EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(),
+ &decompressed, &fell_back_to_1x));
+ EXPECT_FALSE(fell_back_to_1x);
+
+ // With the custom chunk, fell_back_to_1x should be true.
+ compressed.insert(compressed.end() - 12,
+ png_scale_chunk, png_scale_chunk + sizeof(png_scale_chunk));
+ fell_back_to_1x = false;
+ EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(),
+ &decompressed, &fell_back_to_1x));
+ EXPECT_TRUE(fell_back_to_1x);
+}
+
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698