Prepare for removal of non-const operator[] from Sequence in cppcanvas
[LibreOffice.git] / cppcanvas / qa / unit / test.cxx
blob303eecd86a16c993f502ca8a0d46b1e46a652bc5
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->GetOutDev()->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().IsEmpty() );
63 // render something
64 rendering::RenderState aDefaultState;
65 uno::Sequence< double > aRedTransparent{ 1.0, // R
66 0.0, // G
67 0.0, // B
68 0.5 }; // A
69 aDefaultState.DeviceColor = aRedTransparent;
70 #if 0
71 // words fail me to describe the sheer beauty of allocating a UNO
72 // object to represent a polygon, and manually handling the ViewState
73 // and there being no public helper for this - to render ... a rectangle.
74 XCachedPrimitive fillPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
75 #endif
78 #endif
81 CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest);
83 CPPUNIT_PLUGIN_IMPLEMENT();
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */