| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Pass data to decoder byte by byte. | 74 // Pass data to decoder byte by byte. |
| 75 RefPtr<SharedBuffer> sourceData[2] = {SharedBuffer::create(), | 75 RefPtr<SharedBuffer> sourceData[2] = {SharedBuffer::create(), |
| 76 SharedBuffer::create()}; | 76 SharedBuffer::create()}; |
| 77 const char* source = data->data(); | 77 const char* source = data->data(); |
| 78 | 78 |
| 79 for (size_t length = 1; length <= data->size() && !decoder->failed(); | 79 for (size_t length = 1; length <= data->size() && !decoder->failed(); |
| 80 ++length) { | 80 ++length) { |
| 81 sourceData[0]->append(source, 1u); | 81 sourceData[0]->append(source, 1u); |
| 82 sourceData[1]->append(source++, 1u); | 82 sourceData[1]->append(source++, 1u); |
| 83 // Alternate the buffers to cover the JPEGImageDecoder::onSetData restart co
de. | 83 // Alternate the buffers to cover the JPEGImageDecoder::onSetData restart |
| 84 // code. |
| 84 decoder->setData(sourceData[length & 1].get(), length == data->size()); | 85 decoder->setData(sourceData[length & 1].get(), length == data->size()); |
| 85 | 86 |
| 86 EXPECT_LE(frameCount, decoder->frameCount()); | 87 EXPECT_LE(frameCount, decoder->frameCount()); |
| 87 frameCount = decoder->frameCount(); | 88 frameCount = decoder->frameCount(); |
| 88 | 89 |
| 89 if (!decoder->isSizeAvailable()) | 90 if (!decoder->isSizeAvailable()) |
| 90 continue; | 91 continue; |
| 91 | 92 |
| 92 for (size_t i = framesDecoded; i < frameCount; ++i) { | 93 for (size_t i = framesDecoded; i < frameCount; ++i) { |
| 93 // In ICOImageDecoder memory layout could differ from frame order. | 94 // In ICOImageDecoder memory layout could differ from frame order. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // data in a segment, its pointer would no longer be valid. | 142 // data in a segment, its pointer would no longer be valid. |
| 142 segmentedData->data(); | 143 segmentedData->data(); |
| 143 | 144 |
| 144 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 145 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 145 ASSERT_FALSE(decoder->failed()); | 146 ASSERT_FALSE(decoder->failed()); |
| 146 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); | 147 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); |
| 147 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); | 148 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); |
| 148 } | 149 } |
| 149 | 150 |
| 150 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |