LCOV - code coverage report
Current view: top level - libreoffice/basebmp/test - bmpmasktest.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 53 100.0 %
Date: 2012-12-27 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : // autogenerated file with codegen.pl
      21             : 
      22             : #include "cppunit/TestAssert.h"
      23             : #include "cppunit/TestFixture.h"
      24             : #include "cppunit/extensions/HelperMacros.h"
      25             : 
      26             : #include <basegfx/vector/b2isize.hxx>
      27             : #include <basegfx/range/b2ibox.hxx>
      28             : #include <basegfx/point/b2ipoint.hxx>
      29             : #include <basegfx/polygon/b2dpolygon.hxx>
      30             : #include <basegfx/polygon/b2dpolygontools.hxx>
      31             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      32             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      33             : 
      34             : #include <basebmp/color.hxx>
      35             : #include <basebmp/scanlineformats.hxx>
      36             : #include <basebmp/bitmapdevice.hxx>
      37             : #include "tools.hxx"
      38             : 
      39             : using namespace ::basebmp;
      40             : 
      41             : namespace
      42             : {
      43           6 : class BmpMaskTest : public CppUnit::TestFixture
      44             : {
      45             : private:
      46             :     BitmapDeviceSharedPtr mpDevice1bpp;
      47             :     BitmapDeviceSharedPtr mpMaskBmp1bpp;
      48             :     BitmapDeviceSharedPtr mpBmp1bpp;
      49             :     BitmapDeviceSharedPtr mpDevice32bpp;
      50             :     BitmapDeviceSharedPtr mpBmp32bpp;
      51             : 
      52           2 :     void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
      53             :                            const BitmapDeviceSharedPtr& rBmp)
      54             :     {
      55           2 :         rDevice->clear(Color(0));
      56           2 :         const Color aCol(0xFFFFFFFF);
      57             : 
      58           2 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      59           2 :         const basegfx::B2IBox aDestAll(0,0,10,10);
      60             : 
      61             :         rDevice->drawMaskedBitmap(
      62             :             rBmp,
      63             :             mpMaskBmp1bpp,
      64             :             aSourceRect,
      65             :             aDestAll,
      66           2 :             DrawMode_PAINT );
      67           4 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
      68           2 :                                countPixel( rDevice, aCol ) == 30);
      69           2 :     }
      70             : 
      71           2 :     void implTestBmpScaledClip(const BitmapDeviceSharedPtr& rDevice,
      72             :                                const BitmapDeviceSharedPtr& rBmp)
      73             :     {
      74           2 :         rDevice->clear(Color(0));
      75           2 :         const Color aCol(0xFFFFFFFF);
      76             : 
      77           2 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      78           2 :         const basegfx::B2IBox aDestLeftTop(0,0,6,6);
      79             : 
      80             :         rDevice->drawMaskedBitmap(
      81             :             rBmp,
      82             :             mpMaskBmp1bpp,
      83             :             aSourceRect,
      84             :             aDestLeftTop,
      85           2 :             DrawMode_PAINT );
      86           4 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
      87           2 :                                countPixel( rDevice, aCol ) == 12);
      88           2 :     }
      89             : 
      90             : public:
      91           2 :     void setUp()
      92             :     {
      93           2 :         const basegfx::B2ISize aSize(10,10);
      94             :         mpDevice1bpp = createBitmapDevice( aSize,
      95             :                                            true,
      96           2 :                                            Format::ONE_BIT_MSB_PAL );
      97             :         mpDevice32bpp = createBitmapDevice( aSize,
      98             :                                             true,
      99           2 :                                             Format::THIRTYTWO_BIT_TC_MASK );
     100             : 
     101             :         mpMaskBmp1bpp = createBitmapDevice( aSize,
     102             :                                             true,
     103           2 :                                             Format::ONE_BIT_MSB_GREY );
     104             : 
     105             :         mpBmp1bpp = createBitmapDevice( aSize,
     106             :                                         true,
     107           2 :                                         Format::ONE_BIT_MSB_PAL );
     108             :         mpBmp32bpp = createBitmapDevice( aSize,
     109             :                                          true,
     110           2 :                                          Format::THIRTYTWO_BIT_TC_MASK );
     111             : 
     112           2 :         OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
     113             : 
     114           2 :         basegfx::B2DPolyPolygon aPoly;
     115           2 :         basegfx::tools::importFromSvgD( aPoly, aSvg );
     116           2 :         const Color aColWhite(0xFFFFFFFF);
     117           2 :         const Color aColBlack(0);
     118             :         mpBmp1bpp->fillPolyPolygon(
     119             :             aPoly,
     120             :             aColWhite,
     121           2 :             DrawMode_PAINT );
     122             :         mpBmp32bpp->fillPolyPolygon(
     123             :             aPoly,
     124             :             aColWhite,
     125           2 :             DrawMode_PAINT );
     126             : 
     127           2 :         aSvg = "m 0 0 h6 v10 h-6z" ;
     128             : 
     129           2 :         aPoly.clear();
     130           2 :         basegfx::tools::importFromSvgD( aPoly, aSvg );
     131           2 :         mpMaskBmp1bpp->clear(aColWhite);
     132             :         mpMaskBmp1bpp->fillPolyPolygon(
     133             :             aPoly,
     134             :             aColBlack,
     135           2 :             DrawMode_PAINT );
     136           2 :     }
     137             : 
     138           1 :     void testBmpBasics()
     139             :     {
     140           1 :         implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
     141           1 :         implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
     142           1 :     }
     143             : 
     144           1 :     void testBmpClip()
     145             :     {
     146           1 :         implTestBmpScaledClip( mpDevice1bpp, mpBmp1bpp );
     147           1 :         implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
     148           1 :     }
     149             : 
     150             :     // Change the following lines only, if you add, remove or rename
     151             :     // member functions of the current class,
     152             :     // because these macros are need by auto register mechanism.
     153             : 
     154           2 :     CPPUNIT_TEST_SUITE(BmpMaskTest);
     155           1 :     CPPUNIT_TEST(testBmpBasics);
     156           1 :     CPPUNIT_TEST(testBmpClip);
     157           2 :     CPPUNIT_TEST_SUITE_END();
     158             : };
     159             : 
     160           1 : CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest);
     161           3 : }
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10