Chromium Code Reviews| Index: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/exported/WebData.cpp b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.cpp |
| similarity index 52% |
| copy from third_party/WebKit/Source/platform/exported/WebData.cpp |
| copy to third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.cpp |
| index 9fc90b3e34ccfcc42764d1084bae5bffc3d10646..12eb4fe507f9c86fcb02f5d660c02e3a15965b43 100644 |
| --- a/third_party/WebKit/Source/platform/exported/WebData.cpp |
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.cpp |
| @@ -1,5 +1,5 @@ |
| /* |
| - * Copyright (C) 2009 Google Inc. All rights reserved. |
| + * Copyright (C) 2016 Google Inc. All rights reserved. |
|
scroggo_chromium
2016/10/04 14:50:16
I think you want a simpler copyright header:
// C
joostouwerling
2016/10/11 16:31:06
Acknowledged.
|
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are |
| @@ -28,55 +28,57 @@ |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#include "public/platform/WebData.h" |
| +#include "platform/image-decoders/png/PNGImageDecoder.h" |
| +#include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/SharedBuffer.h" |
| +#include "platform/image-decoders/ImageDecoderTestHelpers.h" |
| +#include "public/platform/WebData.h" |
| +#include "public/platform/WebSize.h" |
|
scroggo_chromium
2016/10/04 14:50:16
I don't think you need this (or WebData.h). Make s
joostouwerling
2016/10/11 16:31:06
Acknowledged.
|
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "wtf/PtrUtil.h" |
| +#include "wtf/Vector.h" |
| +#include "wtf/dtoa/utils.h" |
| +#include <memory> |
| namespace blink { |
| -void WebData::reset() |
| -{ |
| - m_private.reset(); |
| -} |
| +namespace { |
| -void WebData::assign(const WebData& other) |
| +std::unique_ptr<ImageDecoder> createDecoder(ImageDecoder::AlphaOption alphaOption) |
| { |
| - m_private = other.m_private; |
| + return wrapUnique(new PNGImageDecoder(alphaOption, |
| + ImageDecoder::GammaAndColorProfileApplied, |
| + ImageDecoder::noDecodedImageByteLimit)); |
| } |
| -void WebData::assign(const char* data, size_t size) |
| +std::unique_ptr<ImageDecoder> createDecoder() |
| { |
| - m_private = SharedBuffer::create(data, size); |
| + return createDecoder(ImageDecoder::AlphaNotPremultiplied); |
| } |
| -size_t WebData::size() const |
| +void testFrameCount(const char* pngFile, size_t expectedFrameCount) |
| { |
| - if (m_private.isNull()) |
| - return 0; |
| - return m_private->size(); |
| -} |
| + auto decoder = createDecoder(); |
| -const char* WebData::data() const |
| -{ |
| - if (m_private.isNull()) |
| - return 0; |
| - return m_private->data(); |
| -} |
| + auto data = readFile(pngFile); |
| + ASSERT_TRUE(data.get()); |
| + decoder->setData(data.get(), true); |
| -WebData::WebData(PassRefPtr<SharedBuffer> buffer) |
| - : m_private(buffer) |
| -{ |
| + EXPECT_EQ(expectedFrameCount, decoder->frameCount()); |
| } |
| -WebData& WebData::operator=(PassRefPtr<SharedBuffer> buffer) |
| +} // Anonymous namespace |
| + |
| +TEST(AnimatedPNGTests, FrameCountTest) |
| { |
| - m_private = buffer; |
| - return *this; |
| + testFrameCount("/LayoutTests/fast/images/resources/png-animated-idat-part-of-animation.png", 20); |
| + testFrameCount("/LayoutTests/fast/images/resources/png-animated-idat-not-part-of-animation.png", 1); |
| } |
| -WebData::operator PassRefPtr<SharedBuffer>() const |
| +TEST(StaticPNGTests, FrameCountTest) |
| { |
| - return PassRefPtr<SharedBuffer>(m_private.get()); |
| + testFrameCount("/LayoutTests/fast/images/resources/png-simple.png", 1); |
| } |
| -} // namespace blink |
| +}; // namespace blink |