| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | |
| 33 #include "platform/image-decoders/gif/GIFImageDecoder.h" | 32 #include "platform/image-decoders/gif/GIFImageDecoder.h" |
| 34 | 33 |
| 35 #include "platform/SharedBuffer.h" | 34 #include "platform/SharedBuffer.h" |
| 36 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebData.h" | 36 #include "public/platform/WebData.h" |
| 38 #include "public/platform/WebSize.h" | 37 #include "public/platform/WebSize.h" |
| 39 #include "public/platform/WebUnitTestSupport.h" | 38 #include "public/platform/WebUnitTestSupport.h" |
| 40 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/StringHasher.h" | 41 #include "wtf/StringHasher.h" |
| 43 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
| 44 #include <gtest/gtest.h> | 43 #include <gtest/gtest.h> |
| 45 | 44 |
| 46 using namespace blink; | 45 namespace blink { |
| 47 | 46 |
| 48 namespace { | 47 namespace { |
| 49 | 48 |
| 50 const char decodersTestingDir[] = "Source/platform/image-decoders/testing"; | 49 const char decodersTestingDir[] = "Source/platform/image-decoders/testing"; |
| 51 const char layoutTestResourcesDir[] = "LayoutTests/fast/images/resources"; | 50 const char layoutTestResourcesDir[] = "LayoutTests/fast/images/resources"; |
| 52 const char webTestsDataDir[] = "Source/web/tests/data"; | 51 const char webTestsDataDir[] = "Source/web/tests/data"; |
| 53 | 52 |
| 54 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) | 53 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) |
| 55 { | 54 { |
| 56 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); | 55 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 for (size_t i = 0; i < skippingStep; ++i) { | 132 for (size_t i = 0; i < skippingStep; ++i) { |
| 134 for (size_t j = 0; j < frameCount; j += skippingStep) { | 133 for (size_t j = 0; j < frameCount; j += skippingStep) { |
| 135 SCOPED_TRACE(testing::Message() << "Random i:" << i << " j:" <<
j); | 134 SCOPED_TRACE(testing::Message() << "Random i:" << i << " j:" <<
j); |
| 136 ImageFrame* frame = decoder->frameBufferAtIndex(j); | 135 ImageFrame* frame = decoder->frameBufferAtIndex(j); |
| 137 EXPECT_EQ(baselineHashes[j], hashSkBitmap(frame->getSkBitmap()))
; | 136 EXPECT_EQ(baselineHashes[j], hashSkBitmap(frame->getSkBitmap()))
; |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 } | 140 } |
| 142 | 141 |
| 143 } // namespace | 142 } // anonymous namespace |
| 144 | 143 |
| 145 TEST(GIFImageDecoderTest, decodeTwoFrames) | 144 TEST(GIFImageDecoderTest, decodeTwoFrames) |
| 146 { | 145 { |
| 147 OwnPtr<GIFImageDecoder> decoder = createDecoder(); | 146 OwnPtr<GIFImageDecoder> decoder = createDecoder(); |
| 148 | 147 |
| 149 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif")
; | 148 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif")
; |
| 150 ASSERT_TRUE(data.get()); | 149 ASSERT_TRUE(data.get()); |
| 151 decoder->setData(data.get(), true); | 150 decoder->setData(data.get(), true); |
| 152 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); | 151 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); |
| 153 | 152 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 522 |
| 524 if (decoder->isSizeAvailable() && !frameSize.width() && !frameSize.heigh
t()) { | 523 if (decoder->isSizeAvailable() && !frameSize.width() && !frameSize.heigh
t()) { |
| 525 frameSize = decoder->decodedSize(); | 524 frameSize = decoder->decodedSize(); |
| 526 continue; | 525 continue; |
| 527 } | 526 } |
| 528 | 527 |
| 529 ASSERT_EQ(frameSize.width(), decoder->decodedSize().width()); | 528 ASSERT_EQ(frameSize.width(), decoder->decodedSize().width()); |
| 530 ASSERT_EQ(frameSize.height(), decoder->decodedSize().height()); | 529 ASSERT_EQ(frameSize.height(), decoder->decodedSize().height()); |
| 531 } | 530 } |
| 532 } | 531 } |
| 532 |
| 533 } // namespace blink |
| OLD | NEW |