How to make a unit test for Draw to test file format?

Regina Henschel rb.henschel at t-online.de
Thu Aug 23 13:23:33 UTC 2018


Hi all,

I'm still working on https://gerrit.libreoffice.org/#/c/59269/. The 
suggested range-based for-loops work well. Now I try to make a unit test 
as suggested by Tomaž.

I have a test file "tdf101242_without_settings.odg", which has the 
attributes in the <draw:layer> elements in styles.xml and has no 
visible/printable/locked items in settings.xml. I want to load the file, 
then save it, then verify that the attributes are still there in 
styles.xml. After that works, make a test to verify, that the old kind 
items in settings.xml are written correctly.

Is there any example, where I can see how to do that?

I have tried a start like
void SdMiscTest::testTdf101242_ODF2ODF()
{
     ::sd::DrawDocShellRef xDocShRef = 
Load(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf101242_without_settings.odg"), 
ODG);

Is there a human readable way to see, what I get there?

Then I have continued (mimicking what I have seen in other places) with:
uno::Reference<lang::XComponent > xComponent(xDocShRef->GetModel(), 
uno::UNO_QUERY);
     uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
     utl::MediaDescriptor aMediaDescriptor;
     aMediaDescriptor["FilterName"] <<= OUString("draw8");
     utl::TempFile aTempFile;
     aTempFile.EnableKillingFile();
     xStorable->storeToURL(aTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());

I see a temp file in C:\cygwin64\tmp\. But it has mimetype 
application/vnd.oasis.opendocument.presentation and the attributes in 
the <draw:layer> elements are wrong.

My idea was to use something like
xmlDocPtr pXmlDoc = parseExport(aTempFile, "styles.xml");
OString 
sPathStart("/office:document-styles/office:master-styles/draw:layer-set/draw:layer");
     assertXPath(pXmlDoc, sPathStart + 
"[@draw:name='backgroundobjects']", "draw:protected", "true" );
I get something in pXmlDoc. How can I see, what I have got? I cannot get 
nodes from it, e.g 
getXPathNode(pXmlDoc,OString("/office:document-styles")) or 
getXPathNode(pXmlDoc,"/office:document-styles") is already empty.

Obviously I need help.

Kind regards
Regina



More information about the LibreOffice mailing list