| 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/graphics/DeferredImageDecoder.h" | 5 #include "platform/graphics/DeferredImageDecoder.h" |
| 6 | 6 |
| 7 #include "platform/SharedBuffer.h" | 7 #include "platform/SharedBuffer.h" |
| 8 #include "platform/image-decoders/ImageDecoderTestHelpers.h" | 8 #include "platform/image-decoders/ImageDecoderTestHelpers.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkImage.h" | 10 #include "third_party/skia/include/core/SkImage.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 EXPECT_EQ(skData->size(), fileBuffer->size()); | 96 EXPECT_EQ(skData->size(), fileBuffer->size()); |
| 97 const char* data = reinterpret_cast<const char*>(skData->bytes()); | 97 const char* data = reinterpret_cast<const char*>(skData->bytes()); |
| 98 | 98 |
| 99 // Truncated signature (only 1 byte). Decoder instantiation should fail. | 99 // Truncated signature (only 1 byte). Decoder instantiation should fail. |
| 100 RefPtr<SharedBuffer> buffer = SharedBuffer::create<size_t>(data, 1u); | 100 RefPtr<SharedBuffer> buffer = SharedBuffer::create<size_t>(data, 1u); |
| 101 EXPECT_FALSE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); | 101 EXPECT_FALSE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); |
| 102 EXPECT_EQ(nullptr, DeferredImageDecoder::create( | 102 EXPECT_EQ(nullptr, DeferredImageDecoder::create( |
| 103 buffer, false, ImageDecoder::AlphaPremultiplied, | 103 buffer, false, ImageDecoder::AlphaPremultiplied, |
| 104 ImageDecoder::GammaAndColorProfileIgnored)); | 104 ImageDecoder::GammaAndColorProfileIgnored)); |
| 105 | 105 |
| 106 // Append the rest of the data. We should be able to sniff the signature no
w, even if segmented. | 106 // Append the rest of the data. We should be able to sniff the signature |
| 107 // now, even if segmented. |
| 107 buffer->append<size_t>(data + 1, skData->size() - 1); | 108 buffer->append<size_t>(data + 1, skData->size() - 1); |
| 108 EXPECT_TRUE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); | 109 EXPECT_TRUE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); |
| 109 std::unique_ptr<DeferredImageDecoder> decoder = | 110 std::unique_ptr<DeferredImageDecoder> decoder = |
| 110 DeferredImageDecoder::create(buffer, false, | 111 DeferredImageDecoder::create(buffer, false, |
| 111 ImageDecoder::AlphaPremultiplied, | 112 ImageDecoder::AlphaPremultiplied, |
| 112 ImageDecoder::GammaAndColorProfileIgnored); | 113 ImageDecoder::GammaAndColorProfileIgnored); |
| 113 ASSERT_NE(decoder, nullptr); | 114 ASSERT_NE(decoder, nullptr); |
| 114 EXPECT_TRUE(String(testFiles[i]).endsWith(decoder->filenameExtension())); | 115 EXPECT_TRUE(String(testFiles[i]).endsWith(decoder->filenameExtension())); |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |