Passing alpha to DeferredImageDecoder once decoding completes
[WebKit-https.git] / Source / WebKit / chromium / tests / ImageFrameGeneratorTest.cpp
index b4169a139bae3b63997c14a0ce84484b5e9b5116..113d78816ed1d912eb51368a7a8ff81882215f39 100644 (file)
@@ -124,6 +124,7 @@ PassOwnPtr<ImageDecoder> MockImageDecoderFactory::create()
 {
     OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_test);
     decoder->setSize(fullSize().width(), fullSize().height());
+    decoder->setFrameHasAlpha(false);
     return decoder.release();
 }
 
@@ -137,6 +138,7 @@ TEST_F(ImageFrameGeneratorTest, cacheHit)
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize());
     EXPECT_EQ(fullImage, tempImage);
     EXPECT_EQ(fullSize(), tempImage->scaledSize());
+    EXPECT_TRUE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(0, m_frameBufferRequestCount);
 }
@@ -152,12 +154,14 @@ TEST_F(ImageFrameGeneratorTest, cacheMissWithScale)
     const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_NE(fullImage, scaledImage);
     EXPECT_EQ(scaledSize(), scaledImage->scaledSize());
+    EXPECT_TRUE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
 
     // Cache hit.
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(scaledImage, tempImage);
     EXPECT_EQ(scaledSize(), tempImage->scaledSize());
+    EXPECT_TRUE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(0, m_frameBufferRequestCount);
 }
@@ -170,6 +174,7 @@ TEST_F(ImageFrameGeneratorTest, cacheMissWithDecodeAndScale)
     const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(1, m_frameBufferRequestCount);
     EXPECT_EQ(scaledSize(), scaledImage->scaledSize());
+    EXPECT_FALSE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
     EXPECT_EQ(1, m_decodersDestroyed);
 
@@ -177,12 +182,14 @@ TEST_F(ImageFrameGeneratorTest, cacheMissWithDecodeAndScale)
     const ScaledImageFragment* fullImage = m_generator->decodeAndScale(fullSize());
     EXPECT_NE(scaledImage, fullImage);
     EXPECT_EQ(fullSize(), fullImage->scaledSize());
+    EXPECT_FALSE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), fullImage);
 
     // Cache hit.
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(scaledImage, tempImage);
     EXPECT_EQ(scaledSize(), tempImage->scaledSize());
+    EXPECT_FALSE(m_generator->hasAlpha());
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(1, m_frameBufferRequestCount);
 }