polytest.cxx (69de5a4c) | polytest.cxx (97c63c1b) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22 23 24// autogenerated file with codegen.pl 25 26#include "preextstl.h" | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22 23 24// autogenerated file with codegen.pl 25 26#include "preextstl.h" |
27#include "cppunit/TestAssert.h" 28#include "cppunit/TestFixture.h" 29#include "cppunit/extensions/HelperMacros.h" | 27#include "gtest/gtest.h" |
30#include "postextstl.h" 31 32#include <basegfx/vector/b2isize.hxx> 33#include <basegfx/range/b2irange.hxx> 34#include <basegfx/point/b2ipoint.hxx> 35#include <basegfx/matrix/b2dhommatrix.hxx> 36#include <basegfx/polygon/b2dpolygon.hxx> 37#include <basegfx/polygon/b2dpolygontools.hxx> --- 13 unchanged lines hidden (view full) --- 51 52namespace 53{ 54/* 55 std::ofstream output("32bpp_test.dump"); 56 debugDump( rDevice, output ); 57*/ 58 | 28#include "postextstl.h" 29 30#include <basegfx/vector/b2isize.hxx> 31#include <basegfx/range/b2irange.hxx> 32#include <basegfx/point/b2ipoint.hxx> 33#include <basegfx/matrix/b2dhommatrix.hxx> 34#include <basegfx/polygon/b2dpolygon.hxx> 35#include <basegfx/polygon/b2dpolygontools.hxx> --- 13 unchanged lines hidden (view full) --- 49 50namespace 51{ 52/* 53 std::ofstream output("32bpp_test.dump"); 54 debugDump( rDevice, output ); 55*/ 56 |
59class PolyTest : public CppUnit::TestFixture | 57class PolyTest : public ::testing::Test |
60{ | 58{ |
61private: | 59protected: |
62 BitmapDeviceSharedPtr mpDevice1bpp; 63 BitmapDeviceSharedPtr mpDevice32bpp; 64 65 void implTestEmpty(const BitmapDeviceSharedPtr& rDevice) 66 { 67 const Color aCol(0xFFFFFFFF); 68 const Color aBgCol(0); 69 rDevice->clear(aBgCol); 70 basegfx::B2DPolyPolygon aPoly; 71 ::rtl::OUString aSvg; 72 73 basegfx::tools::importFromSvgD( 74 aPoly, 75 rtl::OUString::createFromAscii( | 60 BitmapDeviceSharedPtr mpDevice1bpp; 61 BitmapDeviceSharedPtr mpDevice32bpp; 62 63 void implTestEmpty(const BitmapDeviceSharedPtr& rDevice) 64 { 65 const Color aCol(0xFFFFFFFF); 66 const Color aBgCol(0); 67 rDevice->clear(aBgCol); 68 basegfx::B2DPolyPolygon aPoly; 69 ::rtl::OUString aSvg; 70 71 basegfx::tools::importFromSvgD( 72 aPoly, 73 rtl::OUString::createFromAscii( |
76 "M2 2 l7 7 z" ) ); | 74 "M2 2 l7 7 z" ), 75 false, NULL); |
77 rDevice->fillPolyPolygon( 78 aPoly, 79 aCol, 80 DrawMode_PAINT ); | 76 rDevice->fillPolyPolygon( 77 aPoly, 78 aCol, 79 DrawMode_PAINT ); |
81 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 0", 82 countPixel( rDevice, aCol ) == 0); | 80 ASSERT_TRUE(countPixel( rDevice, aCol ) == 0) << "number of rendered pixel is not 0"; |
83 84 // -------------------------------------------------- 85 86 rDevice->clear(aBgCol); 87 aPoly.clear(); 88 basegfx::tools::importFromSvgD( 89 aPoly, 90 rtl::OUString::createFromAscii( | 81 82 // -------------------------------------------------- 83 84 rDevice->clear(aBgCol); 85 aPoly.clear(); 86 basegfx::tools::importFromSvgD( 87 aPoly, 88 rtl::OUString::createFromAscii( |
91 "M7 2 l-6 6 z" ) ); | 89 "M7 2 l-6 6 z" ), 90 false, NULL); |
92 rDevice->fillPolyPolygon( 93 aPoly, 94 aCol, 95 DrawMode_PAINT ); | 91 rDevice->fillPolyPolygon( 92 aPoly, 93 aCol, 94 DrawMode_PAINT ); |
96 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 0(b)", 97 countPixel( rDevice, aCol ) == 0); | 95 ASSERT_TRUE(countPixel( rDevice, aCol ) == 0) << "number of rendered pixel is not 0(b)"; |
98 } 99 100 void implTestHairline(const BitmapDeviceSharedPtr& rDevice) 101 { 102 const Color aCol(0xFFFFFFFF); 103 const Color aBgCol(0); 104 rDevice->clear(aBgCol); 105 basegfx::B2DPolyPolygon aPoly; 106 ::rtl::OUString aSvg; 107 108 basegfx::tools::importFromSvgD( 109 aPoly, 110 rtl::OUString::createFromAscii( | 96 } 97 98 void implTestHairline(const BitmapDeviceSharedPtr& rDevice) 99 { 100 const Color aCol(0xFFFFFFFF); 101 const Color aBgCol(0); 102 rDevice->clear(aBgCol); 103 basegfx::B2DPolyPolygon aPoly; 104 ::rtl::OUString aSvg; 105 106 basegfx::tools::importFromSvgD( 107 aPoly, 108 rtl::OUString::createFromAscii( |
111 "M2 2 h1 l7 7 h-1 z" ) ); | 109 "M2 2 h1 l7 7 h-1 z" ), 110 false, NULL); |
112 rDevice->fillPolyPolygon( 113 aPoly, 114 aCol, 115 DrawMode_PAINT ); | 111 rDevice->fillPolyPolygon( 112 aPoly, 113 aCol, 114 DrawMode_PAINT ); |
116 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 7", 117 countPixel( rDevice, aCol ) == 7); | 115 ASSERT_TRUE(countPixel( rDevice, aCol ) == 7) << "number of rendered pixel is not 7"; |
118 119 // -------------------------------------------------- 120 121 rDevice->clear(aBgCol); 122 aPoly.clear(); 123 basegfx::tools::importFromSvgD( 124 aPoly, 125 rtl::OUString::createFromAscii( | 116 117 // -------------------------------------------------- 118 119 rDevice->clear(aBgCol); 120 aPoly.clear(); 121 basegfx::tools::importFromSvgD( 122 aPoly, 123 rtl::OUString::createFromAscii( |
126 "M7 2 h-1 l-6 6 h1 z" ) ); | 124 "M7 2 h-1 l-6 6 h1 z" ), 125 false, NULL); |
127 rDevice->fillPolyPolygon( 128 aPoly, 129 aCol, 130 DrawMode_PAINT ); | 126 rDevice->fillPolyPolygon( 127 aPoly, 128 aCol, 129 DrawMode_PAINT ); |
131 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 6", 132 countPixel( rDevice, aCol ) == 6); | 130 ASSERT_TRUE(countPixel( rDevice, aCol ) == 6) << "number of rendered pixel is not 6"; |
133 134 // -------------------------------------------------- 135 136 rDevice->clear(aBgCol); 137 aPoly.clear(); 138 basegfx::tools::importFromSvgD( 139 aPoly, 140 rtl::OUString::createFromAscii( | 131 132 // -------------------------------------------------- 133 134 rDevice->clear(aBgCol); 135 aPoly.clear(); 136 basegfx::tools::importFromSvgD( 137 aPoly, 138 rtl::OUString::createFromAscii( |
141 "M0 0 l7 7 h-1 l-5-7 z" ) ); | 139 "M0 0 l7 7 h-1 l-5-7 z" ), 140 false, NULL); |
142 rDevice->fillPolyPolygon( 143 aPoly, 144 aCol, 145 DrawMode_PAINT ); | 141 rDevice->fillPolyPolygon( 142 aPoly, 143 aCol, 144 DrawMode_PAINT ); |
146 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 3", 147 countPixel( rDevice, aCol ) == 3); | 145 ASSERT_TRUE(countPixel( rDevice, aCol ) == 3) << "number of rendered pixel is not 3"; |
148 } 149 150 void implTestPolyPoly(const BitmapDeviceSharedPtr& rDevice) 151 { 152 const Color aCol(0xFFFFFFFF); 153 const Color aBgCol(0); 154 rDevice->clear(aBgCol); 155 basegfx::B2DPolyPolygon aPoly; 156 ::rtl::OUString aSvg; 157 158 basegfx::tools::importFromSvgD( aPoly, 159 ::rtl::OUString::createFromAscii( | 146 } 147 148 void implTestPolyPoly(const BitmapDeviceSharedPtr& rDevice) 149 { 150 const Color aCol(0xFFFFFFFF); 151 const Color aBgCol(0); 152 rDevice->clear(aBgCol); 153 basegfx::B2DPolyPolygon aPoly; 154 ::rtl::OUString aSvg; 155 156 basegfx::tools::importFromSvgD( aPoly, 157 ::rtl::OUString::createFromAscii( |
160 "M0 0 h7 v7 h-7 z M2 2 v3 h3 v-3 z" ) ); | 158 "M0 0 h7 v7 h-7 z M2 2 v3 h3 v-3 z" ), 159 false, NULL ); |
161 162 rDevice->fillPolyPolygon( 163 aPoly, 164 aCol, 165 DrawMode_PAINT ); | 160 161 rDevice->fillPolyPolygon( 162 aPoly, 163 aCol, 164 DrawMode_PAINT ); |
166 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 40", 167 countPixel( rDevice, aCol ) == 40); | 165 ASSERT_TRUE(countPixel( rDevice, aCol ) == 40) << "number of rendered pixel is not 40"; |
168 } 169 170 void implTestPolyPolyClip(const BitmapDeviceSharedPtr& rDevice) 171 { 172 const Color aCol(0xFFFFFFFF); 173 const Color aBgCol(0); 174 rDevice->clear(aBgCol); 175 basegfx::B2DPolyPolygon aPoly; 176 ::rtl::OUString aSvg; 177 178 basegfx::tools::importFromSvgD( aPoly, 179 ::rtl::OUString::createFromAscii( | 166 } 167 168 void implTestPolyPolyClip(const BitmapDeviceSharedPtr& rDevice) 169 { 170 const Color aCol(0xFFFFFFFF); 171 const Color aBgCol(0); 172 rDevice->clear(aBgCol); 173 basegfx::B2DPolyPolygon aPoly; 174 ::rtl::OUString aSvg; 175 176 basegfx::tools::importFromSvgD( aPoly, 177 ::rtl::OUString::createFromAscii( |
180 "M0 0 h7 v7 h-7 z M2 2 v3 h3 v-3 z" ) ); | 178 "M0 0 h7 v7 h-7 z M2 2 v3 h3 v-3 z" ), 179 false, NULL ); |
181 basegfx::B2DHomMatrix aMat; 182 aMat.translate(-3,-3); 183 aMat.rotate( 1.7 ); 184 aMat.translate(6,5); 185 aPoly.transform(aMat); 186 187 rDevice->fillPolyPolygon( 188 aPoly, 189 aCol, 190 DrawMode_PAINT ); 191 | 180 basegfx::B2DHomMatrix aMat; 181 aMat.translate(-3,-3); 182 aMat.rotate( 1.7 ); 183 aMat.translate(6,5); 184 aPoly.transform(aMat); 185 186 rDevice->fillPolyPolygon( 187 aPoly, 188 aCol, 189 DrawMode_PAINT ); 190 |
192 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 39", 193 countPixel( rDevice, aCol ) == 39); | 191 ASSERT_TRUE(countPixel( rDevice, aCol ) == 39) << "number of rendered pixel is not 39"; |
194 195 BitmapDeviceSharedPtr pClippedDevice( 196 subsetBitmapDevice( rDevice, 197 basegfx::B2IRange(3,3,5,8) )); 198 199 rDevice->clear(aBgCol); 200 pClippedDevice->fillPolyPolygon( 201 aPoly, 202 aCol, 203 DrawMode_PAINT ); | 192 193 BitmapDeviceSharedPtr pClippedDevice( 194 subsetBitmapDevice( rDevice, 195 basegfx::B2IRange(3,3,5,8) )); 196 197 rDevice->clear(aBgCol); 198 pClippedDevice->fillPolyPolygon( 199 aPoly, 200 aCol, 201 DrawMode_PAINT ); |
204 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 7", 205 countPixel( rDevice, aCol ) == 7); | 202 ASSERT_TRUE(countPixel( rDevice, aCol ) == 7) << "number of rendered pixel is not 7"; |
206 } 207 208 void implTestPolyPolyCrissCross(const BitmapDeviceSharedPtr& rDevice) 209 { 210 const Color aCol(0xFFFFFFFF); 211 const Color aBgCol(0); 212 rDevice->clear(aBgCol); 213 basegfx::B2DPolyPolygon aPoly; 214 ::rtl::OUString aSvg; 215 216 basegfx::tools::importFromSvgD( aPoly, 217 ::rtl::OUString::createFromAscii( 218 "M0 0 v2 l10 2 v-2 z" 219 "M10 6 v-2 l-10 2 v2 z" 220 "M1 0 h1 v10 h-1 z" 221 "M4 0 h1 v10 h-1 z" | 203 } 204 205 void implTestPolyPolyCrissCross(const BitmapDeviceSharedPtr& rDevice) 206 { 207 const Color aCol(0xFFFFFFFF); 208 const Color aBgCol(0); 209 rDevice->clear(aBgCol); 210 basegfx::B2DPolyPolygon aPoly; 211 ::rtl::OUString aSvg; 212 213 basegfx::tools::importFromSvgD( aPoly, 214 ::rtl::OUString::createFromAscii( 215 "M0 0 v2 l10 2 v-2 z" 216 "M10 6 v-2 l-10 2 v2 z" 217 "M1 0 h1 v10 h-1 z" 218 "M4 0 h1 v10 h-1 z" |
222 "M8 0 h1 v10 h-1 z" ) ); | 219 "M8 0 h1 v10 h-1 z" ), 220 false, NULL ); |
223 rDevice->fillPolyPolygon( 224 aPoly, 225 aCol, 226 DrawMode_PAINT ); | 221 rDevice->fillPolyPolygon( 222 aPoly, 223 aCol, 224 DrawMode_PAINT ); |
227 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 46", 228 countPixel( rDevice, aCol ) == 46); | 225 ASSERT_TRUE(countPixel( rDevice, aCol ) == 46) << "number of rendered pixel is not 46"; |
229 } 230 231 232public: | 226 } 227 228 229public: |
233 void setUp() | 230 virtual void SetUp() |
234 { 235 const basegfx::B2ISize aSize(10,10); 236 mpDevice1bpp = createBitmapDevice( aSize, 237 true, 238 Format::ONE_BIT_MSB_PAL ); 239 mpDevice32bpp = createBitmapDevice( aSize, 240 true, 241 Format::THIRTYTWO_BIT_TC_MASK ); 242 } | 231 { 232 const basegfx::B2ISize aSize(10,10); 233 mpDevice1bpp = createBitmapDevice( aSize, 234 true, 235 Format::ONE_BIT_MSB_PAL ); 236 mpDevice32bpp = createBitmapDevice( aSize, 237 true, 238 Format::THIRTYTWO_BIT_TC_MASK ); 239 } |
240}; |
|
243 | 241 |
244 void testEmpty() 245 { 246 implTestEmpty( mpDevice1bpp ); 247 implTestEmpty( mpDevice32bpp ); 248 } | |
249 | 242 |
250 void testHairline() 251 { 252 implTestHairline( mpDevice1bpp ); 253 implTestHairline( mpDevice32bpp ); 254 } | 243TEST_F(PolyTest, testEmpty) 244{ 245 implTestEmpty( mpDevice1bpp ); 246 implTestEmpty( mpDevice32bpp ); 247} |
255 | 248 |
256 void testPolyPoly() 257 { 258 implTestPolyPoly( mpDevice1bpp ); 259 implTestPolyPoly( mpDevice32bpp ); 260 } | 249TEST_F(PolyTest, testHairline) 250{ 251 implTestHairline( mpDevice1bpp ); 252 implTestHairline( mpDevice32bpp ); 253} |
261 | 254 |
262 void testPolyPolyClip() 263 { 264 implTestPolyPolyClip(mpDevice1bpp); 265 implTestPolyPolyClip(mpDevice32bpp); 266 } | 255TEST_F(PolyTest, testPolyPoly) 256{ 257 implTestPolyPoly( mpDevice1bpp ); 258 implTestPolyPoly( mpDevice32bpp ); 259} |
267 | 260 |
268 void testPolyPolyCrissCross() 269 { 270 implTestPolyPolyCrissCross(mpDevice1bpp); 271 implTestPolyPolyCrissCross(mpDevice32bpp); 272 } | 261TEST_F(PolyTest, testPolyPolyClip) 262{ 263 implTestPolyPolyClip(mpDevice1bpp); 264 implTestPolyPolyClip(mpDevice32bpp); 265} |
273 | 266 |
274 // Change the following lines only, if you add, remove or rename 275 // member functions of the current class, 276 // because these macros are need by auto register mechanism. 277 278 CPPUNIT_TEST_SUITE(PolyTest); 279 CPPUNIT_TEST(testEmpty); 280 CPPUNIT_TEST(testHairline); 281 CPPUNIT_TEST(testPolyPoly); 282 CPPUNIT_TEST(testPolyPolyClip); 283 CPPUNIT_TEST(testPolyPolyCrissCross); 284 CPPUNIT_TEST_SUITE_END(); 285}; 286 287// ----------------------------------------------------------------------------- 288CPPUNIT_TEST_SUITE_REGISTRATION(PolyTest); | 267TEST_F(PolyTest, testPolyPolyCrissCross) 268{ 269 implTestPolyPolyCrissCross(mpDevice1bpp); 270 implTestPolyPolyCrissCross(mpDevice32bpp); |
289} 290 291 | 271} 272 273 |
292// ----------------------------------------------------------------------------- 293 294// this macro creates an empty function, which will called by the RegisterAllFunctions() 295// to let the user the possibility to also register some functions by hand. 296//NOADDITIONAL; 297 | 274} |