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

Unified Diff: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 1358643002: Fix caching bug in JPEGImageDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
index 59ae3c81f2557edeef572f0a271593353c66cf7b..8f9eae71b94eae5cf7150bb97a685cb38b3b93f7 100644
--- a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
+++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
@@ -240,4 +240,35 @@ TEST(JPEGImageDecoderTest, byteByByte)
testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/red-at-12-oclock-with-color-profile.jpg", 1u, cAnimationNone);
}
+static unsigned createDecodingBaseline(SharedBuffer* data)
+{
+ OwnPtr<ImageDecoder> decoder = createDecoder();
+ decoder->setData(data, true);
+ ImageFrame* frame = decoder->frameBufferAtIndex(0);
+ return hashBitmap(frame->bitmap());
+}
+
+TEST(JPEGImageDecoderTest, mergeBuffer)
+{
+ const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg"; // 256x256
+ RefPtr<SharedBuffer> data = readFile(jpegFile);
+ ASSERT_TRUE(data);
+
+ const unsigned hash = createDecodingBaseline(data.get());
+
+ RefPtr<SharedBuffer> segmentedData = SharedBuffer::create();
+ segmentedData->append(data->data(), data->size());
Peter Kasting 2015/09/19 00:51:34 You should have comments in this test about what y
scroggo_chromium 2015/09/21 18:21:28 Done.
+
+ OwnPtr<ImageDecoder> decoder = createDecoder();
+ decoder->setData(segmentedData.get(), true);
+
+ ASSERT_TRUE(decoder->isSizeAvailable());
+
+ segmentedData->data();
+ ImageFrame* frame = decoder->frameBufferAtIndex(0);
+ ASSERT_FALSE(decoder->failed());
+ EXPECT_EQ(frame->status(), ImageFrame::FrameComplete);
+ EXPECT_EQ(hashBitmap(frame->bitmap()), hash);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698