chromium/third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder_test.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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) {}

}  // anonymous namespace

// Tests failure on a too big image.
TEST(JPEGImageDecoderTest, tooBig) {}

// Tests that the JPEG decoder can downsample image whose width and height are
// multiples of 8, to ensure we compute the correct DecodedSize and pass correct
// parameters to libjpeg to output the image with the expected size.
TEST(JPEGImageDecoderTest, downsampleImageSizeMultipleOf8) {}

// Tests that JPEG decoder can downsample image whose width and height are not
// multiple of 8. Ensures that we round using the same algorithm as libjpeg.
TEST(JPEGImageDecoderTest, downsampleImageSizeNotMultipleOf8) {}

// Tests that upsampling is not allowed.
TEST(JPEGImageDecoderTest, upsample) {}

TEST(JPEGImageDecoderTest, yuv) {}

// Tests that a progressive image missing an EOI marker causes a YUV decoding
// failure but also results in displayable YUV data.
TEST(JPEGImageDecoderTest, missingEoi) {}

TEST(JPEGImageDecoderTest,
     byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) {}

TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) {}

TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {}

// This tests decoding a JPEG with many progressive scans.  Decoding should
// fail, but not hang (crbug.com/642462).
TEST(JPEGImageDecoderTest, manyProgressiveScans) {}

// Decode a JPEG with EXIF data that defines a density corrected size. The EXIF
// data has the initial IFD at the end of the data blob, and out-of-line data
// defined just after the header.
// The order of the EXIF data is:
//   <header> <out-of-line data> <Exif IFD> <0th IFD>
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> {};

// Tests YUV decoding path with different color encodings (and chroma
// subsamplings if applicable).
TEST_P(ColorSpaceTest, YuvDecode) {}

// Tests RGB decoding path with different color encodings (and chroma
// subsamplings if applicable).
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) {}

}  // namespace blink