Source/core/frame/ImageBitmapTest.cpp
// Verifies that the image resource held by an ImageBitmap is the same as the
// one held by the HTMLImageElement.
Verifies that the image resource held by an ImageBitmap is the same as the
one held by the HTMLImageElement.
Verifies that the image resource held by an ImageBitmap is the same as the one held by the HTMLImageElement .
TEST_F(ImageBitmapTest, ImageResourceConsistency)
{
    RefPtrWillBeRawPtr<HTMLImageElement> imageElement = HTMLImageElement::create(*Document::create().get());
    imageElement->setImageResource(new ImageResource(BitmapImage::create(NativeImageSkia::create(m_bitmap)).get()));
    RefPtrWillBeRawPtr<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create(imageElement.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height()));
    RefPtrWillBeRawPtr<ImageBitmap> imageBitmapInteriorCrop = ImageBitmap::create(imageElement.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width() / 2, m_bitmap.height() / 2));
    RefPtrWillBeRawPtr<ImageBitmap> imageBitmapExteriorCrop = ImageBitmap::create(imageElement.get(), IntRect(-m_bitmap.width() / 2, -m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
    RefPtrWillBeRawPtr<ImageBitmap> imageBitmapOutsideCrop = ImageBitmap::create(imageElement.get(), IntRect(-m_bitmap.width(), -m_bitmap.height(), m_bitmap.width(), m_bitmap.height()));
    ASSERT_EQ(imageBitmapNoCrop->bitmapImage().get(), imageElement->cachedImage()->image());
    ASSERT_EQ(imageBitmapInteriorCrop->bitmapImage().get(), imageElement->cachedImage()->image());
    ASSERT_EQ(imageBitmapExteriorCrop->bitmapImage().get(), imageElement->cachedImage()->image());
    RefPtr<Image> emptyImage = imageBitmapOutsideCrop->bitmapImage();
    ASSERT_NE(emptyImage.get(), imageElement->cachedImage()->image());
}
TEST_F ( ImageBitmapTest , ImageResourceConsistency ) { RefPtrWillBeRawPtr < HTMLImageElement > imageElement = HTMLImageElement :: create ( * Document :: create ( ) . get ( ) ) ; imageElement -> setImageResource ( new ImageResource ( BitmapImage :: create ( NativeImageSkia :: create ( m_bitmap ) ) . get ( ) ) ) ; RefPtrWillBeRawPtr < ImageBitmap > imageBitmapNoCrop = ImageBitmap :: create ( imageElement . get ( ) , IntRect ( 0 , 0 , m_bitmap . width ( ) , m_bitmap . height ( ) ) ) ; RefPtrWillBeRawPtr < ImageBitmap > imageBitmapInteriorCrop = ImageBitmap :: create ( imageElement . get ( ) , IntRect ( m_bitmap . width ( ) / 2 , m_bitmap . height ( ) / 2 , m_bitmap . width ( ) / 2 , m_bitmap . height ( ) / 2 ) ) ; RefPtrWillBeRawPtr < ImageBitmap > imageBitmapExteriorCrop = ImageBitmap :: create ( imageElement . get ( ) , IntRect ( - m_bitmap . width ( ) / 2 , - m_bitmap . height ( ) / 2 , m_bitmap . width ( ) , m_bitmap . height ( ) ) ) ; RefPtrWillBeRawPtr < ImageBitmap > imageBitmapOutsideCrop = ImageBitmap :: create ( imageElement . get ( ) , IntRect ( - m_bitmap . width ( ) , - m_bitmap . height ( ) , m_bitmap . width ( ) , m_bitmap . height ( ) ) ) ; ASSERT_EQ ( imageBitmapNoCrop -> bitmapImage ( ) . get ( ) , imageElement -> cachedImage ( ) -> image ( ) ) ; ASSERT_EQ ( imageBitmapInteriorCrop -> bitmapImage ( ) . get ( ) , imageElement -> cachedImage ( ) -> image ( ) ) ; ASSERT_EQ ( imageBitmapExteriorCrop -> bitmapImage ( ) . get ( ) , imageElement -> cachedImage ( ) -> image ( ) ) ; RefPtr < Image > emptyImage = imageBitmapOutsideCrop -> bitmapImage ( ) ; ASSERT_NE ( emptyImage . get ( ) , imageElement -> cachedImage ( ) -> image ( ) ) ; }
Verifies that the image resource held by an ImageBitmap is the same as the
one held by the HTMLImageElement.
Verifies that the image resource held by an ImageBitmap is the same as the one held by the HTMLImageElement .