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

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

Issue 2565323003: Move gif image decoder to SkCodec (Closed)
Patch Set: Code review comments Created 3 years, 8 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 ee469c82bdb6e1ebabc50bae3e7d53a20db3d57a..fc9f4123b2c6dd598f993e38ac1f3d71722c9d29 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
@@ -59,16 +59,11 @@ void TestRepetitionCount(const char* dir,
RefPtr<SharedBuffer> data = ReadFile(dir, file);
ASSERT_TRUE(data.Get());
decoder->SetData(data.Get(), true);
- EXPECT_EQ(kCAnimationLoopOnce,
- decoder->RepetitionCount()); // Default value before decode.
- for (size_t i = 0; i < decoder->FrameCount(); ++i) {
- ImageFrame* frame = decoder->FrameBufferAtIndex(i);
- EXPECT_EQ(ImageFrame::kFrameComplete, frame->GetStatus());
- }
+ // Decode a frame to verify the decoder had a chance to update its state
+ decoder->FrameBufferAtIndex(0);
scroggo_chromium 2017/04/24 20:25:07 Are you sure this is necessary?
cblume 2017/04/24 21:35:53 I guess it isn't, huh. RepetitionCount() will end
- EXPECT_EQ(expected_repetition_count,
- decoder->RepetitionCount()); // Expected value after decode.
+ EXPECT_EQ(expected_repetition_count, decoder->RepetitionCount());
}
} // anonymous namespace
@@ -79,7 +74,6 @@ TEST(GIFImageDecoderTest, decodeTwoFrames) {
RefPtr<SharedBuffer> data = ReadFile(kLayoutTestResourcesDir, "animated.gif");
ASSERT_TRUE(data.Get());
decoder->SetData(data.Get(), true);
- EXPECT_EQ(kCAnimationLoopOnce, decoder->RepetitionCount());
ImageFrame* frame = decoder->FrameBufferAtIndex(0);
uint32_t generation_id0 = frame->Bitmap().getGenerationID();
@@ -104,10 +98,6 @@ TEST(GIFImageDecoderTest, parseAndDecode) {
RefPtr<SharedBuffer> data = ReadFile(kLayoutTestResourcesDir, "animated.gif");
ASSERT_TRUE(data.Get());
decoder->SetData(data.Get(), true);
- EXPECT_EQ(kCAnimationLoopOnce, decoder->RepetitionCount());
-
- // This call will parse the entire file.
- EXPECT_EQ(2u, decoder->FrameCount());
ImageFrame* frame = decoder->FrameBufferAtIndex(0);
EXPECT_EQ(ImageFrame::kFrameComplete, frame->GetStatus());
@@ -308,24 +298,6 @@ TEST(GIFImageDecoderTest, badCode) {
EXPECT_TRUE(test_decoder->Failed());
}
-TEST(GIFImageDecoderTest, invalidDisposalMethod) {
- std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
-
- // The image has 2 frames, with disposal method 4 and 5, respectively.
- RefPtr<SharedBuffer> data =
- ReadFile(kDecodersTestingDir, "invalid-disposal-method.gif");
- ASSERT_TRUE(data.Get());
- decoder->SetData(data.Get(), true);
-
- EXPECT_EQ(2u, decoder->FrameCount());
- // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious.
- EXPECT_EQ(ImageFrame::kDisposeOverwritePrevious,
- decoder->FrameBufferAtIndex(0)->GetDisposalMethod());
- // Disposal method 5 is ignored.
- EXPECT_EQ(ImageFrame::kDisposeNotSpecified,
- decoder->FrameBufferAtIndex(1)->GetDisposalMethod());
-}
-
TEST(GIFImageDecoderTest, firstFrameHasGreaterSizeThanScreenSize) {
RefPtr<SharedBuffer> full_data = ReadFile(
kDecodersTestingDir, "first-frame-has-greater-size-than-screen-size.gif");
@@ -386,11 +358,11 @@ TEST(GIFImageDecoderTest, bitmapAlphaType) {
ImageFrame* premul_frame = premul_decoder->FrameBufferAtIndex(0);
EXPECT_TRUE(premul_frame &&
premul_frame->GetStatus() != ImageFrame::kFrameComplete);
- EXPECT_EQ(premul_frame->Bitmap().alphaType(), kPremul_SkAlphaType);
+ EXPECT_EQ(kPremul_SkAlphaType, premul_frame->Bitmap().alphaType());
scroggo_chromium 2017/04/24 20:25:07 Did this need to change? (Did git cl format change
cblume 2017/04/24 21:35:53 It didn't have to change. I can put it in a separa
ImageFrame* unpremul_frame = unpremul_decoder->FrameBufferAtIndex(0);
EXPECT_TRUE(unpremul_frame &&
unpremul_frame->GetStatus() != ImageFrame::kFrameComplete);
- EXPECT_EQ(unpremul_frame->Bitmap().alphaType(), kUnpremul_SkAlphaType);
+ EXPECT_EQ(kUnpremul_SkAlphaType, unpremul_frame->Bitmap().alphaType());
// Fully decoded frame => the frame alpha type is known (opaque).
premul_decoder->SetData(full_data.Get(), true);
@@ -400,11 +372,11 @@ TEST(GIFImageDecoderTest, bitmapAlphaType) {
premul_frame = premul_decoder->FrameBufferAtIndex(0);
EXPECT_TRUE(premul_frame &&
premul_frame->GetStatus() == ImageFrame::kFrameComplete);
- EXPECT_EQ(premul_frame->Bitmap().alphaType(), kOpaque_SkAlphaType);
+ EXPECT_EQ(kOpaque_SkAlphaType, premul_frame->Bitmap().alphaType());
unpremul_frame = unpremul_decoder->FrameBufferAtIndex(0);
EXPECT_TRUE(unpremul_frame &&
unpremul_frame->GetStatus() == ImageFrame::kFrameComplete);
- EXPECT_EQ(unpremul_frame->Bitmap().alphaType(), kOpaque_SkAlphaType);
+ EXPECT_EQ(kOpaque_SkAlphaType, unpremul_frame->Bitmap().alphaType());
}
namespace {

Powered by Google App Engine
This is Rietveld 408576698