Bump version to 21.06.18.1
[LibreOffice.git] / cppcanvas / qa / unit / test.cxx
blobfbf6caf39147803b1dc9c53fe0a58709d1fbbcb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <sal/config.h>
12 #include <test/bootstrapfixture.hxx>
14 #include <vcl/wrkwin.hxx>
15 #include <vcl/canvastools.hxx>
17 #include <com/sun/star/rendering/XBitmap.hpp>
18 #include <com/sun/star/rendering/XCanvas.hpp>
19 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
21 using namespace ::com::sun::star;
23 class CanvasTest : public test::BootstrapFixture
25 public:
26 CanvasTest() : BootstrapFixture(true, false) {}
28 void testComposite();
30 CPPUNIT_TEST_SUITE(CanvasTest);
31 CPPUNIT_TEST(testComposite);
32 CPPUNIT_TEST_SUITE_END();
35 void CanvasTest::testComposite()
37 #ifdef LINUX
38 ScopedVclPtrInstance<WorkWindow> pWin( nullptr, WB_STDWORK );
40 uno::Reference<rendering::XCanvas> xCanvas = pWin->GetCanvas ();
41 if( !xCanvas.is() )
42 return; // can't get a canvas working at all - truly headless ?
44 // a huge canvas ...
45 Size aSize (1, 1);
46 uno::Reference<rendering::XBitmap> xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap(
47 vcl::unotools::integerSize2DFromSize( aSize ) );
48 CPPUNIT_ASSERT( xBitmap.is() );
50 uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
51 CPPUNIT_ASSERT( xBitmapCanvas.is() );
53 BitmapEx aBitmapEx;
55 // clear the canvas and basic sanity check ...
56 xBitmapCanvas->clear();
57 CPPUNIT_ASSERT( aBitmapEx.Create( xBitmapCanvas, aSize ) );
58 CPPUNIT_ASSERT( aBitmapEx.IsAlpha() );
59 CPPUNIT_ASSERT( aBitmapEx.GetAlpha() );
63 // render something
64 rendering::RenderState aDefaultState;
65 uno::Sequence< double > aRedTransparent( 4 );
66 aRedTransparent[0] = 1.0; // R
67 aRedTransparent[1] = 0.0; // G
68 aRedTransparent[2] = 0.0; // B
69 aRedTransparent[3] = 0.5; // A
70 aDefaultState.DeviceColor = aRedTransparent;
71 #if 0
72 // words fail me to describe the sheer beauty of allocating a UNO
73 // object to represent a polygon, and manually handling the ViewState
74 // and there being no public helper for this - to render ... a rectangle.
75 XCachedPrimitive fillPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
76 #endif
79 #endif
82 CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest);
84 CPPUNIT_PLUGIN_IMPLEMENT();
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */