#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/image_decoder_base_test.h"
#include <stddef.h>
#include <memory>
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/hash/md5.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h"
namespace {
const int kFirstFrameIndex = …;
bool ShouldSkipFile(const base::FilePath& path,
blink::ImageDecoderBaseTest::FileSelection file_selection,
const int64_t threshold) { … }
void ReadFileToVector(const base::FilePath& path, Vector<char>* contents) { … }
base::MD5Digest ComputeMD5Sum(const blink::ImageFrame& frame_buffer) { … }
#if defined(CALCULATE_MD5_SUMS)
void SaveMD5Sum(const base::FilePath& path,
const blink::ImageFrame* frame_buffer) {
ASSERT_TRUE(frame_buffer);
base::MD5Digest digest = ComputeMD5Sum(*frame_buffer);
ASSERT_TRUE(base::WriteFile(path, base::byte_span_from_ref(digest)));
}
#endif
#if !defined(CALCULATE_MD5_SUMS)
void VerifyImage(blink::ImageDecoder& decoder,
const base::FilePath& path,
const base::FilePath& md5_sum_path,
size_t frame_index) { … }
#endif
}
namespace blink {
void ImageDecoderBaseTest::SetUp() { … }
base::FilePath ImageDecoderBaseTest::GetMD5SumPath(const base::FilePath& path) { … }
Vector<base::FilePath> ImageDecoderBaseTest::GetImageFiles() const { … }
bool ImageDecoderBaseTest::ShouldImageFail(const base::FilePath& path) const { … }
void ImageDecoderBaseTest::TestDecoding(
blink::ImageDecoderBaseTest::FileSelection file_selection,
const int64_t threshold) { … }
void ImageDecoderBaseTest::TestImageDecoder(const base::FilePath& image_path,
const base::FilePath& md5_sum_path,
int desired_frame_index) const { … }
}