Re: Unit test, with inserting a control?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
Regina

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

    // 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);
    pPage->InsertObject(pObj);
    OUString sType("smiley");
    pObj->MergeDefaultAttributes(&sType);
    const tools::Rectangle aRect(Point(1000, 1000), Size(5000, 5000));
    pObj->SetLogicRect(aRect);

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

    pDocSh->DoClose();
}

_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux