| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/image-decoders/ico/ICOImageDecoder.h" | 5 #include "platform/image-decoders/ico/ICOImageDecoder.h" |
| 6 | 6 |
| 7 #include "platform/image-decoders/ImageDecoderTestHelpers.h" | 7 #include "platform/image-decoders/ImageDecoderTestHelpers.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "wtf/PtrUtil.h" | 9 #include "wtf/PtrUtil.h" |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) | 23 TEST(ICOImageDecoderTests, parseAndDecodeByteByByte) |
| 24 { | 24 { |
| 25 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/2en
tries.ico", 2u, cAnimationNone); | 25 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/2en
tries.ico", 2u, cAnimationNone); |
| 26 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/gre
enbox-3frames.cur", 3u, cAnimationNone); | 26 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/gre
enbox-3frames.cur", 3u, cAnimationNone); |
| 27 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/ico
n-without-and-bitmap.ico", 1u, cAnimationNone); | 27 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/ico
n-without-and-bitmap.ico", 1u, cAnimationNone); |
| 28 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/1bi
t.ico", 1u, cAnimationNone); | 28 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/1bi
t.ico", 1u, cAnimationNone); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TEST(ICOImageDecoderTests, setDataTruncated) |
| 32 { |
| 33 std::unique_ptr<ImageDecoder> decoder = createDecoder(); |
| 34 |
| 35 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/wro
ng-frame-dimensions.ico"); |
| 36 ASSERT_TRUE(data.get()); |
| 37 |
| 38 ASSERT_GE(data->size(), 10u); |
| 39 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->siz
e() - 10); |
| 40 decoder->setData(tempData.get(), true); |
| 41 |
| 42 EXPECT_EQ(3u, decoder->frameCount()); |
| 43 EXPECT_FALSE(decoder->failed()); |
| 44 |
| 45 // Issue 621488 - all data received, but truncated. |
| 46 RefPtr<SharedBuffer> emptyData = SharedBuffer::create(data->data(), size_t {
0 }); |
| 47 decoder->setData(emptyData.get(), true); |
| 48 EXPECT_EQ(3u, decoder->frameCount()); |
| 49 EXPECT_TRUE(decoder->failed()); |
| 50 |
| 51 decoder = createDecoder(); |
| 52 decoder->setData(tempData.get(), true); |
| 53 decoder->frameBufferAtIndex(2); |
| 54 EXPECT_FALSE(decoder->failed()); |
| 55 decoder->frameBufferAtIndex(1); |
| 56 EXPECT_TRUE(decoder->failed()); |
| 57 } |
| 58 |
| 31 } // namespace blink | 59 } // namespace blink |
| OLD | NEW |