summaryrefslogtreecommitdiff
path: root/basebmp/test/filltest.cxx
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2006-05-31 08:49:45 +0000
committerThorsten Behrens <thb@openoffice.org>2006-05-31 08:49:45 +0000
commitef0bbaaf42d5d1784ab158d1b6b0535459702823 (patch)
tree89fa01c3069b3fc4f3afbe8850b001c755b8e787 /basebmp/test/filltest.cxx
parentc16e3ab6fba4dc9a7217c97b198a801dcca94ee0 (diff)
#i65904# Initial revision
Diffstat (limited to 'basebmp/test/filltest.cxx')
-rw-r--r--basebmp/test/filltest.cxx113
1 files changed, 113 insertions, 0 deletions
diff --git a/basebmp/test/filltest.cxx b/basebmp/test/filltest.cxx
new file mode 100644
index 000000000000..8a458cac573f
--- /dev/null
+++ b/basebmp/test/filltest.cxx
@@ -0,0 +1,113 @@
+// autogenerated file with codegen.pl
+
+#include <cppunit/simpleheader.hxx>
+
+#include <basegfx/vector/b2isize.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include <basebmp/color.hxx>
+#include <basebmp/scanlineformats.hxx>
+#include <basebmp/bitmapdevice.hxx>
+#include <basebmp/debug.hxx>
+
+#include <iostream>
+#include <fstream>
+
+using namespace ::basebmp;
+
+namespace
+{
+/*
+ std::ofstream output("32bpp_test.dump");
+ debugDump( mpDevice32bpp, output );
+*/
+
+class FillTest : public CppUnit::TestFixture
+{
+private:
+ BitmapDeviceSharedPtr mpDevice1bpp;
+ BitmapDeviceSharedPtr mpDevice32bpp;
+
+ int countPixel( const BitmapDeviceSharedPtr& rDevice,
+ Color checkColor ) const
+ {
+ int count(0);
+ const basegfx::B2ISize& rSize( rDevice->getSize() );
+ for( sal_Int32 y=0; y<rSize.getY(); ++y )
+ for( sal_Int32 x=0; x<rSize.getX(); ++x )
+ if( rDevice->getPixel( basegfx::B2IPoint(x,y) ) == checkColor )
+ ++count;
+
+ return count;
+ }
+
+ void implTestRectFill(const BitmapDeviceSharedPtr& rDevice)
+ {
+ rDevice->clear(Color(0));
+
+ const basegfx::B2DRange aRect(1,1,10,10);
+ const basegfx::B2DPolygon aRectPoly(
+ basegfx::tools::createPolygonFromRect( aRect ));
+
+ const Color aCol(0xFFFFFFFF);
+ rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(aRectPoly),
+ aCol,
+ DrawMode_PAINT );
+ const basegfx::B2IPoint aPt1(1,1);
+ CPPUNIT_ASSERT_MESSAGE("first pixel set",
+ rDevice->getPixel(aPt1) == aCol);
+ const basegfx::B2IPoint aPt2(9,9);
+ CPPUNIT_ASSERT_MESSAGE("last pixel set",
+ rDevice->getPixel(aPt2) == aCol);
+ const basegfx::B2IPoint aPt3(0,0);
+ CPPUNIT_ASSERT_MESSAGE("topmost pixel not set",
+ rDevice->getPixel(aPt3) != aCol);
+ const basegfx::B2IPoint aPt4(10,10);
+ CPPUNIT_ASSERT_MESSAGE("bottommost pixel not set",
+ rDevice->getPixel(aPt4) != aCol);
+
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 81",
+ countPixel( rDevice, aCol ) == 81);
+ }
+
+public:
+ void setUp()
+ {
+ const basegfx::B2ISize aSize(11,11);
+ mpDevice1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpDevice32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+ }
+
+ void testRectFill()
+ {
+ implTestRectFill( mpDevice1bpp );
+ implTestRectFill( mpDevice32bpp );
+ }
+
+ // 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(FillTest);
+ CPPUNIT_TEST(testRectFill);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FillTest, "FillTest");
+}
+
+
+// -----------------------------------------------------------------------------
+
+// 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;
+