#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.h"
#include <limits>
#include <memory>
#include <string>
#include "base/test/metrics/histogram_tester.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image_metrics.h"
#include "third_party/blink/renderer/platform/image-decoders/image_animation.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
namespace blink {
static const size_t kLargeEnoughSize = …;
namespace {
std::unique_ptr<JPEGImageDecoder> CreateJPEGDecoder(size_t max_decoded_bytes) { … }
std::unique_ptr<ImageDecoder> CreateJPEGDecoder() { … }
void Downsample(size_t max_decoded_bytes,
const char* image_file_path,
const gfx::Size& expected_size) { … }
void ReadYUV(size_t max_decoded_bytes,
const char* image_file_path,
const gfx::Size& expected_y_size,
const gfx::Size& expected_uv_size,
const bool expect_decoding_failure = false) { … }
void TestJpegBppHistogram(const char* image_name,
const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { … }
}
TEST(JPEGImageDecoderTest, tooBig) { … }
TEST(JPEGImageDecoderTest, downsampleImageSizeMultipleOf8) { … }
TEST(JPEGImageDecoderTest, downsampleImageSizeNotMultipleOf8) { … }
TEST(JPEGImageDecoderTest, upsample) { … }
TEST(JPEGImageDecoderTest, yuv) { … }
TEST(JPEGImageDecoderTest, missingEoi) { … }
TEST(JPEGImageDecoderTest,
byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) { … }
TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) { … }
TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) { … }
TEST(JPEGImageDecoderTest, manyProgressiveScans) { … }
TEST(JPEGImageDecoderTest, exifWithInitialIfdLast) { … }
TEST(JPEGImageDecoderTest, SupportedSizesSquare) { … }
TEST(JPEGImageDecoderTest, SupportedSizesRectangle) { … }
TEST(JPEGImageDecoderTest,
SupportedSizesRectangleNotMultipleOfMCUIfMemoryBound) { … }
TEST(JPEGImageDecoderTest, SupportedSizesRectangleNotMultipleOfMCU) { … }
TEST(JPEGImageDecoderTest, SupportedSizesTruncatedIfMemoryBound) { … }
TEST(JPEGImageDecoderTest, SupportedScaleNumeratorBound) { … }
struct ColorSpaceTestParam { … };
void PrintTo(const ColorSpaceTestParam& param, std::ostream* os) { … }
class ColorSpaceTest : public ::testing::TestWithParam<ColorSpaceTestParam> { … };
TEST_P(ColorSpaceTest, YuvDecode) { … }
TEST_P(ColorSpaceTest, RgbDecode) { … }
const ColorSpaceTest::ParamType kColorSpaceTestParams[] = …;
INSTANTIATE_TEST_SUITE_P(…);
TEST(JPEGImageDecoderTest, PartialDataWithoutSize) { … }
TEST(JPEGImageDecoderTest, PartialRgbDecodeBlocksYuvDecoding) { … }
TEST(JPEGImageDecoderTest, Gainmap) { … }
TEST(JPEGImageDecoderTest, BppHistogramSmall) { … }
TEST(JPEGImageDecoderTest, BppHistogramSmall16x16) { … }
TEST(JPEGImageDecoderTest, BppHistogramSmall900000) { … }
TEST(JPEGImageDecoderTest, BppHistogramBig) { … }
TEST(JPEGImageDecoderTest, BppHistogramBig13000000) { … }
TEST(JPEGImageDecoderTest, BppHistogramHuge) { … }
TEST(JPEGImageDecoderTest, BppHistogramHuge13000002) { … }
TEST(JPEGImageDecoderTest, BppHistogramInvalid) { … }
TEST(JPEGImageDecoderTest, BppHistogramGrayscale) { … }
}