Unit test, with inserting a control?

Regina Henschel rb.henschel at t-online.de
Fri Feb 12 00:19:05 UTC 2021

Hi Xisco,

Regina Henschel schrieb am 11.02.2021 um 18:58:
> Hi Xisco,
> Regina Henschel schrieb am 10.02.2021 um 22:36:
>> There will be the same problem in my upcoming fix for tdf#134355. 
>> There I will need to drag-create a custom-shape. And I have no idea, 
>> how to make a drag-create in a cppunit test.
> The patch for tdf#134355 is now in 
> https://gerrit.libreoffice.org/c/core/+/110763. So if you have any idea 
> about a cppunit test, please tell me.

The following code does not work, it does not fail in un-patched 
version. Creating the custom shape with "new" and then adding it to the 
draw page, puts the shape onto the correct layer. The faulty method 
FuConstCustomShape::Activate() it not called.

It seems I need indeed a way to create the custom shape with the mouse.

Kind regards

void ScShapeTest::testTdf134355_createCustomShape()
     // Load an empty document.
     OUString aFileURL;
     createFileURL(u"ManualColWidthRowHeight.ods", aFileURL);
     uno::Reference<css::lang::XComponent> xComponent = 

     // Get document and draw page
     ScDocShell* pDocSh = lcl_getScDocShellWithAssert(xComponent);
     ScDocument& rDoc = pDocSh->GetDocument();
     SdrPage* pPage = lcl_getSdrPageWithAssert(rDoc);

     // Insert Shape
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
     CPPUNIT_ASSERT_MESSAGE("No ScDrawLayer", pDrawLayer);
     SdrObjCustomShape* pObj = new SdrObjCustomShape(*pDrawLayer);
     CPPUNIT_ASSERT_MESSAGE("Could not create rectangle", pObj);
     OUString sType("smiley");
     const tools::Rectangle aRect(Point(1000, 1000), Size(5000, 5000));

     sal_uInt8 nExpectedID = sal_uInt8(SC_LAYER_FRONT);
     sal_uInt8 nActualID = pObj->GetLayer().get();
     CPPUNIT_ASSERT_EQUAL(nExpectedID, nActualID);


More information about the LibreOffice mailing list