| 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/ImageDecoderTestHelpers.h" | 5 #include "platform/image-decoders/ImageDecoderTestHelpers.h" |
| 6 | 6 |
| 7 #include "platform/SharedBuffer.h" | 7 #include "platform/SharedBuffer.h" |
| 8 #include "platform/image-decoders/ImageDecoder.h" | 8 #include "platform/image-decoders/ImageDecoder.h" |
| 9 #include "platform/image-decoders/ImageFrame.h" | 9 #include "platform/image-decoders/ImageFrame.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 sourceData[1]->append(source++, 1u); | 79 sourceData[1]->append(source++, 1u); |
| 80 // Alternate the buffers to cover the JPEGImageDecoder::onSetData restar
t code. | 80 // Alternate the buffers to cover the JPEGImageDecoder::onSetData restar
t code. |
| 81 decoder->setData(sourceData[length & 1].get(), length == data->size()); | 81 decoder->setData(sourceData[length & 1].get(), length == data->size()); |
| 82 | 82 |
| 83 EXPECT_LE(frameCount, decoder->frameCount()); | 83 EXPECT_LE(frameCount, decoder->frameCount()); |
| 84 frameCount = decoder->frameCount(); | 84 frameCount = decoder->frameCount(); |
| 85 | 85 |
| 86 if (!decoder->isSizeAvailable()) | 86 if (!decoder->isSizeAvailable()) |
| 87 continue; | 87 continue; |
| 88 | 88 |
| 89 for (size_t i = framesDecoded; i < frameCount; ++i) { | 89 ImageFrame* frame = decoder->frameBufferAtIndex(frameCount - 1); |
| 90 // In ICOImageDecoder memory layout could differ from frame order. | 90 if (frame && frame->getStatus() == ImageFrame::FrameComplete && framesDe
coded < frameCount) |
| 91 // E.g. memory layout could be |<frame1><frame0>| and frameCount | 91 ++framesDecoded; |
| 92 // would return 1 until receiving full file. | |
| 93 // When file is completely received frameCount would return 2 and | |
| 94 // only then both frames could be completely decoded. | |
| 95 ImageFrame* frame = decoder->frameBufferAtIndex(i); | |
| 96 if (frame && frame->getStatus() == ImageFrame::FrameComplete) | |
| 97 ++framesDecoded; | |
| 98 } | |
| 99 } | 92 } |
| 100 | 93 |
| 101 EXPECT_FALSE(decoder->failed()); | 94 EXPECT_FALSE(decoder->failed()); |
| 102 EXPECT_EQ(expectedFrameCount, decoder->frameCount()); | 95 EXPECT_EQ(expectedFrameCount, decoder->frameCount()); |
| 103 EXPECT_EQ(expectedFrameCount, framesDecoded); | 96 EXPECT_EQ(expectedFrameCount, framesDecoded); |
| 104 EXPECT_EQ(expectedRepetitionCount, decoder->repetitionCount()); | 97 EXPECT_EQ(expectedRepetitionCount, decoder->repetitionCount()); |
| 105 | 98 |
| 106 ASSERT_EQ(expectedFrameCount, baselineHashes.size()); | 99 ASSERT_EQ(expectedFrameCount, baselineHashes.size()); |
| 107 for (size_t i = 0; i < decoder->frameCount(); i++) { | 100 for (size_t i = 0; i < decoder->frameCount(); i++) { |
| 108 ImageFrame* frame = decoder->frameBufferAtIndex(i); | 101 ImageFrame* frame = decoder->frameBufferAtIndex(i); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 139 // data in a segment, its pointer would no longer be valid. | 132 // data in a segment, its pointer would no longer be valid. |
| 140 segmentedData->data(); | 133 segmentedData->data(); |
| 141 | 134 |
| 142 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 135 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 143 ASSERT_FALSE(decoder->failed()); | 136 ASSERT_FALSE(decoder->failed()); |
| 144 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); | 137 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); |
| 145 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); | 138 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); |
| 146 } | 139 } |
| 147 | 140 |
| 148 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |