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

Side by Side Diff: Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp

Issue 47623002: Fix more warnings on linux (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix RenderImage.cpp. Created 7 years, 1 month 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecode) 195 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecode)
196 { 196 {
197 setFrameStatus(ImageFrame::FramePartial); 197 setFrameStatus(ImageFrame::FramePartial);
198 198
199 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(fullSize() ); 199 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(fullSize() );
200 EXPECT_FALSE(tempImage->isComplete()); 200 EXPECT_FALSE(tempImage->isComplete());
201 EXPECT_EQ(1, m_frameBufferRequestCount); 201 EXPECT_EQ(1, m_frameBufferRequestCount);
202 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 202 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
203 EXPECT_EQ(2u, ImageDecodingStore::instance()->cacheEntries()); 203 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries());
204 EXPECT_EQ(1u, ImageDecodingStore::instance()->imageCacheEntries()); 204 EXPECT_EQ(1, ImageDecodingStore::instance()->imageCacheEntries());
205 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 205 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
206 206
207 addNewData(); 207 addNewData();
208 tempImage = m_generator->decodeAndScale(fullSize()); 208 tempImage = m_generator->decodeAndScale(fullSize());
209 EXPECT_FALSE(tempImage->isComplete()); 209 EXPECT_FALSE(tempImage->isComplete());
210 EXPECT_EQ(2, m_frameBufferRequestCount); 210 EXPECT_EQ(2, m_frameBufferRequestCount);
211 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 211 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
212 EXPECT_EQ(3u, ImageDecodingStore::instance()->cacheEntries()); 212 EXPECT_EQ(3, ImageDecodingStore::instance()->cacheEntries());
213 EXPECT_EQ(2u, ImageDecodingStore::instance()->imageCacheEntries()); 213 EXPECT_EQ(2, ImageDecodingStore::instance()->imageCacheEntries());
214 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 214 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
215 EXPECT_EQ(0, m_decodersDestroyed); 215 EXPECT_EQ(0, m_decodersDestroyed);
216 } 216 }
217 217
218 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecodeAndScale) 218 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecodeAndScale)
219 { 219 {
220 setFrameStatus(ImageFrame::FramePartial); 220 setFrameStatus(ImageFrame::FramePartial);
221 221
222 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(scaledSize ()); 222 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(scaledSize ());
223 EXPECT_FALSE(tempImage->isComplete()); 223 EXPECT_FALSE(tempImage->isComplete());
224 EXPECT_EQ(1, m_frameBufferRequestCount); 224 EXPECT_EQ(1, m_frameBufferRequestCount);
225 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 225 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
226 EXPECT_EQ(3u, ImageDecodingStore::instance()->cacheEntries()); 226 EXPECT_EQ(3, ImageDecodingStore::instance()->cacheEntries());
227 EXPECT_EQ(2u, ImageDecodingStore::instance()->imageCacheEntries()); 227 EXPECT_EQ(2, ImageDecodingStore::instance()->imageCacheEntries());
228 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 228 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
229 229
230 addNewData(); 230 addNewData();
231 tempImage = m_generator->decodeAndScale(scaledSize()); 231 tempImage = m_generator->decodeAndScale(scaledSize());
232 EXPECT_FALSE(tempImage->isComplete()); 232 EXPECT_FALSE(tempImage->isComplete());
233 EXPECT_EQ(2, m_frameBufferRequestCount); 233 EXPECT_EQ(2, m_frameBufferRequestCount);
234 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 234 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
235 EXPECT_EQ(5u, ImageDecodingStore::instance()->cacheEntries()); 235 EXPECT_EQ(5, ImageDecodingStore::instance()->cacheEntries());
236 EXPECT_EQ(4u, ImageDecodingStore::instance()->imageCacheEntries()); 236 EXPECT_EQ(4, ImageDecodingStore::instance()->imageCacheEntries());
237 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 237 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
238 EXPECT_EQ(0, m_decodersDestroyed); 238 EXPECT_EQ(0, m_decodersDestroyed);
239 } 239 }
240 240
241 TEST_F(ImageFrameGeneratorTest, incompleteDecodeBecomesComplete) 241 TEST_F(ImageFrameGeneratorTest, incompleteDecodeBecomesComplete)
242 { 242 {
243 setFrameStatus(ImageFrame::FramePartial); 243 setFrameStatus(ImageFrame::FramePartial);
244 244
245 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize( )); 245 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize( ));
246 EXPECT_FALSE(tempImage->isComplete()); 246 EXPECT_FALSE(tempImage->isComplete());
247 EXPECT_EQ(1, m_frameBufferRequestCount); 247 EXPECT_EQ(1, m_frameBufferRequestCount);
248 EXPECT_EQ(0, m_decodersDestroyed); 248 EXPECT_EQ(0, m_decodersDestroyed);
249 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 249 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
250 EXPECT_EQ(2u, ImageDecodingStore::instance()->cacheEntries()); 250 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries());
251 EXPECT_EQ(1u, ImageDecodingStore::instance()->imageCacheEntries()); 251 EXPECT_EQ(1, ImageDecodingStore::instance()->imageCacheEntries());
252 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 252 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
253 253
254 setFrameStatus(ImageFrame::FrameComplete); 254 setFrameStatus(ImageFrame::FrameComplete);
255 addNewData(); 255 addNewData();
256 256
257 tempImage = m_generator->decodeAndScale(fullSize()); 257 tempImage = m_generator->decodeAndScale(fullSize());
258 EXPECT_TRUE(tempImage->isComplete()); 258 EXPECT_TRUE(tempImage->isComplete());
259 EXPECT_EQ(2, m_frameBufferRequestCount); 259 EXPECT_EQ(2, m_frameBufferRequestCount);
260 EXPECT_EQ(1, m_decodersDestroyed); 260 EXPECT_EQ(1, m_decodersDestroyed);
261 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 261 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
262 EXPECT_EQ(2u, ImageDecodingStore::instance()->cacheEntries()); 262 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries());
263 EXPECT_EQ(2u, ImageDecodingStore::instance()->imageCacheEntries()); 263 EXPECT_EQ(2, ImageDecodingStore::instance()->imageCacheEntries());
264 EXPECT_EQ(0u, ImageDecodingStore::instance()->decoderCacheEntries()); 264 EXPECT_EQ(0, ImageDecodingStore::instance()->decoderCacheEntries());
265 265
266 tempImage = m_generator->decodeAndScale(fullSize()); 266 tempImage = m_generator->decodeAndScale(fullSize());
267 EXPECT_TRUE(tempImage->isComplete()); 267 EXPECT_TRUE(tempImage->isComplete());
268 EXPECT_EQ(2, m_frameBufferRequestCount); 268 EXPECT_EQ(2, m_frameBufferRequestCount);
269 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 269 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
270 } 270 }
271 271
272 TEST_F(ImageFrameGeneratorTest, incompleteDecodeAndScaleBecomesComplete) 272 TEST_F(ImageFrameGeneratorTest, incompleteDecodeAndScaleBecomesComplete)
273 { 273 {
274 setFrameStatus(ImageFrame::FramePartial); 274 setFrameStatus(ImageFrame::FramePartial);
275 275
276 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSiz e()); 276 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSiz e());
277 EXPECT_FALSE(tempImage->isComplete()); 277 EXPECT_FALSE(tempImage->isComplete());
278 EXPECT_EQ(1, m_frameBufferRequestCount); 278 EXPECT_EQ(1, m_frameBufferRequestCount);
279 EXPECT_EQ(0, m_decodersDestroyed); 279 EXPECT_EQ(0, m_decodersDestroyed);
280 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 280 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
281 EXPECT_EQ(3u, ImageDecodingStore::instance()->cacheEntries()); 281 EXPECT_EQ(3, ImageDecodingStore::instance()->cacheEntries());
282 EXPECT_EQ(2u, ImageDecodingStore::instance()->imageCacheEntries()); 282 EXPECT_EQ(2, ImageDecodingStore::instance()->imageCacheEntries());
283 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 283 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
284 284
285 setFrameStatus(ImageFrame::FrameComplete); 285 setFrameStatus(ImageFrame::FrameComplete);
286 addNewData(); 286 addNewData();
287 287
288 tempImage = m_generator->decodeAndScale(scaledSize()); 288 tempImage = m_generator->decodeAndScale(scaledSize());
289 EXPECT_TRUE(tempImage->isComplete()); 289 EXPECT_TRUE(tempImage->isComplete());
290 EXPECT_EQ(2, m_frameBufferRequestCount); 290 EXPECT_EQ(2, m_frameBufferRequestCount);
291 EXPECT_EQ(1, m_decodersDestroyed); 291 EXPECT_EQ(1, m_decodersDestroyed);
292 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 292 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
293 EXPECT_EQ(4u, ImageDecodingStore::instance()->cacheEntries()); 293 EXPECT_EQ(4, ImageDecodingStore::instance()->cacheEntries());
294 EXPECT_EQ(4u, ImageDecodingStore::instance()->imageCacheEntries()); 294 EXPECT_EQ(4, ImageDecodingStore::instance()->imageCacheEntries());
295 EXPECT_EQ(0u, ImageDecodingStore::instance()->decoderCacheEntries()); 295 EXPECT_EQ(0, ImageDecodingStore::instance()->decoderCacheEntries());
296 296
297 tempImage = m_generator->decodeAndScale(scaledSize()); 297 tempImage = m_generator->decodeAndScale(scaledSize());
298 EXPECT_TRUE(tempImage->isComplete()); 298 EXPECT_TRUE(tempImage->isComplete());
299 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 299 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
300 300
301 tempImage = m_generator->decodeAndScale(fullSize()); 301 tempImage = m_generator->decodeAndScale(fullSize());
302 EXPECT_TRUE(tempImage->isComplete()); 302 EXPECT_TRUE(tempImage->isComplete());
303 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 303 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
304 304
305 EXPECT_EQ(2, m_frameBufferRequestCount); 305 EXPECT_EQ(2, m_frameBufferRequestCount);
306 } 306 }
307 307
308 static void decodeThreadMain(ImageFrameGenerator* generator) 308 static void decodeThreadMain(ImageFrameGenerator* generator)
309 { 309 {
310 const ScaledImageFragment* tempImage = generator->decodeAndScale(fullSize()) ; 310 const ScaledImageFragment* tempImage = generator->decodeAndScale(fullSize()) ;
311 ImageDecodingStore::instance()->unlockCache(generator, tempImage); 311 ImageDecodingStore::instance()->unlockCache(generator, tempImage);
312 } 312 }
313 313
314 TEST_F(ImageFrameGeneratorTest, incompleteDecodeBecomesCompleteMultiThreaded) 314 TEST_F(ImageFrameGeneratorTest, incompleteDecodeBecomesCompleteMultiThreaded)
315 { 315 {
316 setFrameStatus(ImageFrame::FramePartial); 316 setFrameStatus(ImageFrame::FramePartial);
317 317
318 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize( )); 318 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize( ));
319 EXPECT_FALSE(tempImage->isComplete()); 319 EXPECT_FALSE(tempImage->isComplete());
320 EXPECT_EQ(1, m_frameBufferRequestCount); 320 EXPECT_EQ(1, m_frameBufferRequestCount);
321 EXPECT_EQ(0, m_decodersDestroyed); 321 EXPECT_EQ(0, m_decodersDestroyed);
322 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 322 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
323 EXPECT_EQ(2u, ImageDecodingStore::instance()->cacheEntries()); 323 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries());
324 EXPECT_EQ(1u, ImageDecodingStore::instance()->imageCacheEntries()); 324 EXPECT_EQ(1, ImageDecodingStore::instance()->imageCacheEntries());
325 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 325 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
326 326
327 // Frame can now be decoded completely. 327 // Frame can now be decoded completely.
328 setFrameStatus(ImageFrame::FrameComplete); 328 setFrameStatus(ImageFrame::FrameComplete);
329 addNewData(); 329 addNewData();
330 OwnPtr<WebKit::WebThread> thread = adoptPtr(WebKit::Platform::current()->cre ateThread("DecodeThread")); 330 OwnPtr<WebKit::WebThread> thread = adoptPtr(WebKit::Platform::current()->cre ateThread("DecodeThread"));
331 thread->postTask(new Task(WTF::bind(&decodeThreadMain, m_generator.get()))); 331 thread->postTask(new Task(WTF::bind(&decodeThreadMain, m_generator.get())));
332 thread.clear(); 332 thread.clear();
333 333
334 EXPECT_EQ(2, m_frameBufferRequestCount); 334 EXPECT_EQ(2, m_frameBufferRequestCount);
335 EXPECT_EQ(1, m_decodersDestroyed); 335 EXPECT_EQ(1, m_decodersDestroyed);
336 EXPECT_EQ(2u, ImageDecodingStore::instance()->cacheEntries()); 336 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries());
337 EXPECT_EQ(2u, ImageDecodingStore::instance()->imageCacheEntries()); 337 EXPECT_EQ(2, ImageDecodingStore::instance()->imageCacheEntries());
338 EXPECT_EQ(0u, ImageDecodingStore::instance()->decoderCacheEntries()); 338 EXPECT_EQ(0, ImageDecodingStore::instance()->decoderCacheEntries());
339 339
340 tempImage = m_generator->decodeAndScale(fullSize()); 340 tempImage = m_generator->decodeAndScale(fullSize());
341 EXPECT_TRUE(tempImage->isComplete()); 341 EXPECT_TRUE(tempImage->isComplete());
342 EXPECT_EQ(2, m_frameBufferRequestCount); 342 EXPECT_EQ(2, m_frameBufferRequestCount);
343 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 343 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
344 } 344 }
345 345
346 TEST_F(ImageFrameGeneratorTest, concurrentIncompleteDecodeAndScale) 346 TEST_F(ImageFrameGeneratorTest, concurrentIncompleteDecodeAndScale)
347 { 347 {
348 setFrameStatus(ImageFrame::FramePartial); 348 setFrameStatus(ImageFrame::FramePartial);
349 349
350 const ScaledImageFragment* fullImage = m_generator->decodeAndScale(fullSize( )); 350 const ScaledImageFragment* fullImage = m_generator->decodeAndScale(fullSize( ));
351 const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledS ize()); 351 const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledS ize());
352 EXPECT_FALSE(fullImage->isComplete()); 352 EXPECT_FALSE(fullImage->isComplete());
353 EXPECT_FALSE(scaledImage->isComplete()); 353 EXPECT_FALSE(scaledImage->isComplete());
354 EXPECT_EQ(2, m_frameBufferRequestCount); 354 EXPECT_EQ(2, m_frameBufferRequestCount);
355 ImageDecodingStore::instance()->unlockCache(m_generator.get(), fullImage); 355 ImageDecodingStore::instance()->unlockCache(m_generator.get(), fullImage);
356 ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage); 356 ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
357 EXPECT_EQ(4u, ImageDecodingStore::instance()->cacheEntries()); 357 EXPECT_EQ(4, ImageDecodingStore::instance()->cacheEntries());
358 EXPECT_EQ(3u, ImageDecodingStore::instance()->imageCacheEntries()); 358 EXPECT_EQ(3, ImageDecodingStore::instance()->imageCacheEntries());
359 EXPECT_EQ(1u, ImageDecodingStore::instance()->decoderCacheEntries()); 359 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries());
360 EXPECT_EQ(0, m_decodersDestroyed); 360 EXPECT_EQ(0, m_decodersDestroyed);
361 361
362 addNewData(); 362 addNewData();
363 setFrameStatus(ImageFrame::FrameComplete); 363 setFrameStatus(ImageFrame::FrameComplete);
364 scaledImage = m_generator->decodeAndScale(scaledSize()); 364 scaledImage = m_generator->decodeAndScale(scaledSize());
365 EXPECT_TRUE(scaledImage->isComplete()); 365 EXPECT_TRUE(scaledImage->isComplete());
366 EXPECT_EQ(3, m_frameBufferRequestCount); 366 EXPECT_EQ(3, m_frameBufferRequestCount);
367 ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage); 367 ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
368 EXPECT_EQ(5u, ImageDecodingStore::instance()->cacheEntries()); 368 EXPECT_EQ(5, ImageDecodingStore::instance()->cacheEntries());
369 EXPECT_EQ(5u, ImageDecodingStore::instance()->imageCacheEntries()); 369 EXPECT_EQ(5, ImageDecodingStore::instance()->imageCacheEntries());
370 EXPECT_EQ(0u, ImageDecodingStore::instance()->decoderCacheEntries()); 370 EXPECT_EQ(0, ImageDecodingStore::instance()->decoderCacheEntries());
371 EXPECT_EQ(1, m_decodersDestroyed); 371 EXPECT_EQ(1, m_decodersDestroyed);
372 } 372 }
373 373
374 TEST_F(ImageFrameGeneratorTest, incompleteBitmapCopied) 374 TEST_F(ImageFrameGeneratorTest, incompleteBitmapCopied)
375 { 375 {
376 setFrameStatus(ImageFrame::FramePartial); 376 setFrameStatus(ImageFrame::FramePartial);
377 377
378 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(fullSize() ); 378 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(fullSize() );
379 EXPECT_FALSE(tempImage->isComplete()); 379 EXPECT_FALSE(tempImage->isComplete());
380 EXPECT_EQ(1, m_frameBufferRequestCount); 380 EXPECT_EQ(1, m_frameBufferRequestCount);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // We have tested failures of all stages. This time all allocations 460 // We have tested failures of all stages. This time all allocations
461 // were successful. 461 // were successful.
462 EXPECT_TRUE(image); 462 EXPECT_TRUE(image);
463 break; 463 break;
464 } 464 }
465 EXPECT_FALSE(image); 465 EXPECT_FALSE(image);
466 } 466 }
467 } 467 }
468 468
469 } // namespace WebCore 469 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698