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

Side by Side Diff: Source/platform/graphics/ImageFrameGeneratorTest.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 | « no previous file | Source/platform/image-decoders/ImageDecoder.cpp » ('j') | 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) 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); 399 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
400 400
401 setFrameStatus(ImageFrame::FrameEmpty); 401 setFrameStatus(ImageFrame::FrameEmpty);
402 setNextFrameStatus(ImageFrame::FrameComplete); 402 setNextFrameStatus(ImageFrame::FrameComplete);
403 EXPECT_FALSE(m_generator->decodeAndScale(fullSize(), 1)); 403 EXPECT_FALSE(m_generator->decodeAndScale(fullSize(), 1));
404 } 404 }
405 405
406 TEST_F(ImageFrameGeneratorTest, frameHasAlpha) 406 TEST_F(ImageFrameGeneratorTest, frameHasAlpha)
407 { 407 {
408 setFrameStatus(ImageFrame::FramePartial); 408 setFrameStatus(ImageFrame::FramePartial);
409 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 0)); 409 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1));
410 EXPECT_TRUE(m_generator->hasAlpha(0)); 410 EXPECT_TRUE(m_generator->hasAlpha(1));
411 411
412 ImageDecoder* tempDecoder = 0; 412 ImageDecoder* tempDecoder = 0;
413 EXPECT_TRUE(ImageDecodingStore::instance()->lockDecoder(m_generator.get(), f ullSize(), &tempDecoder)); 413 EXPECT_TRUE(ImageDecodingStore::instance()->lockDecoder(m_generator.get(), f ullSize(), &tempDecoder));
414 ASSERT_TRUE(tempDecoder); 414 ASSERT_TRUE(tempDecoder);
415 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); 415 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false);
416 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder ); 416 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder );
417 417
418 setFrameStatus(ImageFrame::FrameComplete); 418 setFrameStatus(ImageFrame::FrameComplete);
419 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 0)); 419 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1));
420 EXPECT_FALSE(m_generator->hasAlpha(0)); 420 EXPECT_FALSE(m_generator->hasAlpha(1));
421 } 421 }
422 422
423 namespace { 423 namespace {
424 424
425 class MockAllocator : public SkBitmap::Allocator { 425 class MockAllocator : public SkBitmap::Allocator {
426 public: 426 public:
427 // N starts from 0. 427 // N starts from 0.
428 MockAllocator(int failAtNthCall) 428 MockAllocator(int failAtNthCall)
429 : m_callCount(0) 429 : m_callCount(0)
430 , m_failAtNthCall(failAtNthCall) 430 , m_failAtNthCall(failAtNthCall)
(...skipping 30 matching lines...) Expand all
461 // We have tested failures of all stages. This time all allocations 461 // We have tested failures of all stages. This time all allocations
462 // were successful. 462 // were successful.
463 EXPECT_TRUE(image); 463 EXPECT_TRUE(image);
464 break; 464 break;
465 } 465 }
466 EXPECT_FALSE(image); 466 EXPECT_FALSE(image);
467 } 467 }
468 } 468 }
469 469
470 } // namespace WebCore 470 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/platform/image-decoders/ImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698