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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 2618633004: Add support for Animated PNG (Closed)
Patch Set: Fix LayoutTest due to accept header change Created 3 years, 9 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: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
index 8c4e988b4ca6653476eb4df645c89a6ac8288843..d7ff80ed8abbd1d06688ce880514bd98bcf0a116 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
@@ -406,4 +406,34 @@ TEST(GIFImageDecoderTest, bitmapAlphaType) {
EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
}
+namespace {
+// Needed to exercise ImageDecoder::setMemoryAllocator, but still does the
+// default allocation.
+class Allocator final : public SkBitmap::Allocator {
+ bool allocPixelRef(SkBitmap* dst, SkColorTable* ctable) override {
+ return dst->tryAllocPixels(ctable);
+ }
+};
+}
+
+// Ensure that calling setMemoryAllocator does not short-circuit
+// initializeNewFrame.
+TEST(GIFImageDecoderTest, externalAllocator) {
+ auto data = readFile(layoutTestResourcesDir, "boston.gif");
+ ASSERT_TRUE(data.get());
+
+ auto decoder = createDecoder();
+ decoder->setData(data.get(), true);
+
+ Allocator allocator;
+ decoder->setMemoryAllocator(&allocator);
+ EXPECT_EQ(1u, decoder->frameCount());
+ ImageFrame* frame = decoder->frameBufferAtIndex(0);
+ decoder->setMemoryAllocator(nullptr);
+
+ ASSERT_TRUE(frame);
+ EXPECT_EQ(IntRect(IntPoint(), decoder->size()), frame->originalFrameRect());
+ EXPECT_FALSE(frame->hasAlpha());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698