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 <memory> | 7 #include <memory> |
8 #include "platform/image-decoders/ImageDecoderTestHelpers.h" | 8 #include "platform/image-decoders/ImageDecoderTestHelpers.h" |
9 #include "platform/wtf/PtrUtil.h" | 9 #include "platform/wtf/PtrUtil.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 std::unique_ptr<ImageDecoder> CreateDecoder() { | 16 std::unique_ptr<ImageDecoder> CreateDecoder() { |
17 return WTF::WrapUnique( | 17 return WTF::WrapUnique( |
18 new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied, | 18 new ICOImageDecoder(ImageDecoder::kAlphaNotPremultiplied, |
19 ColorBehavior::TransformToTargetForTesting(), | 19 ColorBehavior::TransformToTargetForTesting(), |
20 ImageDecoder::kNoDecodedImageByteLimit)); | 20 ImageDecoder::kNoDecodedImageByteLimit)); |
21 } | 21 } |
22 } | 22 } // namespace |
23 | 23 |
24 TEST(ICOImageDecoderTests, trunctedIco) { | 24 TEST(ICOImageDecoderTests, trunctedIco) { |
25 const Vector<char> data = | 25 const Vector<char> data = |
26 ReadFile("/LayoutTests/images/resources/png-in-ico.ico")->Copy(); | 26 ReadFile("/LayoutTests/images/resources/png-in-ico.ico")->Copy(); |
27 ASSERT_FALSE(data.IsEmpty()); | 27 ASSERT_FALSE(data.IsEmpty()); |
28 | 28 |
29 RefPtr<SharedBuffer> truncated_data = | 29 RefPtr<SharedBuffer> truncated_data = |
30 SharedBuffer::Create(data.data(), data.size() / 2); | 30 SharedBuffer::Create(data.data(), data.size() / 2); |
31 auto decoder = CreateDecoder(); | 31 auto decoder = CreateDecoder(); |
32 | 32 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 "/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u, | 82 "/LayoutTests/images/resources/icon-without-and-bitmap.ico", 1u, |
83 kAnimationNone); | 83 kAnimationNone); |
84 TestByteByByteDecode(&CreateDecoder, "/LayoutTests/images/resources/1bit.ico", | 84 TestByteByByteDecode(&CreateDecoder, "/LayoutTests/images/resources/1bit.ico", |
85 1u, kAnimationNone); | 85 1u, kAnimationNone); |
86 TestByteByByteDecode(&CreateDecoder, | 86 TestByteByByteDecode(&CreateDecoder, |
87 "/LayoutTests/images/resources/bug653075.ico", 2u, | 87 "/LayoutTests/images/resources/bug653075.ico", 2u, |
88 kAnimationNone); | 88 kAnimationNone); |
89 } | 89 } |
90 | 90 |
91 } // namespace blink | 91 } // namespace blink |
OLD | NEW |