#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h"
#include <memory>
#include "build/build_config.h"
#include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/image-decoders/image_frame.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class TestImageDecoder : public ImageDecoder { … };
TEST(ImageDecoderTest, sizeCalculationMayOverflow) { … }
TEST(ImageDecoderTest, requiredPreviousFrameIndex) { … }
TEST(ImageDecoderTest, requiredPreviousFrameIndexDisposeOverwriteBgcolor) { … }
TEST(ImageDecoderTest, requiredPreviousFrameIndexForFrame1) { … }
TEST(ImageDecoderTest, requiredPreviousFrameIndexBlendAtopBgcolor) { … }
TEST(ImageDecoderTest, requiredPreviousFrameIndexKnownOpaque) { … }
TEST(ImageDecoderTest, clearCacheExceptFrameDoNothing) { … }
TEST(ImageDecoderTest, clearCacheExceptFrameAll) { … }
TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame) { … }
#if BUILDFLAG(IS_FUCHSIA)
TEST(ImageDecoderTest, decodedSizeLimitBoundary) {
constexpr unsigned kWidth = 100;
constexpr unsigned kHeight = 200;
constexpr unsigned kBitDepth = 4;
std::unique_ptr<TestImageDecoder> decoder(std::make_unique<TestImageDecoder>(
ImageDecoder::kDefaultBitDepth, (kWidth * kHeight * kBitDepth)));
EXPECT_TRUE(decoder->SetSize(1, 1));
EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_FALSE(decoder->Failed());
EXPECT_TRUE(decoder->SetSize(kWidth, kHeight));
EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_FALSE(decoder->Failed());
EXPECT_TRUE(decoder->SetSize(kWidth + 1, kHeight));
EXPECT_FALSE(decoder->IsSizeAvailable());
EXPECT_TRUE(decoder->Failed());
}
TEST(ImageDecoderTest, decodedSizeUnlimited) {
constexpr unsigned kWidth = 10000;
constexpr unsigned kHeight = 10000;
std::unique_ptr<TestImageDecoder> decoder(std::make_unique<TestImageDecoder>(
ImageDecoder::kDefaultBitDepth, ImageDecoder::kNoDecodedImageByteLimit));
EXPECT_TRUE(decoder->SetSize(kWidth, kHeight));
EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_FALSE(decoder->Failed());
}
#else
TEST(ImageDecoderTest, decodedSizeLimitIsIgnored) { … }
#endif
#if BUILDFLAG(ENABLE_AV1_DECODER)
TEST(ImageDecoderTest, hasSufficientDataToSniffMimeTypeAvif) { … }
#endif
}