Commit 9694c119 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Renamed CreateDecoder helper functions in Image decoder tests

All image decoder test have a helper function "CreateDecoder" which
conflicts in jumbo builds where the tests are merged. This patch renames
them "CreateBMPDecoder", "CreateJPEGDecoder" and so on.

Bug: 745732
Change-Id: I2cfd108c39ade76a09059d77778557ab44b82752
Reviewed-on: https://chromium-review.googlesource.com/576098Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#488407}
parent e1b867e6
......@@ -14,7 +14,7 @@ namespace blink {
namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() {
std::unique_ptr<ImageDecoder> CreateBMPDecoder() {
return WTF::WrapUnique(
new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(),
......@@ -28,7 +28,7 @@ TEST(BMPImageDecoderTest, isSizeAvailable) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true);
EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_EQ(256, decoder->Size().Width());
......@@ -40,7 +40,7 @@ TEST(BMPImageDecoderTest, parseAndDecode) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0);
......@@ -57,7 +57,7 @@ TEST(BMPImageDecoderTest, emptyImage) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0);
......@@ -70,7 +70,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
const char* bmp_file =
"/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN
RefPtr<SharedBuffer> data = ReadFile(bmp_file);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
// Test when not all data is received.
decoder->SetData(data.Get(), false);
EXPECT_FALSE(decoder->IsSizeAvailable());
......@@ -83,7 +83,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
// read) and a call to do a full decode.
TEST(BMPImageDecoderTest, mergeBuffer) {
const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp";
TestMergeBuffer(&CreateDecoder, bmp_file);
TestMergeBuffer(&CreateBMPDecoder, bmp_file);
}
} // namespace blink
......@@ -13,7 +13,7 @@ namespace blink {
namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() {
std::unique_ptr<ImageDecoder> CreateICODecoder() {
return WTF::WrapUnique(
new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(),
......@@ -28,7 +28,7 @@ TEST(ICOImageDecoderTests, trunctedIco) {
RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(data.data(), data.size() / 2);
auto decoder = CreateDecoder();
auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false);
decoder->FrameBufferAtIndex(0);
......@@ -54,7 +54,7 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
modified_data->Append(data.data() + kCrcOffset + kCrcSize,
data.size() - kCrcOffset - kCrcSize);
auto decoder = CreateDecoder();
auto decoder = CreateICODecoder();
decoder->SetData(modified_data.Get(), true);
// ICOImageDecoder reports the frame count based on whether enough data has
......@@ -68,22 +68,23 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
}
TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) {
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/png-in-ico.ico", 1u,
kAnimationNone);
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/2entries.ico", 2u,
kAnimationNone);
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/greenbox-3frames.cur", 3u,
kAnimationNone);
TestByteByByteDecode(
&CreateDecoder,
&CreateICODecoder,
"/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u,
kAnimationNone);
TestByteByByteDecode(&CreateDecoder, "/LayoutTests/images/resources/1bit.ico",
1u, kAnimationNone);
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/1bit.ico", 1u,
kAnimationNone);
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/bug653075.ico", 2u,
kAnimationNone);
}
......@@ -98,7 +99,7 @@ TEST(ICOImageDecoderTests, NullData) {
RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(ico_file_data->Data(), kSizeOfBadBlock);
auto decoder = CreateDecoder();
auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false);
decoder->SetMemoryAllocator(nullptr);
......
......@@ -46,14 +46,14 @@ static const size_t kLargeEnoughSize = 1000 * 1000;
namespace {
std::unique_ptr<ImageDecoder> CreateDecoder(size_t max_decoded_bytes) {
std::unique_ptr<ImageDecoder> CreateJPEGDecoder(size_t max_decoded_bytes) {
return WTF::WrapUnique(new JPEGImageDecoder(
ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes));
}
std::unique_ptr<ImageDecoder> CreateDecoder() {
return CreateDecoder(ImageDecoder::kNoDecodedImageByteLimit);
std::unique_ptr<ImageDecoder> CreateJPEGDecoder() {
return CreateJPEGDecoder(ImageDecoder::kNoDecodedImageByteLimit);
}
} // anonymous namespace
......@@ -65,7 +65,7 @@ void Downsample(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(max_decoded_bytes);
std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(max_decoded_bytes);
decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0);
......@@ -84,7 +84,7 @@ void ReadYUV(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(max_decoded_bytes);
std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(max_decoded_bytes);
decoder->SetData(data.Get(), true);
// Setting a dummy ImagePlanes object signals to the decoder that we want to
......@@ -134,7 +134,7 @@ void ReadYUV(size_t max_decoded_bytes,
// Tests failure on a too big image.
TEST(JPEGImageDecoderTest, tooBig) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(100);
std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(100);
EXPECT_FALSE(decoder->SetSize(10000, 10000));
EXPECT_TRUE(decoder->Failed());
}
......@@ -259,7 +259,7 @@ TEST(JPEGImageDecoderTest, yuv) {
RefPtr<SharedBuffer> data = ReadFile(jpeg_file);
ASSERT_TRUE(data);
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(230 * 230 * 4);
std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(230 * 230 * 4);
decoder->SetData(data.Get(), true);
std::unique_ptr<ImagePlanes> image_planes = WTF::MakeUnique<ImagePlanes>();
......@@ -270,21 +270,21 @@ TEST(JPEGImageDecoderTest, yuv) {
TEST(JPEGImageDecoderTest,
byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) {
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/"
"small-square-with-colorspin-profile.jpg",
1u, kAnimationNone);
}
TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) {
TestByteByByteDecode(&CreateDecoder,
TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/bug106024.jpg", 1u,
kAnimationNone);
}
TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
TestByteByByteDecode(
&CreateDecoder,
&CreateJPEGDecoder,
"/LayoutTests/images/resources/rgb-jpeg-with-adobe-marker-only.jpg", 1u,
kAnimationNone);
}
......@@ -295,7 +295,7 @@ TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
// read) and a call to do a full decode.
TEST(JPEGImageDecoderTest, mergeBuffer) {
const char* jpeg_file = "/LayoutTests/images/resources/lenna.jpg";
TestMergeBuffer(&CreateDecoder, jpeg_file);
TestMergeBuffer(&CreateJPEGDecoder, jpeg_file);
}
// This tests decoding a JPEG with many progressive scans. Decoding should
......@@ -305,7 +305,7 @@ TEST(JPEGImageDecoderTest, manyProgressiveScans) {
ReadFile(kDecodersTestingDir, "many-progressive-scans.jpg");
ASSERT_TRUE(test_data.Get());
std::unique_ptr<ImageDecoder> test_decoder = CreateDecoder();
std::unique_ptr<ImageDecoder> test_decoder = CreateJPEGDecoder();
test_decoder->SetData(test_data.Get(), true);
EXPECT_EQ(1u, test_decoder->FrameCount());
ASSERT_TRUE(test_decoder->FrameBufferAtIndex(0));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment