| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 decoder->resetRequiredPreviousFrames(); | 179 decoder->resetRequiredPreviousFrames(); |
| 180 decoder->clearCacheExceptFrame(5); | 180 decoder->clearCacheExceptFrame(5); |
| 181 for (size_t i = 0; i < numFrames; ++i) { | 181 for (size_t i = 0; i < numFrames; ++i) { |
| 182 SCOPED_TRACE(testing::Message() << i); | 182 SCOPED_TRACE(testing::Message() << i); |
| 183 if (i == 5) | 183 if (i == 5) |
| 184 EXPECT_EQ(ImageFrame::FrameComplete, decoderFrameBufferCache[i].stat
us()); | 184 EXPECT_EQ(ImageFrame::FrameComplete, decoderFrameBufferCache[i].stat
us()); |
| 185 else | 185 else |
| 186 EXPECT_EQ(ImageFrame::FrameEmpty, decoderFrameBufferCache[i].status(
)); | 186 EXPECT_EQ(ImageFrame::FrameEmpty, decoderFrameBufferCache[i].status(
)); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | |
| 190 TEST(ImageDecoderTest, clearCacheExceptFramePreverveRequiredFrame) | |
| 191 { | |
| 192 const size_t numFrames = 10; | |
| 193 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); | |
| 194 decoder->initFrames(numFrames); | |
| 195 Vector<ImageFrame, 1>& decoderFrameBufferCache = decoder->frameBufferCache()
; | |
| 196 for (size_t i = 0; i < numFrames; ++i) | |
| 197 decoderFrameBufferCache[i].setStatus(ImageFrame::FrameComplete); | |
| 198 | |
| 199 decoderFrameBufferCache[2].setStatus(ImageFrame::FrameComplete); | |
| 200 decoderFrameBufferCache[3].clearPixelData(); | |
| 201 decoderFrameBufferCache[4].setDisposalMethod(ImageFrame::DisposeOverwritePre
vious); | |
| 202 decoderFrameBufferCache[5].setDisposalMethod(ImageFrame::DisposeOverwritePre
vious); | |
| 203 decoderFrameBufferCache[6].clearPixelData(); | |
| 204 decoder->resetRequiredPreviousFrames(); | |
| 205 | |
| 206 // 6 which is empty requires 3 which is empty, and 3 requires 2 which is com
plete, | |
| 207 // so 2 will be required by the next request of 6 and needs to be preserved. | |
| 208 decoder->clearCacheExceptFrame(6); | |
| 209 for (size_t i = 0; i < numFrames; ++i) { | |
| 210 SCOPED_TRACE(testing::Message() << i); | |
| 211 if (i == 2) | |
| 212 EXPECT_EQ(ImageFrame::FrameComplete, decoderFrameBufferCache[i].stat
us()); | |
| 213 else | |
| 214 EXPECT_EQ(ImageFrame::FrameEmpty, decoderFrameBufferCache[i].status(
)); | |
| 215 } | |
| 216 } | |
| OLD | NEW |