| 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 bool frameIsFullyReceived = decoder->frameIsFullyReceivedAtIndex(frameCo
unt - 1); |
| 89 ImageFrame* frame = decoder->frameBufferAtIndex(frameCount - 1); | 90 ImageFrame* frame = decoder->frameBufferAtIndex(frameCount - 1); |
| 91 |
| 92 if (frameIsFullyReceived) |
| 93 ASSERT_TRUE(decoder->frameIsCompleteAtIndex(frameCount - 1) || decod
er->failed()); |
| 94 |
| 95 for (size_t i = 0; i < framesDecoded; ++i) { |
| 96 ASSERT_TRUE(decoder->frameIsFullyReceivedAtIndex(i)); |
| 97 } |
| 98 |
| 90 if (frame && frame->getStatus() == ImageFrame::FrameComplete && framesDe
coded < frameCount) | 99 if (frame && frame->getStatus() == ImageFrame::FrameComplete && framesDe
coded < frameCount) |
| 91 ++framesDecoded; | 100 ++framesDecoded; |
| 92 } | 101 } |
| 93 | 102 |
| 94 EXPECT_FALSE(decoder->failed()); | 103 EXPECT_FALSE(decoder->failed()); |
| 95 EXPECT_EQ(expectedFrameCount, decoder->frameCount()); | 104 EXPECT_EQ(expectedFrameCount, decoder->frameCount()); |
| 96 EXPECT_EQ(expectedFrameCount, framesDecoded); | 105 EXPECT_EQ(expectedFrameCount, framesDecoded); |
| 97 EXPECT_EQ(expectedRepetitionCount, decoder->repetitionCount()); | 106 EXPECT_EQ(expectedRepetitionCount, decoder->repetitionCount()); |
| 98 | 107 |
| 99 ASSERT_EQ(expectedFrameCount, baselineHashes.size()); | 108 ASSERT_EQ(expectedFrameCount, baselineHashes.size()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // data in a segment, its pointer would no longer be valid. | 141 // data in a segment, its pointer would no longer be valid. |
| 133 segmentedData->data(); | 142 segmentedData->data(); |
| 134 | 143 |
| 135 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 144 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 136 ASSERT_FALSE(decoder->failed()); | 145 ASSERT_FALSE(decoder->failed()); |
| 137 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); | 146 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); |
| 138 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); | 147 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); |
| 139 } | 148 } |
| 140 | 149 |
| 141 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |