Need help for unit test

Regina Henschel rb.henschel at t-online.de
Tue Mar 16 01:58:49 UTC 2021


Hi all,

and again I need help for making a unit test.

My idea for unit test for https://gerrit.libreoffice.org/c/core/+/112474 
is to load a document with a custom shape in 3D mode. It has extrusion 
direction "Extrusion Backwards", which means, that no side faces are 
visible.
Then I want let a DrawViewShell execute a request with 
SID_EXTRUSION_DIRECTION. That should show a side face and I can examine 
whether the BoundRect has the correct height. But I struggle:

In svx/qa/unit/customshape.cxx I can write
CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141021ExtrusionNorth)
{
     OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + 
"tdf141021_ExtrusionNorth.odp";
     mxComponent = loadFromDesktop(aURL, 
"com.sun.star.comp.presentation.PresentationDocument");
     uno::Reference<drawing::XShape> xShape(getShape(0));

     SdrObjCustomShape& rSdrShape( 
static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape)));
     tools::Rectangle aBoundRect(rSdrShape.GetCurrentBoundRect());
     CPPUNIT_ASSERT_EQUAL(tools::Long(5895), aBoundRect.GetHeight());
}

I get a non-empty BoundRect, but I cannot get a DrawViewShell to execute 
the request.

In sd/qa/unit/misc-tests.cxx I can write
void SdMiscTest::testTdf141021ExtrusionNorth()
{
     sd::DrawDocShellRef xDocSh = 
Load(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf141021_ExtrusionNorth.odp"), 
ODP);
     sd::DrawViewShell* pViewShell = 
static_cast<sd::DrawViewShell*>(xDocSh->GetViewShell());

     SdPage* pPage = pViewShell->GetActualPage();
     SdrObjCustomShape* pObject = 
static_cast<SdrObjCustomShape*>(pPage->GetObj(0));
     tools::Rectangle aBoundRect(pObject->GetCurrentBoundRect());
     CPPUNIT_ASSERT_EQUAL(tools::Long(5895), aBoundRect.GetHeight());
}

Here I have a DrawViewShell, but the BoundRect is empty.

Any idea?

Kind regards
Regina



More information about the LibreOffice mailing list