Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: Source/platform/image-decoders/ImageDecoderTest.cpp

Issue 201793002: Revert of Allow frames to be free'd even for static images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/image-decoders/ImageDecoder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 TEST(ImageDecoderTest, clearCacheExceptFrameAll) 214 TEST(ImageDecoderTest, clearCacheExceptFrameAll)
215 { 215 {
216 const size_t numFrames = 10; 216 const size_t numFrames = 10;
217 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 217 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
218 decoder->initFrames(numFrames); 218 decoder->initFrames(numFrames);
219 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache(); 219 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache();
220 for (size_t i = 0; i < numFrames; ++i) 220 for (size_t i = 0; i < numFrames; ++i)
221 frameBuffers[i].setStatus(i % 2 ? ImageFrame::FramePartial : ImageFrame: :FrameComplete); 221 frameBuffers[i].setStatus(i % 2 ? ImageFrame::FramePartial : ImageFrame: :FrameComplete);
222 222
223 decoder->clearCacheExceptFrame(kNotFound); 223 decoder->clearCacheExceptFrame(kNotFound);
224
224 for (size_t i = 0; i < numFrames; ++i) { 225 for (size_t i = 0; i < numFrames; ++i) {
225 SCOPED_TRACE(testing::Message() << i); 226 SCOPED_TRACE(testing::Message() << i);
226 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 227 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
227 } 228 }
228 } 229 }
229 230
230 TEST(ImageDecoderTest, clearCacheExceptFrameAllSingleFrame)
231 {
232 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
233 decoder->initFrames(1);
234 ImageFrame* frame = &decoder->frameBufferCache().first();
235 frame->setStatus(ImageFrame::FrameComplete);
236
237 decoder->clearCacheExceptFrame(kNotFound);
238 EXPECT_EQ(ImageFrame::FrameEmpty, frame->status());
239 }
240
241 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame) 231 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame)
242 { 232 {
243 const size_t numFrames = 10; 233 const size_t numFrames = 10;
244 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 234 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
245 decoder->initFrames(numFrames); 235 decoder->initFrames(numFrames);
246 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache(); 236 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache();
247 for (size_t i = 0; i < numFrames; ++i) 237 for (size_t i = 0; i < numFrames; ++i)
248 frameBuffers[i].setStatus(ImageFrame::FrameComplete); 238 frameBuffers[i].setStatus(ImageFrame::FrameComplete);
249 239
250 decoder->resetRequiredPreviousFrames(); 240 decoder->resetRequiredPreviousFrames();
251 decoder->clearCacheExceptFrame(5); 241 decoder->clearCacheExceptFrame(5);
252 for (size_t i = 0; i < numFrames; ++i) { 242 for (size_t i = 0; i < numFrames; ++i) {
253 SCOPED_TRACE(testing::Message() << i); 243 SCOPED_TRACE(testing::Message() << i);
254 if (i == 5) 244 if (i == 5)
255 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status()); 245 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status());
256 else 246 else
257 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 247 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
258 } 248 }
259 } 249 }
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/ImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698