chromium/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder_test.cc

// Copyright 2020 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/avif/avif_image_decoder.h"

#include <cmath>
#include <memory>
#include <ostream>
#include <utility>
#include <vector>

#include "base/barrier_closure.h"
#include "base/bit_cast.h"
#include "base/functional/bind.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/color_transform.h"

#define FIXME_SUPPORT_ICC_PROFILE_NO_TRANSFORM
#define FIXME_SUPPORT_ICC_PROFILE_TRANSFORM
#define FIXME_DISTINGUISH_LOSSY_OR_LOSSLESS

namespace blink {

namespace {

std::unique_ptr<ImageDecoder> CreateAVIFDecoderWithOptions(
    ImageDecoder::AlphaOption alpha_option,
    ImageDecoder::HighBitDepthDecodingOption high_bit_depth_option,
    ColorBehavior color_behavior,
    ImageDecoder::AnimationOption animation_option) {}

std::unique_ptr<ImageDecoder> CreateAVIFDecoder() {}

struct ExpectedColor {};

enum class ColorType {};

struct StaticColorCheckParam {};

std::ostream& operator<<(std::ostream& os, const StaticColorCheckParam& param) {}

StaticColorCheckParam kTestParams[] =;

enum class ErrorPhase {};

// If 'error_phase' is ErrorPhase::kParse, error is expected during parse
// (SetData() call); else error is expected during decode
// (DecodeFrameBufferAtIndex() call).
void TestInvalidStaticImage(const char* avif_file, ErrorPhase error_phase) {}

float HalfFloatToUnorm(uint16_t h) {}

void ReadYUV(const char* file_name,
             const gfx::Size& expected_y_size,
             const gfx::Size& expected_uv_size,
             SkColorType color_type,
             int bit_depth,
             gfx::Point3F* rgb_pixel = nullptr) {}

void TestYUVRed(const char* file_name,
                const gfx::Size& expected_uv_size,
                SkColorType color_type = kGray_8_SkColorType,
                int bit_depth = 8) {}

void DecodeTask(const Vector<char>* data, base::RepeatingClosure* done) {}

void InspectImage(
    const StaticColorCheckParam& param,
    ImageDecoder::HighBitDepthDecodingOption high_bit_depth_option) {}

void TestAvifBppHistogram(const char* image_name,
                          const char* histogram_name = nullptr,
                          base::HistogramBase::Sample sample = 0) {}

struct AVIFImageParam {};

constexpr AVIFImageParam kAnimatedTestParams[] =;

constexpr AVIFImageParam kStaticTestParams[] =;

AVIFValidImagesTest;

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

TEST_P(AVIFValidImagesTest, ByteByByteDecode) {}

TEST(AnimatedAVIFTests, HasMultipleSubImages) {}

TEST(StaticAVIFTests, DoesNotHaveMultipleSubImages) {}

TEST(StaticAVIFTests, HasTimingInformation) {}

TEST(AnimatedAVIFTests, HasTimingInformation) {}

TEST(StaticAVIFTests, NoCrashWhenCheckingForMultipleSubImages) {}

// TODO(ryoh): Add corrupted video tests.

TEST(StaticAVIFTests, invalidImages) {}

TEST(StaticAVIFTests, GetAdobeGainmapInfoAndData) {}

TEST(StaticAVIFTests, GetIsoGainmapInfoAndData) {}

TEST(StaticAVIFTests, GetIsoGainmapInfoAndDataHdrToSdr) {}

TEST(StaticAVIFTests, GetIsoGainmapColorSpaceSameICC) {}

void ExpectMatrixNear(const skcms_Matrix3x3& lhs,
                      const skcms_Matrix3x3& rhs,
                      float epsilon) {}

TEST(StaticAVIFTests, GetIsoGainmapColorSpaceDifferentICC) {}

TEST(StaticAVIFTests, GetIsoGainmapColorSpaceDifferentCICP) {}

TEST(StaticAVIFTests, GetGainmapInfoAndDataWithFeatureDisabled) {}

TEST(StaticAVIFTests, GetGainmapInfoAndDataWithTruncatedData) {}

TEST(StaticAVIFTests, YUV) {}

TEST(StaticAVIFTests, SizeAvailableBeforeAllDataReceived) {}

TEST(StaticAVIFTests, ProgressiveDecoding) {}

TEST(StaticAVIFTests, IncrementalDecoding) {}

// Reproduces crbug.com/1402841. Decodes a large AVIF image 104 times in
// parallel from base::ThreadPool. Should not cause temporary deadlock of
// base::ThreadPool.
TEST(StaticAVIFTests, ParallelDecoding) {}

TEST(StaticAVIFTests, AlphaHasNoIspeProperty) {}

TEST(StaticAVIFTests, UnsupportedTransferFunctionInColrProperty) {}

TEST(StaticAVIFTests, ClapPropertyZeroOrigin) {}

// Verifies that an invalid 'clap' (clean aperture) image property is handled by
// ignoring the 'clap' property and showing the full image.
TEST(StaticAVIFTests, InvalidClapPropertyHandling) {}

TEST(StaticAVIFTests, BppHistogramSmall) {}

TEST(StaticAVIFTests, BppHistogramSmall3x3) {}

TEST(StaticAVIFTests, BppHistogramSmall900000) {}

TEST(StaticAVIFTests, BppHistogramBig) {}

TEST(StaticAVIFTests, BppHistogramBig13000000) {}

TEST(StaticAVIFTests, BppHistogramHuge) {}

TEST(StaticAVIFTests, BppHistogramHuge13000002) {}

TEST(StaticAVIFTests, BppHistogramInvalid) {}

TEST(StaticAVIFTests, BppHistogram10bit) {}

TEST(StaticAVIFTests, BppHistogramMonochrome) {}

TEST(StaticAVIFTests, BppHistogramAlpha) {}

TEST(StaticAVIFTests, BppHistogramAnimated) {}

StaticAVIFColorTests;

INSTANTIATE_TEST_SUITE_P();

TEST_P(StaticAVIFColorTests, InspectImage) {}

TEST_P(StaticAVIFColorTests, InspectImageHalfFloat) {}

}  // namespace

}  // namespace blink