Commit 9694c119 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Renamed CreateDecoder helper functions in Image decoder tests

All image decoder test have a helper function "CreateDecoder" which
conflicts in jumbo builds where the tests are merged. This patch renames
them "CreateBMPDecoder", "CreateJPEGDecoder" and so on.

Bug: 745732
Change-Id: I2cfd108c39ade76a09059d77778557ab44b82752
Reviewed-on: https://chromium-review.googlesource.com/576098Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#488407}
parent e1b867e6
...@@ -14,7 +14,7 @@ namespace blink { ...@@ -14,7 +14,7 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateBMPDecoder() {
return WTF::WrapUnique( return WTF::WrapUnique(
new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied, new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), ColorBehavior::TransformToTargetForTesting(),
...@@ -28,7 +28,7 @@ TEST(BMPImageDecoderTest, isSizeAvailable) { ...@@ -28,7 +28,7 @@ TEST(BMPImageDecoderTest, isSizeAvailable) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
EXPECT_TRUE(decoder->IsSizeAvailable()); EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_EQ(256, decoder->Size().Width()); EXPECT_EQ(256, decoder->Size().Width());
...@@ -40,7 +40,7 @@ TEST(BMPImageDecoderTest, parseAndDecode) { ...@@ -40,7 +40,7 @@ TEST(BMPImageDecoderTest, parseAndDecode) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -57,7 +57,7 @@ TEST(BMPImageDecoderTest, emptyImage) { ...@@ -57,7 +57,7 @@ TEST(BMPImageDecoderTest, emptyImage) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -70,7 +70,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) { ...@@ -70,7 +70,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
const char* bmp_file = const char* bmp_file =
"/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN "/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
// Test when not all data is received. // Test when not all data is received.
decoder->SetData(data.Get(), false); decoder->SetData(data.Get(), false);
EXPECT_FALSE(decoder->IsSizeAvailable()); EXPECT_FALSE(decoder->IsSizeAvailable());
...@@ -83,7 +83,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) { ...@@ -83,7 +83,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
// read) and a call to do a full decode. // read) and a call to do a full decode.
TEST(BMPImageDecoderTest, mergeBuffer) { TEST(BMPImageDecoderTest, mergeBuffer) {
const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp"; const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp";
TestMergeBuffer(&CreateDecoder, bmp_file); TestMergeBuffer(&CreateBMPDecoder, bmp_file);
} }
} // namespace blink } // namespace blink
...@@ -13,7 +13,7 @@ namespace blink { ...@@ -13,7 +13,7 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateICODecoder() {
return WTF::WrapUnique( return WTF::WrapUnique(
new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied, new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), ColorBehavior::TransformToTargetForTesting(),
...@@ -28,7 +28,7 @@ TEST(ICOImageDecoderTests, trunctedIco) { ...@@ -28,7 +28,7 @@ TEST(ICOImageDecoderTests, trunctedIco) {
RefPtr<SharedBuffer> truncated_data = RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(data.data(), data.size() / 2); SharedBuffer::Create(data.data(), data.size() / 2);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false); decoder->SetData(truncated_data.Get(), false);
decoder->FrameBufferAtIndex(0); decoder->FrameBufferAtIndex(0);
...@@ -54,7 +54,7 @@ TEST(ICOImageDecoderTests, errorInPngInIco) { ...@@ -54,7 +54,7 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
modified_data->Append(data.data() + kCrcOffset + kCrcSize, modified_data->Append(data.data() + kCrcOffset + kCrcSize,
data.size() - kCrcOffset - kCrcSize); data.size() - kCrcOffset - kCrcSize);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(modified_data.Get(), true); decoder->SetData(modified_data.Get(), true);
// ICOImageDecoder reports the frame count based on whether enough data has // ICOImageDecoder reports the frame count based on whether enough data has
...@@ -68,22 +68,23 @@ TEST(ICOImageDecoderTests, errorInPngInIco) { ...@@ -68,22 +68,23 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
} }
TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) { TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/png-in-ico.ico", 1u, "/LayoutTests/images/resources/png-in-ico.ico", 1u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/2entries.ico", 2u, "/LayoutTests/images/resources/2entries.ico", 2u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/greenbox-3frames.cur", 3u, "/LayoutTests/images/resources/greenbox-3frames.cur", 3u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode( TestByteByByteDecode(
&CreateDecoder, &CreateICODecoder,
"/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u, "/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, "/LayoutTests/images/resources/1bit.ico", TestByteByByteDecode(&CreateICODecoder,
1u, kAnimationNone); "/LayoutTests/images/resources/1bit.ico", 1u,
TestByteByByteDecode(&CreateDecoder, kAnimationNone);
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/bug653075.ico", 2u, "/LayoutTests/images/resources/bug653075.ico", 2u,
kAnimationNone); kAnimationNone);
} }
...@@ -98,7 +99,7 @@ TEST(ICOImageDecoderTests, NullData) { ...@@ -98,7 +99,7 @@ TEST(ICOImageDecoderTests, NullData) {
RefPtr<SharedBuffer> truncated_data = RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(ico_file_data->Data(), kSizeOfBadBlock); SharedBuffer::Create(ico_file_data->Data(), kSizeOfBadBlock);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false); decoder->SetData(truncated_data.Get(), false);
decoder->SetMemoryAllocator(nullptr); decoder->SetMemoryAllocator(nullptr);
......
...@@ -46,14 +46,14 @@ static const size_t kLargeEnoughSize = 1000 * 1000; ...@@ -46,14 +46,14 @@ static const size_t kLargeEnoughSize = 1000 * 1000;
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder(size_t max_decoded_bytes) { std::unique_ptr<ImageDecoder> CreateJPEGDecoder(size_t max_decoded_bytes) {
return WTF::WrapUnique(new JPEGImageDecoder( return WTF::WrapUnique(new JPEGImageDecoder(
ImageDecoder::kAlphaNotPremultiplied, ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes)); ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes));
} }
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateJPEGDecoder() {
return CreateDecoder(ImageDecoder::kNoDecodedImageByteLimit); return CreateJPEGDecoder(ImageDecoder::kNoDecodedImageByteLimit);
} }
} // anonymous namespace } // anonymous namespace
...@@ -65,7 +65,7 @@ void Downsample(size_t max_decoded_bytes, ...@@ -65,7 +65,7 @@ void Downsample(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path); RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data); ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(max_decoded_bytes); std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(max_decoded_bytes);
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -84,7 +84,7 @@ void ReadYUV(size_t max_decoded_bytes, ...@@ -84,7 +84,7 @@ void ReadYUV(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path); RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data); ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(max_decoded_bytes); std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(max_decoded_bytes);
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
// Setting a dummy ImagePlanes object signals to the decoder that we want to // Setting a dummy ImagePlanes object signals to the decoder that we want to
...@@ -134,7 +134,7 @@ void ReadYUV(size_t max_decoded_bytes, ...@@ -134,7 +134,7 @@ void ReadYUV(size_t max_decoded_bytes,
// Tests failure on a too big image. // Tests failure on a too big image.
TEST(JPEGImageDecoderTest, tooBig) { TEST(JPEGImageDecoderTest, tooBig) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(100); std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(100);
EXPECT_FALSE(decoder->SetSize(10000, 10000)); EXPECT_FALSE(decoder->SetSize(10000, 10000));
EXPECT_TRUE(decoder->Failed()); EXPECT_TRUE(decoder->Failed());
} }
...@@ -259,7 +259,7 @@ TEST(JPEGImageDecoderTest, yuv) { ...@@ -259,7 +259,7 @@ TEST(JPEGImageDecoderTest, yuv) {
RefPtr<SharedBuffer> data = ReadFile(jpeg_file); RefPtr<SharedBuffer> data = ReadFile(jpeg_file);
ASSERT_TRUE(data); ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(230 * 230 * 4); std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(230 * 230 * 4);
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
std::unique_ptr<ImagePlanes> image_planes = WTF::MakeUnique<ImagePlanes>(); std::unique_ptr<ImagePlanes> image_planes = WTF::MakeUnique<ImagePlanes>();
...@@ -270,21 +270,21 @@ TEST(JPEGImageDecoderTest, yuv) { ...@@ -270,21 +270,21 @@ TEST(JPEGImageDecoderTest, yuv) {
TEST(JPEGImageDecoderTest, TEST(JPEGImageDecoderTest,
byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) { byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"small-square-with-colorspin-profile.jpg", "small-square-with-colorspin-profile.jpg",
1u, kAnimationNone); 1u, kAnimationNone);
} }
TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) { TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/bug106024.jpg", 1u, "/LayoutTests/images/resources/bug106024.jpg", 1u,
kAnimationNone); kAnimationNone);
} }
TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) { TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
TestByteByByteDecode( TestByteByByteDecode(
&CreateDecoder, &CreateJPEGDecoder,
"/LayoutTests/images/resources/rgb-jpeg-with-adobe-marker-only.jpg", 1u, "/LayoutTests/images/resources/rgb-jpeg-with-adobe-marker-only.jpg", 1u,
kAnimationNone); kAnimationNone);
} }
...@@ -295,7 +295,7 @@ TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) { ...@@ -295,7 +295,7 @@ TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
// read) and a call to do a full decode. // read) and a call to do a full decode.
TEST(JPEGImageDecoderTest, mergeBuffer) { TEST(JPEGImageDecoderTest, mergeBuffer) {
const char* jpeg_file = "/LayoutTests/images/resources/lenna.jpg"; const char* jpeg_file = "/LayoutTests/images/resources/lenna.jpg";
TestMergeBuffer(&CreateDecoder, jpeg_file); TestMergeBuffer(&CreateJPEGDecoder, jpeg_file);
} }
// This tests decoding a JPEG with many progressive scans. Decoding should // This tests decoding a JPEG with many progressive scans. Decoding should
...@@ -305,7 +305,7 @@ TEST(JPEGImageDecoderTest, manyProgressiveScans) { ...@@ -305,7 +305,7 @@ TEST(JPEGImageDecoderTest, manyProgressiveScans) {
ReadFile(kDecodersTestingDir, "many-progressive-scans.jpg"); ReadFile(kDecodersTestingDir, "many-progressive-scans.jpg");
ASSERT_TRUE(test_data.Get()); ASSERT_TRUE(test_data.Get());
std::unique_ptr<ImageDecoder> test_decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> test_decoder = CreateJPEGDecoder();
test_decoder->SetData(test_data.Get(), true); test_decoder->SetData(test_data.Get(), true);
EXPECT_EQ(1u, test_decoder->FrameCount()); EXPECT_EQ(1u, test_decoder->FrameCount());
ASSERT_TRUE(test_decoder->FrameBufferAtIndex(0)); ASSERT_TRUE(test_decoder->FrameBufferAtIndex(0));
......
...@@ -31,19 +31,20 @@ namespace blink { ...@@ -31,19 +31,20 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder( std::unique_ptr<ImageDecoder> CreatePNGDecoder(
ImageDecoder::AlphaOption alpha_option) { ImageDecoder::AlphaOption alpha_option) {
return WTF::WrapUnique(new PNGImageDecoder( return WTF::WrapUnique(new PNGImageDecoder(
alpha_option, ColorBehavior::TransformToTargetForTesting(), alpha_option, ColorBehavior::TransformToTargetForTesting(),
ImageDecoder::kNoDecodedImageByteLimit)); ImageDecoder::kNoDecodedImageByteLimit));
} }
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreatePNGDecoder() {
return CreateDecoder(ImageDecoder::kAlphaNotPremultiplied); return CreatePNGDecoder(ImageDecoder::kAlphaNotPremultiplied);
} }
std::unique_ptr<ImageDecoder> CreateDecoderWithPngData(const char* png_file) { std::unique_ptr<ImageDecoder> CreatePNGDecoderWithPngData(
auto decoder = CreateDecoder(); const char* png_file) {
auto decoder = CreatePNGDecoder();
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
EXPECT_FALSE(data->IsEmpty()); EXPECT_FALSE(data->IsEmpty());
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
...@@ -51,7 +52,7 @@ std::unique_ptr<ImageDecoder> CreateDecoderWithPngData(const char* png_file) { ...@@ -51,7 +52,7 @@ std::unique_ptr<ImageDecoder> CreateDecoderWithPngData(const char* png_file) {
} }
void TestSize(const char* png_file, IntSize expected_size) { void TestSize(const char* png_file, IntSize expected_size) {
auto decoder = CreateDecoderWithPngData(png_file); auto decoder = CreatePNGDecoderWithPngData(png_file);
EXPECT_TRUE(decoder->IsSizeAvailable()); EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_EQ(expected_size, decoder->Size()); EXPECT_EQ(expected_size, decoder->Size());
} }
...@@ -61,7 +62,7 @@ void TestSize(const char* png_file, IntSize expected_size) { ...@@ -61,7 +62,7 @@ void TestSize(const char* png_file, IntSize expected_size) {
void TestSizeByteByByte(const char* png_file, void TestSizeByteByByte(const char* png_file,
size_t bytes_needed_to_decode_size, size_t bytes_needed_to_decode_size,
IntSize expected_size) { IntSize expected_size) {
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
ASSERT_FALSE(data->IsEmpty()); ASSERT_FALSE(data->IsEmpty());
ASSERT_LT(bytes_needed_to_decode_size, data->size()); ASSERT_LT(bytes_needed_to_decode_size, data->size());
...@@ -92,7 +93,7 @@ void WriteUint32(uint32_t val, png_byte* data) { ...@@ -92,7 +93,7 @@ void WriteUint32(uint32_t val, png_byte* data) {
} }
void TestRepetitionCount(const char* png_file, int expected_repetition_count) { void TestRepetitionCount(const char* png_file, int expected_repetition_count) {
auto decoder = CreateDecoderWithPngData(png_file); auto decoder = CreatePNGDecoderWithPngData(png_file);
// Decoding the frame count sets the number of repetitions as well. // Decoding the frame count sets the number of repetitions as well.
decoder->FrameCount(); decoder->FrameCount();
EXPECT_FALSE(decoder->Failed()); EXPECT_FALSE(decoder->Failed());
...@@ -147,7 +148,7 @@ void CompareFrameWithExpectation(const PublicFrameInfo& expected, ...@@ -147,7 +148,7 @@ void CompareFrameWithExpectation(const PublicFrameInfo& expected,
void TestMissingDataBreaksDecoding(const char* png_file, void TestMissingDataBreaksDecoding(const char* png_file,
size_t offset, size_t offset,
size_t length) { size_t length) {
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
ASSERT_FALSE(data->IsEmpty()); ASSERT_FALSE(data->IsEmpty());
...@@ -183,7 +184,7 @@ void TestInvalidFctlSize(const char* png_file, ...@@ -183,7 +184,7 @@ void TestInvalidFctlSize(const char* png_file,
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
ASSERT_FALSE(data->IsEmpty()); ASSERT_FALSE(data->IsEmpty());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
RefPtr<SharedBuffer> invalid_data = RefPtr<SharedBuffer> invalid_data =
SharedBuffer::Create(data->Data(), offset_fctl); SharedBuffer::Create(data->Data(), offset_fctl);
...@@ -228,7 +229,7 @@ void TestProgressiveDecodingContinuesAfterFullData( ...@@ -228,7 +229,7 @@ void TestProgressiveDecodingContinuesAfterFullData(
auto full_data = ReadFile(png_file); auto full_data = ReadFile(png_file);
ASSERT_FALSE(full_data->IsEmpty()); ASSERT_FALSE(full_data->IsEmpty());
auto decoder_upfront = CreateDecoder(); auto decoder_upfront = CreatePNGDecoder();
decoder_upfront->SetData(full_data.Get(), true); decoder_upfront->SetData(full_data.Get(), true);
EXPECT_GE(decoder_upfront->FrameCount(), 1u); EXPECT_GE(decoder_upfront->FrameCount(), 1u);
const ImageFrame* const frame_upfront = const ImageFrame* const frame_upfront =
...@@ -236,7 +237,7 @@ void TestProgressiveDecodingContinuesAfterFullData( ...@@ -236,7 +237,7 @@ void TestProgressiveDecodingContinuesAfterFullData(
ASSERT_EQ(ImageFrame::kFrameComplete, frame_upfront->GetStatus()); ASSERT_EQ(ImageFrame::kFrameComplete, frame_upfront->GetStatus());
const unsigned hash_upfront = HashBitmap(frame_upfront->Bitmap()); const unsigned hash_upfront = HashBitmap(frame_upfront->Bitmap());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
RefPtr<SharedBuffer> partial_data = RefPtr<SharedBuffer> partial_data =
SharedBuffer::Create(full_data->Data(), offset_mid_first_frame); SharedBuffer::Create(full_data->Data(), offset_mid_first_frame);
decoder->SetData(partial_data, false); decoder->SetData(partial_data, false);
...@@ -275,7 +276,7 @@ void TestFailureDuringDecode(const char* file, ...@@ -275,7 +276,7 @@ void TestFailureDuringDecode(const char* file,
data->Append(full_data->Data() + idat_offset + 16u, data->Append(full_data->Data() + idat_offset + 16u,
full_data->size() - idat_offset - 16u); full_data->size() - idat_offset - 16u);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
EXPECT_EQ(expected_frame_count, decoder->FrameCount()); EXPECT_EQ(expected_frame_count, decoder->FrameCount());
...@@ -322,7 +323,7 @@ TEST(AnimatedPNGTests, MetaDataTest) { ...@@ -322,7 +323,7 @@ TEST(AnimatedPNGTests, MetaDataTest) {
"png-animated-idat-part-of-animation.png"; "png-animated-idat-part-of-animation.png";
constexpr size_t kExpectedFrameCount = 4; constexpr size_t kExpectedFrameCount = 4;
auto decoder = CreateDecoderWithPngData(png_file); auto decoder = CreatePNGDecoderWithPngData(png_file);
ASSERT_EQ(kExpectedFrameCount, decoder->FrameCount()); ASSERT_EQ(kExpectedFrameCount, decoder->FrameCount());
for (size_t i = 0; i < kExpectedFrameCount; i++) { for (size_t i = 0; i < kExpectedFrameCount; i++) {
CompareFrameWithExpectation(g_png_animated_frame_info[i], decoder.get(), i); CompareFrameWithExpectation(g_png_animated_frame_info[i], decoder.get(), i);
...@@ -331,7 +332,7 @@ TEST(AnimatedPNGTests, MetaDataTest) { ...@@ -331,7 +332,7 @@ TEST(AnimatedPNGTests, MetaDataTest) {
TEST(AnimatedPNGTests, EmptyFrame) { TEST(AnimatedPNGTests, EmptyFrame) {
const char* png_file = "/LayoutTests/images/resources/empty-frame.png"; const char* png_file = "/LayoutTests/images/resources/empty-frame.png";
auto decoder = CreateDecoderWithPngData(png_file); auto decoder = CreatePNGDecoderWithPngData(png_file);
// Frame 0 is empty. Ensure that decoding frame 1 (which depends on frame 0) // Frame 0 is empty. Ensure that decoding frame 1 (which depends on frame 0)
// fails (rather than crashing). // fails (rather than crashing).
EXPECT_EQ(2u, decoder->FrameCount()); EXPECT_EQ(2u, decoder->FrameCount());
...@@ -366,7 +367,7 @@ TEST(AnimatedPNGTests, ByteByByteMetaData) { ...@@ -366,7 +367,7 @@ TEST(AnimatedPNGTests, ByteByByteMetaData) {
// the first frame, which is reported when its first framedata is seen. // the first frame, which is reported when its first framedata is seen.
size_t frame_offsets[kExpectedFrameCount] = {141, 249, 322, 430}; size_t frame_offsets[kExpectedFrameCount] = {141, 249, 322, 430};
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
ASSERT_FALSE(data->IsEmpty()); ASSERT_FALSE(data->IsEmpty());
size_t frames_parsed = 0; size_t frames_parsed = 0;
...@@ -392,27 +393,27 @@ TEST(AnimatedPNGTests, ByteByByteMetaData) { ...@@ -392,27 +393,27 @@ TEST(AnimatedPNGTests, ByteByByteMetaData) {
} }
TEST(AnimatedPNGTests, TestRandomFrameDecode) { TEST(AnimatedPNGTests, TestRandomFrameDecode) {
TestRandomFrameDecode(&CreateDecoder, TestRandomFrameDecode(&CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png", "png-animated-idat-part-of-animation.png",
2u); 2u);
} }
TEST(AnimatedPNGTests, TestDecodeAfterReallocation) { TEST(AnimatedPNGTests, TestDecodeAfterReallocation) {
TestDecodeAfterReallocatingData(&CreateDecoder, TestDecodeAfterReallocatingData(&CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png"); "png-animated-idat-part-of-animation.png");
} }
TEST(AnimatedPNGTests, ProgressiveDecode) { TEST(AnimatedPNGTests, ProgressiveDecode) {
TestProgressiveDecoding(&CreateDecoder, TestProgressiveDecoding(&CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png", "png-animated-idat-part-of-animation.png",
13u); 13u);
} }
TEST(AnimatedPNGTests, ParseAndDecodeByteByByte) { TEST(AnimatedPNGTests, ParseAndDecodeByteByByte) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png", "png-animated-idat-part-of-animation.png",
4u, 6u); 4u, 6u);
...@@ -452,7 +453,7 @@ TEST(AnimatedPNGTests, ActlErrors) { ...@@ -452,7 +453,7 @@ TEST(AnimatedPNGTests, ActlErrors) {
no_actl_data->Append(data->Data() + kOffsetActl + kAcTLSize, no_actl_data->Append(data->Data() + kOffsetActl + kAcTLSize,
data->size() - kOffsetActl - kAcTLSize); data->size() - kOffsetActl - kAcTLSize);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(no_actl_data, true); decoder->SetData(no_actl_data, true);
EXPECT_EQ(1u, decoder->FrameCount()); EXPECT_EQ(1u, decoder->FrameCount());
EXPECT_FALSE(decoder->Failed()); EXPECT_FALSE(decoder->Failed());
...@@ -480,7 +481,7 @@ TEST(AnimatedPNGTests, ActlErrors) { ...@@ -480,7 +481,7 @@ TEST(AnimatedPNGTests, ActlErrors) {
SharedBuffer::Create(data->Data(), offset); SharedBuffer::Create(data->Data(), offset);
extra_actl_data->Append(ac_tl, kAcTLSize); extra_actl_data->Append(ac_tl, kAcTLSize);
extra_actl_data->Append(data->Data() + offset, data->size() - offset); extra_actl_data->Append(data->Data() + offset, data->size() - offset);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(extra_actl_data, true); decoder->SetData(extra_actl_data, true);
EXPECT_EQ(rec.should_fail ? 0u : 1u, decoder->FrameCount()); EXPECT_EQ(rec.should_fail ? 0u : 1u, decoder->FrameCount());
EXPECT_EQ(rec.should_fail, decoder->Failed()); EXPECT_EQ(rec.should_fail, decoder->Failed());
...@@ -502,7 +503,7 @@ TEST(AnimatedPNGTests, ActlErrors) { ...@@ -502,7 +503,7 @@ TEST(AnimatedPNGTests, ActlErrors) {
extra_actl_data->Append(data2->Data() + kPostIDATOffset, extra_actl_data->Append(data2->Data() + kPostIDATOffset,
data2->size() - kPostIDATOffset); data2->size() - kPostIDATOffset);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(extra_actl_data, true); decoder->SetData(extra_actl_data, true);
EXPECT_EQ(1u, decoder->FrameCount()); EXPECT_EQ(1u, decoder->FrameCount());
EXPECT_FALSE(decoder->Failed()); EXPECT_FALSE(decoder->Failed());
...@@ -536,7 +537,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) { ...@@ -536,7 +537,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) {
{ {
// This broken APNG will be treated as a static png. // This broken APNG will be treated as a static png.
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(modified_data.Get(), true); decoder->SetData(modified_data.Get(), true);
ExpectStatic(decoder.get()); ExpectStatic(decoder.get());
} }
...@@ -550,7 +551,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) { ...@@ -550,7 +551,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) {
SharedBuffer::Create(modified_data->Data(), kOffsetActl); SharedBuffer::Create(modified_data->Data(), kOffsetActl);
modified_data2->Append(modified_data->Data() + kOffsetActl + kAcTLSize, modified_data2->Append(modified_data->Data() + kOffsetActl + kAcTLSize,
modified_data->size() - kOffsetActl - kAcTLSize); modified_data->size() - kOffsetActl - kAcTLSize);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(modified_data2.Get(), true); decoder->SetData(modified_data2.Get(), true);
ExpectStatic(decoder.get()); ExpectStatic(decoder.get());
...@@ -561,7 +562,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) { ...@@ -561,7 +562,7 @@ TEST(AnimatedPNGTests, fdatBeforeIdat) {
modified_data3->Append(data->Data() + kOffsetActl, kAcTLSize); modified_data3->Append(data->Data() + kOffsetActl, kAcTLSize);
modified_data3->Append(modified_data2->Data() + kInsertionOffset, modified_data3->Append(modified_data2->Data() + kInsertionOffset,
modified_data2->size() - kInsertionOffset); modified_data2->size() - kInsertionOffset);
decoder = CreateDecoder(); decoder = CreatePNGDecoder();
decoder->SetData(modified_data3.Get(), true); decoder->SetData(modified_data3.Get(), true);
ExpectStatic(decoder.get()); ExpectStatic(decoder.get());
} }
...@@ -589,7 +590,7 @@ TEST(AnimatedPNGTests, IdatSizeMismatch) { ...@@ -589,7 +590,7 @@ TEST(AnimatedPNGTests, IdatSizeMismatch) {
const size_t kAfterFctl = kFctlOffset + kFctlSize; const size_t kAfterFctl = kFctlOffset + kFctlSize;
modified_data->Append(data->Data() + kAfterFctl, data->size() - kAfterFctl); modified_data->Append(data->Data() + kAfterFctl, data->size() - kAfterFctl);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(modified_data.Get(), true); decoder->SetData(modified_data.Get(), true);
ExpectStatic(decoder.get()); ExpectStatic(decoder.get());
} }
...@@ -602,7 +603,7 @@ TEST(AnimatedPNGTests, VerifyFrameOutsideImageSizeFails) { ...@@ -602,7 +603,7 @@ TEST(AnimatedPNGTests, VerifyFrameOutsideImageSizeFails) {
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png"; "png-animated-idat-part-of-animation.png";
auto data = ReadFile(png_file); auto data = ReadFile(png_file);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
ASSERT_FALSE(data->IsEmpty()); ASSERT_FALSE(data->IsEmpty());
const size_t kOffsetThirdFctl = 241; const size_t kOffsetThirdFctl = 241;
...@@ -642,14 +643,14 @@ TEST(AnimatedPNGTests, ProgressiveDecodingContinuesAfterFullData) { ...@@ -642,14 +643,14 @@ TEST(AnimatedPNGTests, ProgressiveDecodingContinuesAfterFullData) {
TEST(AnimatedPNGTests, RandomDecodeAfterClearFrameBufferCache) { TEST(AnimatedPNGTests, RandomDecodeAfterClearFrameBufferCache) {
TestRandomDecodeAfterClearFrameBufferCache( TestRandomDecodeAfterClearFrameBufferCache(
&CreateDecoder, &CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png", "png-animated-idat-part-of-animation.png",
2u); 2u);
} }
TEST(AnimatedPNGTests, VerifyAlphaBlending) { TEST(AnimatedPNGTests, VerifyAlphaBlending) {
TestAlphaBlending(&CreateDecoder, TestAlphaBlending(&CreatePNGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png"); "png-animated-idat-part-of-animation.png");
} }
...@@ -673,7 +674,7 @@ TEST(AnimatedPNGTests, FailureMissingIendChunk) { ...@@ -673,7 +674,7 @@ TEST(AnimatedPNGTests, FailureMissingIendChunk) {
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png"); "png-animated-idat-part-of-animation.png");
ASSERT_FALSE(full_data->IsEmpty()); ASSERT_FALSE(full_data->IsEmpty());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
const size_t kOffsetTwoFrames = 249; const size_t kOffsetTwoFrames = 249;
const size_t kExpectedFramesAfter249Bytes = 2; const size_t kExpectedFramesAfter249Bytes = 2;
...@@ -721,7 +722,7 @@ TEST(AnimatedPNGTests, VerifyIENDBeforeIDATInvalidatesDecoder) { ...@@ -721,7 +722,7 @@ TEST(AnimatedPNGTests, VerifyIENDBeforeIDATInvalidatesDecoder) {
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-idat-part-of-animation.png"); "png-animated-idat-part-of-animation.png");
ASSERT_FALSE(full_data->IsEmpty()); ASSERT_FALSE(full_data->IsEmpty());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
const size_t kOffsetIDAT = 133; const size_t kOffsetIDAT = 133;
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
...@@ -758,7 +759,7 @@ TEST(AnimatedPNGTests, MixedDataChunks) { ...@@ -758,7 +759,7 @@ TEST(AnimatedPNGTests, MixedDataChunks) {
const size_t kIENDOffset = 422u; const size_t kIENDOffset = 422u;
data->Append(full_data->Data() + kIENDOffset, data->Append(full_data->Data() + kIENDOffset,
full_data->size() - kIENDOffset); full_data->size() - kIENDOffset);
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
decoder->FrameCount(); decoder->FrameCount();
EXPECT_TRUE(decoder->Failed()); EXPECT_TRUE(decoder->Failed());
...@@ -770,7 +771,7 @@ TEST(AnimatedPNGTests, MixedDataChunks) { ...@@ -770,7 +771,7 @@ TEST(AnimatedPNGTests, MixedDataChunks) {
data->Append(full_data->Data() + kIDATOffset, kPostIDAT - kIDATOffset); data->Append(full_data->Data() + kIDATOffset, kPostIDAT - kIDATOffset);
// Append the rest. // Append the rest.
data->Append(full_data->Data() + kPostIDAT, full_data->size() - kPostIDAT); data->Append(full_data->Data() + kPostIDAT, full_data->size() - kPostIDAT);
decoder = CreateDecoder(); decoder = CreatePNGDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
decoder->FrameCount(); decoder->FrameCount();
EXPECT_TRUE(decoder->Failed()); EXPECT_TRUE(decoder->Failed());
...@@ -784,7 +785,7 @@ TEST(AnimatedPNGTests, VerifyInvalidDisposalAndBlending) { ...@@ -784,7 +785,7 @@ TEST(AnimatedPNGTests, VerifyInvalidDisposalAndBlending) {
"png-animated-idat-part-of-animation.png"; "png-animated-idat-part-of-animation.png";
RefPtr<SharedBuffer> full_data = ReadFile(png_file); RefPtr<SharedBuffer> full_data = ReadFile(png_file);
ASSERT_FALSE(full_data->IsEmpty()); ASSERT_FALSE(full_data->IsEmpty());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
// The disposal byte in the frame control chunk is the 24th byte, alpha // The disposal byte in the frame control chunk is the 24th byte, alpha
// blending the 25th. |kOffsetDisposalOp| is 241 bytes to get to the third // blending the 25th. |kOffsetDisposalOp| is 241 bytes to get to the third
...@@ -823,7 +824,7 @@ TEST(AnimatedPNGTests, VerifySuccessfulFirstFrameDecodeAfterLaterFrame) { ...@@ -823,7 +824,7 @@ TEST(AnimatedPNGTests, VerifySuccessfulFirstFrameDecodeAfterLaterFrame) {
const char* png_file = const char* png_file =
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"png-animated-three-independent-frames.png"; "png-animated-three-independent-frames.png";
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
auto full_data = ReadFile(png_file); auto full_data = ReadFile(png_file);
ASSERT_FALSE(full_data->IsEmpty()); ASSERT_FALSE(full_data->IsEmpty());
...@@ -879,7 +880,7 @@ TEST(AnimatedPNGTests, DecodeFromIndependentFrame) { ...@@ -879,7 +880,7 @@ TEST(AnimatedPNGTests, DecodeFromIndependentFrame) {
original_data->size() - data->size()); original_data->size() - data->size());
ASSERT_EQ(original_data->size(), data->size()); ASSERT_EQ(original_data->size(), data->size());
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ASSERT_EQ(4u, decoder->FrameCount()); ASSERT_EQ(4u, decoder->FrameCount());
...@@ -898,7 +899,7 @@ TEST(AnimatedPNGTests, DecodeFromIndependentFrame) { ...@@ -898,7 +899,7 @@ TEST(AnimatedPNGTests, DecodeFromIndependentFrame) {
const auto hash = HashBitmap(frame->Bitmap()); const auto hash = HashBitmap(frame->Bitmap());
// Now decode starting from frame 1. // Now decode starting from frame 1.
decoder = CreateDecoder(); decoder = CreatePNGDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
frame = decoder->FrameBufferAtIndex(1); frame = decoder->FrameBufferAtIndex(1);
...@@ -936,7 +937,7 @@ TEST(AnimatedPNGTests, SubsetFromIHDR) { ...@@ -936,7 +937,7 @@ TEST(AnimatedPNGTests, SubsetFromIHDR) {
ASSERT_EQ(original_data->size(), data->size()); ASSERT_EQ(original_data->size(), data->size());
// This will test both byte by byte and using the full data, and compare. // This will test both byte by byte and using the full data, and compare.
TestByteByByteDecode(CreateDecoder, data.Get(), 1, kAnimationNone); TestByteByByteDecode(CreatePNGDecoder, data.Get(), 1, kAnimationNone);
} }
// Static PNG tests // Static PNG tests
...@@ -953,8 +954,8 @@ TEST(StaticPNGTests, sizeTest) { ...@@ -953,8 +954,8 @@ TEST(StaticPNGTests, sizeTest) {
TEST(StaticPNGTests, MetaDataTest) { TEST(StaticPNGTests, MetaDataTest) {
const size_t kExpectedFrameCount = 1; const size_t kExpectedFrameCount = 1;
const size_t kExpectedDuration = 0; const size_t kExpectedDuration = 0;
auto decoder = auto decoder = CreatePNGDecoderWithPngData(
CreateDecoderWithPngData("/LayoutTests/images/resources/png-simple.png"); "/LayoutTests/images/resources/png-simple.png");
EXPECT_EQ(kExpectedFrameCount, decoder->FrameCount()); EXPECT_EQ(kExpectedFrameCount, decoder->FrameCount());
EXPECT_EQ(kExpectedDuration, decoder->FrameDurationAtIndex(0)); EXPECT_EQ(kExpectedDuration, decoder->FrameDurationAtIndex(0));
} }
...@@ -965,7 +966,7 @@ TEST(StaticPNGTests, InvalidIHDRChunk) { ...@@ -965,7 +966,7 @@ TEST(StaticPNGTests, InvalidIHDRChunk) {
} }
TEST(StaticPNGTests, ProgressiveDecoding) { TEST(StaticPNGTests, ProgressiveDecoding) {
TestProgressiveDecoding(&CreateDecoder, TestProgressiveDecoding(&CreatePNGDecoder,
"/LayoutTests/images/resources/png-simple.png", 11u); "/LayoutTests/images/resources/png-simple.png", 11u);
} }
...@@ -1002,7 +1003,7 @@ TEST(PNGTests, VerifyFrameCompleteBehavior) { ...@@ -1002,7 +1003,7 @@ TEST(PNGTests, VerifyFrameCompleteBehavior) {
ASSERT_TRUE(full_data.Get()); ASSERT_TRUE(full_data.Get());
// Create with enough data for part of the first frame. // Create with enough data for part of the first frame.
auto decoder = CreateDecoder(); auto decoder = CreatePNGDecoder();
auto data = auto data =
SharedBuffer::Create(full_data->Data(), rec.offset_in_first_frame); SharedBuffer::Create(full_data->Data(), rec.offset_in_first_frame);
decoder->SetData(data.Get(), false); decoder->SetData(data.Get(), false);
...@@ -1048,8 +1049,8 @@ TEST(PNGTests, VerifyFrameCompleteBehavior) { ...@@ -1048,8 +1049,8 @@ TEST(PNGTests, VerifyFrameCompleteBehavior) {
} }
TEST(PNGTests, sizeMayOverflow) { TEST(PNGTests, sizeMayOverflow) {
auto decoder = auto decoder = CreatePNGDecoderWithPngData(
CreateDecoderWithPngData("/LayoutTests/images/resources/crbug702934.png"); "/LayoutTests/images/resources/crbug702934.png");
EXPECT_FALSE(decoder->IsSizeAvailable()); EXPECT_FALSE(decoder->IsSizeAvailable());
EXPECT_TRUE(decoder->Failed()); EXPECT_TRUE(decoder->Failed());
} }
......
...@@ -45,22 +45,22 @@ namespace blink { ...@@ -45,22 +45,22 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder( std::unique_ptr<ImageDecoder> CreateWEBPDecoder(
ImageDecoder::AlphaOption alpha_option) { ImageDecoder::AlphaOption alpha_option) {
return WTF::WrapUnique(new WEBPImageDecoder( return WTF::WrapUnique(new WEBPImageDecoder(
alpha_option, ColorBehavior::TransformToTargetForTesting(), alpha_option, ColorBehavior::TransformToTargetForTesting(),
ImageDecoder::kNoDecodedImageByteLimit)); ImageDecoder::kNoDecodedImageByteLimit));
} }
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateWEBPDecoder() {
return CreateDecoder(ImageDecoder::kAlphaNotPremultiplied); return CreateWEBPDecoder(ImageDecoder::kAlphaNotPremultiplied);
} }
// If 'parse_error_expected' is true, error is expected during parse // If 'parse_error_expected' is true, error is expected during parse
// (FrameCount() call); else error is expected during decode // (FrameCount() call); else error is expected during decode
// (FrameBufferAtIndex() call). // (FrameBufferAtIndex() call).
void TestInvalidImage(const char* webp_file, bool parse_error_expected) { void TestInvalidImage(const char* webp_file, bool parse_error_expected) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> data = ReadFile(webp_file); RefPtr<SharedBuffer> data = ReadFile(webp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
...@@ -82,7 +82,7 @@ void TestInvalidImage(const char* webp_file, bool parse_error_expected) { ...@@ -82,7 +82,7 @@ void TestInvalidImage(const char* webp_file, bool parse_error_expected) {
} // anonymous namespace } // anonymous namespace
TEST(AnimatedWebPTests, uniqueGenerationIDs) { TEST(AnimatedWebPTests, uniqueGenerationIDs) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
ReadFile("/LayoutTests/images/resources/webp-animated.webp"); ReadFile("/LayoutTests/images/resources/webp-animated.webp");
...@@ -98,7 +98,7 @@ TEST(AnimatedWebPTests, uniqueGenerationIDs) { ...@@ -98,7 +98,7 @@ TEST(AnimatedWebPTests, uniqueGenerationIDs) {
} }
TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) { TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount()); EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount());
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
...@@ -145,7 +145,7 @@ TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) { ...@@ -145,7 +145,7 @@ TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) {
TEST(AnimatedWebPTests, TEST(AnimatedWebPTests,
verifyAnimationParametersOpaqueFramesTransparentBackground) { verifyAnimationParametersOpaqueFramesTransparentBackground) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount()); EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount());
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
...@@ -193,7 +193,7 @@ TEST(AnimatedWebPTests, ...@@ -193,7 +193,7 @@ TEST(AnimatedWebPTests,
} }
TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) { TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount()); EXPECT_EQ(kAnimationLoopOnce, decoder->RepetitionCount());
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
...@@ -241,11 +241,11 @@ TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) { ...@@ -241,11 +241,11 @@ TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) {
} }
TEST(AnimatedWebPTests, parseAndDecodeByteByByte) { TEST(AnimatedWebPTests, parseAndDecodeByteByByte) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated.webp", 3u, "/LayoutTests/images/resources/webp-animated.webp", 3u,
kAnimationLoopInfinite); kAnimationLoopInfinite);
TestByteByByteDecode( TestByteByByteDecode(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 13u, 32000); "/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 13u, 32000);
} }
...@@ -259,7 +259,7 @@ TEST(AnimatedWebPTests, invalidImages) { ...@@ -259,7 +259,7 @@ TEST(AnimatedWebPTests, invalidImages) {
} }
TEST(AnimatedWebPTests, truncatedLastFrame) { TEST(AnimatedWebPTests, truncatedLastFrame) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
ReadFile("/LayoutTests/images/resources/invalid-animated-webp2.webp"); ReadFile("/LayoutTests/images/resources/invalid-animated-webp2.webp");
...@@ -282,7 +282,7 @@ TEST(AnimatedWebPTests, truncatedLastFrame) { ...@@ -282,7 +282,7 @@ TEST(AnimatedWebPTests, truncatedLastFrame) {
} }
TEST(AnimatedWebPTests, truncatedInBetweenFrame) { TEST(AnimatedWebPTests, truncatedInBetweenFrame) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
const Vector<char> full_data = const Vector<char> full_data =
ReadFile("/LayoutTests/images/resources/invalid-animated-webp4.webp") ReadFile("/LayoutTests/images/resources/invalid-animated-webp4.webp")
...@@ -303,7 +303,7 @@ TEST(AnimatedWebPTests, truncatedInBetweenFrame) { ...@@ -303,7 +303,7 @@ TEST(AnimatedWebPTests, truncatedInBetweenFrame) {
// Tests for a crash that used to happen for a specific file with specific // Tests for a crash that used to happen for a specific file with specific
// sequence of method calls. // sequence of method calls.
TEST(AnimatedWebPTests, reproCrash) { TEST(AnimatedWebPTests, reproCrash) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> full_data_buffer = RefPtr<SharedBuffer> full_data_buffer =
ReadFile("/LayoutTests/images/resources/invalid_vp8_vp8x.webp"); ReadFile("/LayoutTests/images/resources/invalid_vp8_vp8x.webp");
...@@ -333,12 +333,12 @@ TEST(AnimatedWebPTests, reproCrash) { ...@@ -333,12 +333,12 @@ TEST(AnimatedWebPTests, reproCrash) {
} }
TEST(AnimatedWebPTests, progressiveDecode) { TEST(AnimatedWebPTests, progressiveDecode) {
TestProgressiveDecoding(&CreateDecoder, TestProgressiveDecoding(&CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated.webp"); "/LayoutTests/images/resources/webp-animated.webp");
} }
TEST(AnimatedWebPTests, frameIsCompleteAndDuration) { TEST(AnimatedWebPTests, frameIsCompleteAndDuration) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> data_buffer = RefPtr<SharedBuffer> data_buffer =
ReadFile("/LayoutTests/images/resources/webp-animated.webp"); ReadFile("/LayoutTests/images/resources/webp-animated.webp");
...@@ -369,32 +369,34 @@ TEST(AnimatedWebPTests, frameIsCompleteAndDuration) { ...@@ -369,32 +369,34 @@ TEST(AnimatedWebPTests, frameIsCompleteAndDuration) {
TEST(AnimatedWebPTests, updateRequiredPreviousFrameAfterFirstDecode) { TEST(AnimatedWebPTests, updateRequiredPreviousFrameAfterFirstDecode) {
TestUpdateRequiredPreviousFrameAfterFirstDecode( TestUpdateRequiredPreviousFrameAfterFirstDecode(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated.webp"); &CreateWEBPDecoder, "/LayoutTests/images/resources/webp-animated.webp");
} }
TEST(AnimatedWebPTests, randomFrameDecode) { TEST(AnimatedWebPTests, randomFrameDecode) {
TestRandomFrameDecode(&CreateDecoder, TestRandomFrameDecode(&CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated.webp"); "/LayoutTests/images/resources/webp-animated.webp");
TestRandomFrameDecode( TestRandomFrameDecode(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-opaque.webp"); "/LayoutTests/images/resources/webp-animated-opaque.webp");
TestRandomFrameDecode( TestRandomFrameDecode(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated-large.webp"); &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-large.webp");
TestRandomFrameDecode( TestRandomFrameDecode(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-icc-xmp.webp"); "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
} }
TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) { TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) {
TestRandomDecodeAfterClearFrameBufferCache( TestRandomDecodeAfterClearFrameBufferCache(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated.webp"); &CreateWEBPDecoder, "/LayoutTests/images/resources/webp-animated.webp");
TestRandomDecodeAfterClearFrameBufferCache( TestRandomDecodeAfterClearFrameBufferCache(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-opaque.webp"); "/LayoutTests/images/resources/webp-animated-opaque.webp");
TestRandomDecodeAfterClearFrameBufferCache( TestRandomDecodeAfterClearFrameBufferCache(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated-large.webp"); &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-large.webp");
TestRandomDecodeAfterClearFrameBufferCache( TestRandomDecodeAfterClearFrameBufferCache(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-icc-xmp.webp"); "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
} }
...@@ -403,47 +405,48 @@ TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) { ...@@ -403,47 +405,48 @@ TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) {
TEST(AnimatedWebPTests, TEST(AnimatedWebPTests,
DISABLED_resumePartialDecodeAfterClearFrameBufferCache) { DISABLED_resumePartialDecodeAfterClearFrameBufferCache) {
TestResumePartialDecodeAfterClearFrameBufferCache( TestResumePartialDecodeAfterClearFrameBufferCache(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated-large.webp"); &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-large.webp");
} }
TEST(AnimatedWebPTests, decodeAfterReallocatingData) { TEST(AnimatedWebPTests, decodeAfterReallocatingData) {
TestDecodeAfterReallocatingData( TestDecodeAfterReallocatingData(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated.webp"); &CreateWEBPDecoder, "/LayoutTests/images/resources/webp-animated.webp");
TestDecodeAfterReallocatingData( TestDecodeAfterReallocatingData(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-icc-xmp.webp"); "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
} }
TEST(AnimatedWebPTests, alphaBlending) { TEST(AnimatedWebPTests, alphaBlending) {
TestAlphaBlending(&CreateDecoder, TestAlphaBlending(&CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated.webp"); "/LayoutTests/images/resources/webp-animated.webp");
TestAlphaBlending( TestAlphaBlending(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-semitransparent1.webp"); "/LayoutTests/images/resources/webp-animated-semitransparent1.webp");
TestAlphaBlending( TestAlphaBlending(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-semitransparent2.webp"); "/LayoutTests/images/resources/webp-animated-semitransparent2.webp");
TestAlphaBlending( TestAlphaBlending(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-semitransparent3.webp"); "/LayoutTests/images/resources/webp-animated-semitransparent3.webp");
TestAlphaBlending( TestAlphaBlending(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-semitransparent4.webp"); "/LayoutTests/images/resources/webp-animated-semitransparent4.webp");
} }
TEST(AnimatedWebPTests, isSizeAvailable) { TEST(AnimatedWebPTests, isSizeAvailable) {
TestByteByByteSizeAvailable( TestByteByByteSizeAvailable(
&CreateDecoder, "/LayoutTests/images/resources/webp-animated.webp", 142u, &CreateWEBPDecoder, "/LayoutTests/images/resources/webp-animated.webp",
false, kAnimationLoopInfinite); 142u, false, kAnimationLoopInfinite);
// FIXME: Add color profile support for animated webp images. // FIXME: Add color profile support for animated webp images.
TestByteByByteSizeAvailable( TestByteByByteSizeAvailable(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 1404u, false, "/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 1404u, false,
32000); 32000);
} }
TEST(AnimatedWEBPTests, clearCacheExceptFrameWithAncestors) { TEST(AnimatedWEBPTests, clearCacheExceptFrameWithAncestors) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> full_data = RefPtr<SharedBuffer> full_data =
ReadFile("/LayoutTests/images/resources/webp-animated.webp"); ReadFile("/LayoutTests/images/resources/webp-animated.webp");
...@@ -528,23 +531,23 @@ TEST(StaticWebPTests, truncatedImage) { ...@@ -528,23 +531,23 @@ TEST(StaticWebPTests, truncatedImage) {
// Regression test for a bug where some valid images were failing to decode // Regression test for a bug where some valid images were failing to decode
// incrementally. // incrementally.
TEST(StaticWebPTests, incrementalDecode) { TEST(StaticWebPTests, incrementalDecode) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateWEBPDecoder,
"/LayoutTests/images/resources/crbug.364830.webp", 1u, "/LayoutTests/images/resources/crbug.364830.webp", 1u,
kAnimationNone); kAnimationNone);
} }
TEST(StaticWebPTests, isSizeAvailable) { TEST(StaticWebPTests, isSizeAvailable) {
TestByteByByteSizeAvailable( TestByteByByteSizeAvailable(
&CreateDecoder, &CreateWEBPDecoder,
"/LayoutTests/images/resources/webp-color-profile-lossy.webp", 520u, true, "/LayoutTests/images/resources/webp-color-profile-lossy.webp", 520u, true,
kAnimationNone); kAnimationNone);
TestByteByByteSizeAvailable(&CreateDecoder, TestByteByByteSizeAvailable(&CreateWEBPDecoder,
"/LayoutTests/images/resources/test.webp", 30u, "/LayoutTests/images/resources/test.webp", 30u,
false, kAnimationNone); false, kAnimationNone);
} }
TEST(StaticWebPTests, notAnimated) { TEST(StaticWebPTests, notAnimated) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateWEBPDecoder();
RefPtr<SharedBuffer> data = RefPtr<SharedBuffer> data =
ReadFile("/LayoutTests/images/resources/webp-color-profile-lossy.webp"); ReadFile("/LayoutTests/images/resources/webp-color-profile-lossy.webp");
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment