diff options
author | Adam Co <rattles2013@gmail.com> | 2014-01-13 13:55:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-14 10:40:22 +0100 |
commit | c2c08b7d0e87f8cd1c97028c9363826f4bd22dcb (patch) | |
tree | 52c49ffeabc62dae3c31b5c491939cfcf3ac6d0c | |
parent | d8db8eddedfe00c428069d046cdef5ea2a3af54d (diff) |
Add unit-test for 'track changes - paragraph properties changed' preservation
This is a unit-test added to complement the patch that added support
for the preservation of 'Track Changes - Paragraph Properties Changed'
from a DOCX file.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7401
Change-Id: Ic81a5ac9ee369ae0f1d2f8d1a1fe54ea5e6b7402
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx | bin | 0 -> 16307 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 26 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx b/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx Binary files differnew file mode 100644 index 000000000000..4a8585c1d008 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 95b2cb248ce9..dea8293d5baf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -84,6 +84,12 @@ protected: void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes); /** + * Assert that rXPath exists, and has exactly nNumberOfChildNodes child nodes. + * Useful for checking that we do have a no child nodes to a specific node (nNumberOfChildNodes == 0). + */ + void assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes); + + /** * Same as the assertXPath(), but don't assert: return the string instead. */ OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute); @@ -160,6 +166,18 @@ void Test::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNo nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes)); } +void Test::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes) +{ + xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(), + 1, xmlXPathNodeSetGetLength(pXmlNodes)); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + OString("XPath '" + rXPath + "' number of child-nodes is incorrect").getStr(), + nNumberOfChildNodes, (int)xmlChildElementCount(pXmlNode)); +} + OUString Test::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute) { xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath); @@ -2422,6 +2440,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70942, "fdo70942.docx") "prst", "ellipse"); } +DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesParagraphProperties.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); |