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

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

Issue 136503002: Allow frames to be free'd even for static images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Prune excess h-space. Created 6 years, 11 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
225 for (size_t i = 0; i < numFrames; ++i) { 224 for (size_t i = 0; i < numFrames; ++i) {
226 SCOPED_TRACE(testing::Message() << i); 225 SCOPED_TRACE(testing::Message() << i);
227 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 226 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
228 } 227 }
229 } 228 }
230 229
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
231 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame) 241 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame)
232 { 242 {
233 const size_t numFrames = 10; 243 const size_t numFrames = 10;
234 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 244 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
235 decoder->initFrames(numFrames); 245 decoder->initFrames(numFrames);
236 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache(); 246 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache();
237 for (size_t i = 0; i < numFrames; ++i) 247 for (size_t i = 0; i < numFrames; ++i)
238 frameBuffers[i].setStatus(ImageFrame::FrameComplete); 248 frameBuffers[i].setStatus(ImageFrame::FrameComplete);
239 249
240 decoder->resetRequiredPreviousFrames(); 250 decoder->resetRequiredPreviousFrames();
241 decoder->clearCacheExceptFrame(5); 251 decoder->clearCacheExceptFrame(5);
242 for (size_t i = 0; i < numFrames; ++i) { 252 for (size_t i = 0; i < numFrames; ++i) {
243 SCOPED_TRACE(testing::Message() << i); 253 SCOPED_TRACE(testing::Message() << i);
244 if (i == 5) 254 if (i == 5)
245 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status()); 255 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status());
246 else 256 else
247 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 257 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
248 } 258 }
249 } 259 }
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