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 { ...@@ -14,7 +14,7 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateBMPDecoder() {
return WTF::WrapUnique( return WTF::WrapUnique(
new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied, new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), ColorBehavior::TransformToTargetForTesting(),
...@@ -28,7 +28,7 @@ TEST(BMPImageDecoderTest, isSizeAvailable) { ...@@ -28,7 +28,7 @@ TEST(BMPImageDecoderTest, isSizeAvailable) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
EXPECT_TRUE(decoder->IsSizeAvailable()); EXPECT_TRUE(decoder->IsSizeAvailable());
EXPECT_EQ(256, decoder->Size().Width()); EXPECT_EQ(256, decoder->Size().Width());
...@@ -40,7 +40,7 @@ TEST(BMPImageDecoderTest, parseAndDecode) { ...@@ -40,7 +40,7 @@ TEST(BMPImageDecoderTest, parseAndDecode) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -57,7 +57,7 @@ TEST(BMPImageDecoderTest, emptyImage) { ...@@ -57,7 +57,7 @@ TEST(BMPImageDecoderTest, emptyImage) {
RefPtr<SharedBuffer> data = ReadFile(bmp_file); RefPtr<SharedBuffer> data = ReadFile(bmp_file);
ASSERT_TRUE(data.Get()); ASSERT_TRUE(data.Get());
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); std::unique_ptr<ImageDecoder> decoder = CreateBMPDecoder();
decoder->SetData(data.Get(), true); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -70,7 +70,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) { ...@@ -70,7 +70,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
const char* bmp_file = const char* bmp_file =
"/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN "/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN
RefPtr<SharedBuffer> data = ReadFile(bmp_file); 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. // Test when not all data is received.
decoder->SetData(data.Get(), false); decoder->SetData(data.Get(), false);
EXPECT_FALSE(decoder->IsSizeAvailable()); EXPECT_FALSE(decoder->IsSizeAvailable());
...@@ -83,7 +83,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) { ...@@ -83,7 +83,7 @@ TEST(BMPImageDecoderTest, int32MinHeight) {
// read) and a call to do a full decode. // read) and a call to do a full decode.
TEST(BMPImageDecoderTest, mergeBuffer) { TEST(BMPImageDecoderTest, mergeBuffer) {
const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp"; const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp";
TestMergeBuffer(&CreateDecoder, bmp_file); TestMergeBuffer(&CreateBMPDecoder, bmp_file);
} }
} // namespace blink } // namespace blink
...@@ -13,7 +13,7 @@ namespace blink { ...@@ -13,7 +13,7 @@ namespace blink {
namespace { namespace {
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateICODecoder() {
return WTF::WrapUnique( return WTF::WrapUnique(
new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied, new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), ColorBehavior::TransformToTargetForTesting(),
...@@ -28,7 +28,7 @@ TEST(ICOImageDecoderTests, trunctedIco) { ...@@ -28,7 +28,7 @@ TEST(ICOImageDecoderTests, trunctedIco) {
RefPtr<SharedBuffer> truncated_data = RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(data.data(), data.size() / 2); SharedBuffer::Create(data.data(), data.size() / 2);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false); decoder->SetData(truncated_data.Get(), false);
decoder->FrameBufferAtIndex(0); decoder->FrameBufferAtIndex(0);
...@@ -54,7 +54,7 @@ TEST(ICOImageDecoderTests, errorInPngInIco) { ...@@ -54,7 +54,7 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
modified_data->Append(data.data() + kCrcOffset + kCrcSize, modified_data->Append(data.data() + kCrcOffset + kCrcSize,
data.size() - kCrcOffset - kCrcSize); data.size() - kCrcOffset - kCrcSize);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(modified_data.Get(), true); decoder->SetData(modified_data.Get(), true);
// ICOImageDecoder reports the frame count based on whether enough data has // ICOImageDecoder reports the frame count based on whether enough data has
...@@ -68,22 +68,23 @@ TEST(ICOImageDecoderTests, errorInPngInIco) { ...@@ -68,22 +68,23 @@ TEST(ICOImageDecoderTests, errorInPngInIco) {
} }
TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) { TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/png-in-ico.ico", 1u, "/LayoutTests/images/resources/png-in-ico.ico", 1u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/2entries.ico", 2u, "/LayoutTests/images/resources/2entries.ico", 2u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/greenbox-3frames.cur", 3u, "/LayoutTests/images/resources/greenbox-3frames.cur", 3u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode( TestByteByByteDecode(
&CreateDecoder, &CreateICODecoder,
"/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u, "/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u,
kAnimationNone); kAnimationNone);
TestByteByByteDecode(&CreateDecoder, "/LayoutTests/images/resources/1bit.ico", TestByteByByteDecode(&CreateICODecoder,
1u, kAnimationNone); "/LayoutTests/images/resources/1bit.ico", 1u,
TestByteByByteDecode(&CreateDecoder, kAnimationNone);
TestByteByByteDecode(&CreateICODecoder,
"/LayoutTests/images/resources/bug653075.ico", 2u, "/LayoutTests/images/resources/bug653075.ico", 2u,
kAnimationNone); kAnimationNone);
} }
...@@ -98,7 +99,7 @@ TEST(ICOImageDecoderTests, NullData) { ...@@ -98,7 +99,7 @@ TEST(ICOImageDecoderTests, NullData) {
RefPtr<SharedBuffer> truncated_data = RefPtr<SharedBuffer> truncated_data =
SharedBuffer::Create(ico_file_data->Data(), kSizeOfBadBlock); SharedBuffer::Create(ico_file_data->Data(), kSizeOfBadBlock);
auto decoder = CreateDecoder(); auto decoder = CreateICODecoder();
decoder->SetData(truncated_data.Get(), false); decoder->SetData(truncated_data.Get(), false);
decoder->SetMemoryAllocator(nullptr); decoder->SetMemoryAllocator(nullptr);
......
...@@ -46,14 +46,14 @@ static const size_t kLargeEnoughSize = 1000 * 1000; ...@@ -46,14 +46,14 @@ static const size_t kLargeEnoughSize = 1000 * 1000;
namespace { 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( return WTF::WrapUnique(new JPEGImageDecoder(
ImageDecoder::kAlphaNotPremultiplied, ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes)); ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes));
} }
std::unique_ptr<ImageDecoder> CreateDecoder() { std::unique_ptr<ImageDecoder> CreateJPEGDecoder() {
return CreateDecoder(ImageDecoder::kNoDecodedImageByteLimit); return CreateJPEGDecoder(ImageDecoder::kNoDecodedImageByteLimit);
} }
} // anonymous namespace } // anonymous namespace
...@@ -65,7 +65,7 @@ void Downsample(size_t max_decoded_bytes, ...@@ -65,7 +65,7 @@ void Downsample(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path); RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data); 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); decoder->SetData(data.Get(), true);
ImageFrame* frame = decoder->FrameBufferAtIndex(0); ImageFrame* frame = decoder->FrameBufferAtIndex(0);
...@@ -84,7 +84,7 @@ void ReadYUV(size_t max_decoded_bytes, ...@@ -84,7 +84,7 @@ void ReadYUV(size_t max_decoded_bytes,
RefPtr<SharedBuffer> data = ReadFile(image_file_path); RefPtr<SharedBuffer> data = ReadFile(image_file_path);
ASSERT_TRUE(data); 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); decoder->SetData(data.Get(), true);
// Setting a dummy ImagePlanes object signals to the decoder that we want to // Setting a dummy ImagePlanes object signals to the decoder that we want to
...@@ -134,7 +134,7 @@ void ReadYUV(size_t max_decoded_bytes, ...@@ -134,7 +134,7 @@ void ReadYUV(size_t max_decoded_bytes,
// Tests failure on a too big image. // Tests failure on a too big image.
TEST(JPEGImageDecoderTest, tooBig) { TEST(JPEGImageDecoderTest, tooBig) {
std::unique_ptr<ImageDecoder> decoder = CreateDecoder(100); std::unique_ptr<ImageDecoder> decoder = CreateJPEGDecoder(100);
EXPECT_FALSE(decoder->SetSize(10000, 10000)); EXPECT_FALSE(decoder->SetSize(10000, 10000));
EXPECT_TRUE(decoder->Failed()); EXPECT_TRUE(decoder->Failed());
} }
...@@ -259,7 +259,7 @@ TEST(JPEGImageDecoderTest, yuv) { ...@@ -259,7 +259,7 @@ TEST(JPEGImageDecoderTest, yuv) {
RefPtr<SharedBuffer> data = ReadFile(jpeg_file); RefPtr<SharedBuffer> data = ReadFile(jpeg_file);
ASSERT_TRUE(data); 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); decoder->SetData(data.Get(), true);
std::unique_ptr<ImagePlanes> image_planes = WTF::MakeUnique<ImagePlanes>(); std::unique_ptr<ImagePlanes> image_planes = WTF::MakeUnique<ImagePlanes>();
...@@ -270,21 +270,21 @@ TEST(JPEGImageDecoderTest, yuv) { ...@@ -270,21 +270,21 @@ TEST(JPEGImageDecoderTest, yuv) {
TEST(JPEGImageDecoderTest, TEST(JPEGImageDecoderTest,
byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) { byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/" "/LayoutTests/images/resources/"
"small-square-with-colorspin-profile.jpg", "small-square-with-colorspin-profile.jpg",
1u, kAnimationNone); 1u, kAnimationNone);
} }
TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) { TEST(JPEGImageDecoderTest, byteByByteProgressiveJPEG) {
TestByteByByteDecode(&CreateDecoder, TestByteByByteDecode(&CreateJPEGDecoder,
"/LayoutTests/images/resources/bug106024.jpg", 1u, "/LayoutTests/images/resources/bug106024.jpg", 1u,
kAnimationNone); kAnimationNone);
} }
TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) { TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
TestByteByByteDecode( TestByteByByteDecode(
&CreateDecoder, &CreateJPEGDecoder,
"/LayoutTests/images/resources/rgb-jpeg-with-adobe-marker-only.jpg", 1u, "/LayoutTests/images/resources/rgb-jpeg-with-adobe-marker-only.jpg", 1u,
kAnimationNone); kAnimationNone);
} }
...@@ -295,7 +295,7 @@ TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) { ...@@ -295,7 +295,7 @@ TEST(JPEGImageDecoderTest, byteByByteRGBJPEGWithAdobeMarkers) {
// read) and a call to do a full decode. // read) and a call to do a full decode.
TEST(JPEGImageDecoderTest, mergeBuffer) { TEST(JPEGImageDecoderTest, mergeBuffer) {
const char* jpeg_file = "/LayoutTests/images/resources/lenna.jpg"; 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 // This tests decoding a JPEG with many progressive scans. Decoding should
...@@ -305,7 +305,7 @@ TEST(JPEGImageDecoderTest, manyProgressiveScans) { ...@@ -305,7 +305,7 @@ TEST(JPEGImageDecoderTest, manyProgressiveScans) {
ReadFile(kDecodersTestingDir, "many-progressive-scans.jpg"); ReadFile(kDecodersTestingDir, "many-progressive-scans.jpg");
ASSERT_TRUE(test_data.Get()); 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); test_decoder->SetData(test_data.Get(), true);
EXPECT_EQ(1u, test_decoder->FrameCount()); EXPECT_EQ(1u, test_decoder->FrameCount());
ASSERT_TRUE(test_decoder->FrameBufferAtIndex(0)); 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