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

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: 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
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
225 for (size_t i = 0; i < numFrames; ++i) { 225 for (size_t i = 0; i < numFrames; ++i) {
226 SCOPED_TRACE(testing::Message() << i); 226 SCOPED_TRACE(testing::Message() << i);
227 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 227 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
228 } 228 }
229 } 229 }
230 230
231 TEST(ImageDecoderTest, clearCacheExceptFrameAllSingleFrame)
232 {
233 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
234 decoder->initFrames(1);
235 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache();
Peter Kasting 2014/01/14 00:46:18 Nit: What about: ImageFrame* frame = &decoder->fr
fs 2014/01/14 08:32:09 Agreed. Will change.
236 frameBuffers[0].setStatus(ImageFrame::FrameComplete);
237
238 decoder->clearCacheExceptFrame(kNotFound);
239
240 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[0].status());
241 }
242
231 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame) 243 TEST(ImageDecoderTest, clearCacheExceptFramePreverveClearExceptFrame)
232 { 244 {
233 const size_t numFrames = 10; 245 const size_t numFrames = 10;
234 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 246 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
235 decoder->initFrames(numFrames); 247 decoder->initFrames(numFrames);
236 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache(); 248 Vector<ImageFrame, 1>& frameBuffers = decoder->frameBufferCache();
237 for (size_t i = 0; i < numFrames; ++i) 249 for (size_t i = 0; i < numFrames; ++i)
238 frameBuffers[i].setStatus(ImageFrame::FrameComplete); 250 frameBuffers[i].setStatus(ImageFrame::FrameComplete);
239 251
240 decoder->resetRequiredPreviousFrames(); 252 decoder->resetRequiredPreviousFrames();
241 decoder->clearCacheExceptFrame(5); 253 decoder->clearCacheExceptFrame(5);
242 for (size_t i = 0; i < numFrames; ++i) { 254 for (size_t i = 0; i < numFrames; ++i) {
243 SCOPED_TRACE(testing::Message() << i); 255 SCOPED_TRACE(testing::Message() << i);
244 if (i == 5) 256 if (i == 5)
245 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status()); 257 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status());
246 else 258 else
247 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 259 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
248 } 260 }
249 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698