Struggling with LayerTabBar in unit test

Michael Stahl mst at libreoffice.org
Mon Sep 24 12:42:04 UTC 2018


On 24/09/2018 14:24, Regina Henschel wrote:
> 
> void SdMiscTest::testTdf119956()
> {
>      sd::DrawDocShellRef xDocShRef = 
> Load(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf119956.odg"), ODG);

okay, so you want to load an existing document...

>      CPPUNIT_ASSERT_MESSAGE( "Failed to load file.", xDocShRef.is());
> 
>      sd::DrawViewShell* pDrawViewShell = dynamic_cast<sd::DrawViewShell* 
>  >(xDocShRef->GetViewShell());
>      CPPUNIT_ASSERT_MESSAGE( "No dynamic_cast to sd::DrawViewShell", 
> pDrawViewShell);
> 
>      pDrawViewShell->ChangeEditMode(EditMode::MasterPage,true);
>      pDrawViewShell->ResetActualLayer();
> }
> 
> The line pDrawViewShell->ResetActualLayer(); does not work. On make 
> sd.check I get the error:
> 
> [build LNK] CppunitTest/test_sd_misc_tests.dll
>     Creating library 
> D:/Build_localizedLayernames/core/workdir/LinkTarget/CppunitTest/itest_sd_misc_tests.lib 
> and object 
> D:/Build_localizedLayernames/core/workdir/LinkTarget/CppunitTest/itest_sd_misc_tests.exp 
> 
> misc-tests.o : error LNK2019: unresolved external symbol "public: void 
> __cdecl sd::DrawViewShell::ResetActualLayer(void)" 
> (?ResetActualLayer at DrawViewShell@sd@@QEAAXXZ) referenced in function 
> "public: void __cdecl SdMiscTest::testTdf119956(void)" 
> (?testTdf119956 at SdMiscTest@@QEAAXXZ)
> D:/Build_localizedLayernames/core/workdir/LinkTarget/CppunitTest/test_sd_misc_tests.dll 
> : fatal error LNK1120: 1 unresolved externals
> 
> Similar for other methods, that use the LayerTabBar, e.g. 
> GetLayerTabControl() or GetTabLayerCount(). There are no problems in the 
> other lines, when I remove ResetActualLayer().

the problem is that the DrawViewShell is not annotated with 
SD_DLLPUBLIC, hence it and its member functions are not visible to the 
unit test.

there are 2 obvious options:

1. make it SD_DLLPUBLIC

2. move your test to "CppunitTest_uimpress", which is built in a special 
way so that it can access all internal functions of Library_sd, but it 
is unable to access anything from Library_sdui or Library_sdfilt.

now i don't know if it is possible to load a document from uimpress 
test; probably not with the same functions as are used in the other tests...


More information about the LibreOffice mailing list