[Libreoffice-commits] core.git: sw/qa
Adam Co
rattles2013 at gmail.com
Tue Jan 14 01:40:44 PST 2014
sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 26 ++++++++++
2 files changed, 26 insertions(+)
New commits:
commit c2c08b7d0e87f8cd1c97028c9363826f4bd22dcb
Author: Adam Co <rattles2013 at gmail.com>
Date: Mon Jan 13 13:55:05 2014 +0200
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
diff --git a/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx b/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx
new file mode 100644
index 0000000..4a8585c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testTrackChangesParagraphProperties.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 95b2cb2..dea8293 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();
More information about the Libreoffice-commits
mailing list