| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bmp/BMPImageDecoder.h" | 5 #include "platform/image-decoders/bmp/BMPImageDecoder.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 "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 std::unique_ptr<ImageDecoder> decoder = createDecoder(); | 61 std::unique_ptr<ImageDecoder> decoder = createDecoder(); |
| 62 decoder->setData(data.get(), true); | 62 decoder->setData(data.get(), true); |
| 63 | 63 |
| 64 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 64 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 65 ASSERT_TRUE(frame); | 65 ASSERT_TRUE(frame); |
| 66 EXPECT_EQ(ImageFrame::FrameEmpty, frame->getStatus()); | 66 EXPECT_EQ(ImageFrame::FrameEmpty, frame->getStatus()); |
| 67 EXPECT_TRUE(decoder->failed()); | 67 EXPECT_TRUE(decoder->failed()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST(BMPImageDecoderTest, int32MinHeight) |
| 71 { |
| 72 const char* bmpFile = "/LayoutTests/fast/images/resources/1xint32_min.bmp";
// 0xINT32_MIN |
| 73 RefPtr<SharedBuffer> data = readFile(bmpFile); |
| 74 std::unique_ptr<ImageDecoder> decoder = createDecoder(); |
| 75 // Test when not all data is received. |
| 76 decoder->setData(data.get(), false); |
| 77 EXPECT_FALSE(decoder->isSizeAvailable()); |
| 78 EXPECT_TRUE(decoder->failed()); |
| 79 } |
| 80 |
| 70 // This test verifies that calling SharedBuffer::mergeSegmentsIntoBuffer() does | 81 // This test verifies that calling SharedBuffer::mergeSegmentsIntoBuffer() does |
| 71 // not break BMP decoding at a critical point: in between a call to decode the | 82 // not break BMP decoding at a critical point: in between a call to decode the |
| 72 // size (when BMPImageDecoder stops while it may still have input data to | 83 // size (when BMPImageDecoder stops while it may still have input data to |
| 73 // read) and a call to do a full decode. | 84 // read) and a call to do a full decode. |
| 74 TEST(BMPImageDecoderTest, mergeBuffer) | 85 TEST(BMPImageDecoderTest, mergeBuffer) |
| 75 { | 86 { |
| 76 const char* bmpFile = "/LayoutTests/fast/images/resources/lenna.bmp"; | 87 const char* bmpFile = "/LayoutTests/fast/images/resources/lenna.bmp"; |
| 77 testMergeBuffer(&createDecoder, bmpFile); | 88 testMergeBuffer(&createDecoder, bmpFile); |
| 78 } | 89 } |
| 79 | 90 |
| 80 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |