LCOV - code coverage report
Current view: top level - cppcanvas/qa/unit - test.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 32 37.5 %
Date: 2015-06-13 12:38:46 Functions: 13 14 92.9 %
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             : 
      10             : #include <sal/config.h>
      11             : 
      12             : #include <boost/scoped_ptr.hpp>
      13             : #include <test/bootstrapfixture.hxx>
      14             : 
      15             : #include <osl/file.hxx>
      16             : #include <osl/process.h>
      17             : #include <vcl/svapp.hxx>
      18             : #include <vcl/wrkwin.hxx>
      19             : #include <vcl/canvastools.hxx>
      20             : 
      21             : #include <comphelper/processfactory.hxx>
      22             : #include <com/sun/star/lang/XInitialization.hpp>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : 
      25             : #include <com/sun/star/rendering/XBitmap.hpp>
      26             : #include <com/sun/star/rendering/XCanvas.hpp>
      27             : #include <com/sun/star/rendering/XBitmapCanvas.hpp>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31           2 : class CanvasTest : public test::BootstrapFixture
      32             : {
      33             : public:
      34           1 :     CanvasTest() : BootstrapFixture(true, false) {}
      35             : 
      36             :     void testComposite();
      37             : 
      38           2 :     CPPUNIT_TEST_SUITE(CanvasTest);
      39           1 :     CPPUNIT_TEST(testComposite);
      40           5 :     CPPUNIT_TEST_SUITE_END();
      41             : };
      42             : 
      43           1 : void CanvasTest::testComposite()
      44             : {
      45             : #ifdef LINUX
      46           1 :     VclPtrInstance<WorkWindow> pWin( nullptr, WB_STDWORK );
      47             : 
      48           1 :     uno::Reference<rendering::XCanvas> xCanvas = pWin->GetCanvas ();
      49           1 :     if( !xCanvas.is() )
      50           2 :         return; // can't get a canvas working at all - truly headless ?
      51             : 
      52             :     // a huge canvas ...
      53           0 :     Size aSize (1, 1);
      54           0 :     uno::Reference<rendering::XBitmap> xBitmap;
      55           0 :     xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap(
      56           0 :                         vcl::unotools::integerSize2DFromSize( aSize ) );
      57           0 :     CPPUNIT_ASSERT( xBitmap.is() );
      58             : 
      59           0 :     uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
      60           0 :     CPPUNIT_ASSERT( xBitmapCanvas.is() );
      61             : 
      62           0 :     BitmapEx aBitmapEx;
      63             :     {
      64             :         // clear the canvas and basic sanity check ...
      65           0 :         xBitmapCanvas->clear();
      66           0 :         CPPUNIT_ASSERT( aBitmapEx.Create( xBitmapCanvas, aSize ) );
      67           0 :         CPPUNIT_ASSERT( aBitmapEx.IsAlpha() );
      68           0 :         CPPUNIT_ASSERT( aBitmapEx.GetAlpha() );
      69             :     }
      70             : 
      71             :     {
      72             :         // render something
      73           0 :         rendering::RenderState aDefaultState;
      74           0 :         uno::Sequence< double > aRedTransparent( 4 );
      75           0 :         aRedTransparent[0] = 1.0; // R
      76           0 :         aRedTransparent[1] = 0.0; // G
      77           0 :         aRedTransparent[2] = 0.0; // B
      78           0 :         aRedTransparent[3] = 0.5; // A
      79           0 :         aDefaultState.DeviceColor = aRedTransparent;
      80             : #if 0
      81             :         // words fail me to describe the sheer beauty of allocating an UNO
      82             :         // object to represent a polygon, and manually handling the ViewState
      83             :         // and there being no public helper for this - to render ... a rectangle.
      84             :         XCachedPrimitive    fillPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
      85             : #endif
      86           0 :     }
      87             : 
      88             : #endif
      89             : }
      90             : 
      91           1 : CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest);
      92             : 
      93           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11