diff options
author | Thorsten Behrens <thb@openoffice.org> | 2006-05-31 08:49:45 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2006-05-31 08:49:45 +0000 |
commit | ef0bbaaf42d5d1784ab158d1b6b0535459702823 (patch) | |
tree | 89fa01c3069b3fc4f3afbe8850b001c755b8e787 /basebmp/test/basictest.cxx | |
parent | c16e3ab6fba4dc9a7217c97b198a801dcca94ee0 (diff) |
#i65904# Initial revision
Diffstat (limited to 'basebmp/test/basictest.cxx')
-rw-r--r-- | basebmp/test/basictest.cxx | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx new file mode 100644 index 000000000000..ef819c81ab6e --- /dev/null +++ b/basebmp/test/basictest.cxx @@ -0,0 +1,133 @@ +// 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; + |