| 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/webp/WEBPImageDecoder.h" | 32 #include "platform/image-decoders/webp/WEBPImageDecoder.h" |
| 34 | 33 |
| 35 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 36 #include "platform/SharedBuffer.h" | 35 #include "platform/SharedBuffer.h" |
| 37 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebData.h" | 37 #include "public/platform/WebData.h" |
| 39 #include "public/platform/WebSize.h" | 38 #include "public/platform/WebSize.h" |
| 40 #include "public/platform/WebUnitTestSupport.h" | 39 #include "public/platform/WebUnitTestSupport.h" |
| 41 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 42 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 43 #include "wtf/StringHasher.h" | 42 #include "wtf/StringHasher.h" |
| 44 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 45 #include "wtf/dtoa/utils.h" | 44 #include "wtf/dtoa/utils.h" |
| 46 #include <gtest/gtest.h> | 45 #include <gtest/gtest.h> |
| 47 | 46 |
| 48 using namespace blink; | 47 namespace blink { |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 PassRefPtr<SharedBuffer> readFile(const char* fileName) | 51 PassRefPtr<SharedBuffer> readFile(const char* fileName) |
| 53 { | 52 { |
| 54 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); | 53 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); |
| 55 filePath.append(fileName); | 54 filePath.append(fileName); |
| 56 | 55 |
| 57 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 56 return Platform::current()->unitTestSupport()->readFromFile(filePath); |
| 58 } | 57 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 OwnPtr<WEBPImageDecoder> decoderB = createDecoder(ImageSource::AlphaNotPremu
ltiplied); | 301 OwnPtr<WEBPImageDecoder> decoderB = createDecoder(ImageSource::AlphaNotPremu
ltiplied); |
| 303 decoderB->setData(data.get(), true); | 302 decoderB->setData(data.get(), true); |
| 304 | 303 |
| 305 size_t frameCount = decoderA->frameCount(); | 304 size_t frameCount = decoderA->frameCount(); |
| 306 ASSERT_EQ(frameCount, decoderB->frameCount()); | 305 ASSERT_EQ(frameCount, decoderB->frameCount()); |
| 307 | 306 |
| 308 for (size_t i = 0; i < frameCount; ++i) | 307 for (size_t i = 0; i < frameCount; ++i) |
| 309 verifyFramesMatch(webpFile, decoderA->frameBufferAtIndex(i), decoderB->f
rameBufferAtIndex(i)); | 308 verifyFramesMatch(webpFile, decoderA->frameBufferAtIndex(i), decoderB->f
rameBufferAtIndex(i)); |
| 310 } | 309 } |
| 311 | 310 |
| 312 } // namespace | 311 } // anonymous namespace |
| 313 | 312 |
| 314 TEST(AnimatedWebPTests, uniqueGenerationIDs) | 313 TEST(AnimatedWebPTests, uniqueGenerationIDs) |
| 315 { | 314 { |
| 316 OwnPtr<WEBPImageDecoder> decoder = createDecoder(); | 315 OwnPtr<WEBPImageDecoder> decoder = createDecoder(); |
| 317 | 316 |
| 318 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web
p-animated.webp"); | 317 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web
p-animated.webp"); |
| 319 ASSERT_TRUE(data.get()); | 318 ASSERT_TRUE(data.get()); |
| 320 decoder->setData(data.get(), true); | 319 decoder->setData(data.get(), true); |
| 321 | 320 |
| 322 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 321 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 732 |
| 734 TEST(StaticWebPTests, notAnimated) | 733 TEST(StaticWebPTests, notAnimated) |
| 735 { | 734 { |
| 736 OwnPtr<WEBPImageDecoder> decoder = createDecoder(); | 735 OwnPtr<WEBPImageDecoder> decoder = createDecoder(); |
| 737 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web
p-color-profile-lossy.webp"); | 736 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web
p-color-profile-lossy.webp"); |
| 738 ASSERT_TRUE(data.get()); | 737 ASSERT_TRUE(data.get()); |
| 739 decoder->setData(data.get(), true); | 738 decoder->setData(data.get(), true); |
| 740 EXPECT_EQ(1u, decoder->frameCount()); | 739 EXPECT_EQ(1u, decoder->frameCount()); |
| 741 EXPECT_EQ(cAnimationNone, decoder->repetitionCount()); | 740 EXPECT_EQ(cAnimationNone, decoder->repetitionCount()); |
| 742 } | 741 } |
| 742 |
| 743 } // namespace blink |
| OLD | NEW |