office-gobmx/basebmp/test/basictest.cxx

134 lines
5 KiB
C++
Raw Normal View History

2006-05-31 03:49:45 -05:00
// autogenerated file with codegen.pl
#include <cppunit/simpleheader.hxx>
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/point/b2ipoint.hxx>
#include <basebmp/color.hxx>
#include <basebmp/scanlineformats.hxx>
#include <basebmp/bitmapdevice.hxx>
using namespace ::basebmp;
namespace
{
class BasicTest : public CppUnit::TestFixture
{
public:
void testConstruction()
{
const basegfx::B2ISize aSize(101,101);
basegfx::B2ISize aSize2(aSize);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
true,
Format::ONE_BIT_MSB_PAL ));
CPPUNIT_ASSERT_MESSAGE("right size",
pDevice->getSize() == aSize2 );
CPPUNIT_ASSERT_MESSAGE("Top down format",
pDevice->isTopDown() == true );
CPPUNIT_ASSERT_MESSAGE("Scanline format",
pDevice->getScanlineFormat() == Format::ONE_BIT_MSB_PAL );
CPPUNIT_ASSERT_MESSAGE("Scanline len",
pDevice->getScanlineStride() == (aSize2.getY() + 7)/8 );
}
void testPixelFuncs()
{
// 1bpp
const basegfx::B2ISize aSize(101,101);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
true,
Format::ONE_BIT_MSB_PAL ));
const basegfx::B2IPoint aPt(3,3);
const Color aCol(0xFFFFFFFF);
pDevice->setPixel( aPt, aCol, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #1",
pDevice->getPixel(aPt) == aCol);
const basegfx::B2IPoint aPt2(0,0);
const Color aCol2(0xFFFFFFFF);
pDevice->setPixel( aPt2, aCol2, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #2",
pDevice->getPixel(aPt2) == aCol2);
const basegfx::B2IPoint aPt3(aSize.getX()-1,aSize.getY()-1);
const Color aCol3(0x00000000);
pDevice->setPixel( aPt3, aCol3, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #3",
pDevice->getPixel(aPt3) == aCol3);
const basegfx::B2IPoint aPt4(-100000,-100000);
pDevice->setPixel( aPt4, aCol3, DrawMode_PAINT );
const basegfx::B2IPoint aPt5(100000,100000);
pDevice->setPixel( aPt5, aCol3, DrawMode_PAINT );
// 8bpp
{
pDevice = createBitmapDevice( aSize,
true,
Format::EIGHT_BIT_TC_MASK );
const Color aCol4(0x01);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #4",
pDevice->getPixel(aPt) == aCol4);
const Color aCol5(0x0F);
pDevice->setPixel( aPt2, aCol5, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #5",
pDevice->getPixel(aPt2) == aCol5);
const Color aCol6(0xFF);
pDevice->setPixel( aPt3, aCol6, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #6",
pDevice->getPixel(aPt3) == aCol6);
}
// 32bpp
{
pDevice = createBitmapDevice( aSize,
true,
Format::THIRTYTWO_BIT_TC_MASK );
const Color aCol4(0x01010101);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #7",
pDevice->getPixel(aPt) == aCol4);
const Color aCol5(0x0F0F0F0F);
pDevice->setPixel( aPt2, aCol5, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #8",
pDevice->getPixel(aPt2) == aCol5);
const Color aCol6(0xFFFFFFFF);
pDevice->setPixel( aPt3, aCol6, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #9",
pDevice->getPixel(aPt3) == aCol6);
}
}
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
CPPUNIT_TEST_SUITE(BasicTest);
CPPUNIT_TEST(testConstruction);
CPPUNIT_TEST(testPixelFuncs);
CPPUNIT_TEST_SUITE_END();
};
// -----------------------------------------------------------------------------
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicTest, "BasicTest");
}
// -----------------------------------------------------------------------------
// this macro creates an empty function, which will called by the RegisterAllFunctions()
// to let the user the possibility to also register some functions by hand.
NOADDITIONAL;