Add test for creating bitmap from cursor

This commit is contained in:
Igor Korot 2020-08-08 18:34:31 +02:00 committed by Maarten Bent
parent 9394d26c40
commit 0c82830a5d
2 changed files with 34 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#endif // WX_PRECOMP
#include "wx/anidecod.h" // wxImageArray
#include "wx/bitmap.h"
#include "wx/palette.h"
#include "wx/url.h"
#include "wx/log.h"
@ -82,6 +83,7 @@ private:
CPPUNIT_TEST( DibPadding );
CPPUNIT_TEST( BMPFlippingAndRLECompression );
CPPUNIT_TEST( ScaleCompare );
CPPUNIT_TEST( CreateBitmapFromCursor );
CPPUNIT_TEST_SUITE_END();
void LoadFromSocketStream();
@ -102,6 +104,7 @@ private:
void DibPadding();
void BMPFlippingAndRLECompression();
void ScaleCompare();
void CreateBitmapFromCursor();
wxDECLARE_NO_COPY_CLASS(ImageTestCase);
};
@ -1451,6 +1454,37 @@ void ImageTestCase::ScaleCompare()
"image/cross_nearest_neighb_256x256.png");
}
const unsigned char toucan[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0xc0, 0x00,
0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00,
0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x08, 0xf8, 0x00, 0x00, 0x58, 0xf8, 0x00, 0x00,
0x2f, 0xf8, 0x00, 0x00, 0x50, 0x78, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0x61, 0x80, 0x00, 0x00,
0x7b, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0d, 0x20, 0x00, 0x00,
0x48, 0x10, 0x00, 0x00, 0x50, 0x80, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void ImageTestCase::CreateBitmapFromCursor()
{
#if !defined __WXOSX_IPHONE__ && !defined __WXDFB__ && !defined __WXMOTIF__ && !defined __WXX11__
#ifdef __WXMSW__
wxImage image( 32, 32, toucan );
#else
wxImage image( "../../samples/image/toucan.png" );
#endif
wxCursor cursor( image );
wxBitmap bitmap( cursor );
if( bitmap.IsOk() )
#ifdef __WXOSX__
CHECK_THAT( image, RGBSimilarTo( bitmap.ConvertToImage(), 2 ) );
#else
CHECK_THAT( image, RGBSameAs( bitmap.ConvertToImage() ) );
#endif
#endif
}
#endif //wxUSE_IMAGE
TEST_CASE("wxImage::Paste", "[image][paste]")

BIN
tests/image/toucan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB