summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/xmltesttools.hxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx18
-rw-r--r--test/source/xmltesttools.cxx12
3 files changed, 18 insertions, 16 deletions
diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx
index 6709c1ca3ce2..a3ac5d6ce5db 100644
--- a/include/test/xmltesttools.hxx
+++ b/include/test/xmltesttools.hxx
@@ -76,6 +76,10 @@ protected:
* 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);
+ /**
+ * Assert that rXPath exists, has exactly 1 child node and does *not* have an attribute named rAttribute.
+ */
+ void assertXPathNoAttribute(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
};
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 207970d65c2e..d136875d7b7d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -134,14 +134,7 @@ DECLARE_OOXMLEXPORT_TEST(testParaShading, "para-shading.docx")
{
// Make sure the themeColor attribute is not written when it would be empty.
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
- {
- xmlXPathObjectPtr pXPath = getXPathNode(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:shd");
- xmlNodeSetPtr pXmlNodes = pXPath->nodesetval;
- CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
- xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
- // The attribute existed, so xmlGetProp() returned non-NULL.
- CPPUNIT_ASSERT_EQUAL(static_cast<xmlChar*>(0), xmlGetProp(pXmlNode, BAD_CAST("themeColor")));
- }
+ assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:shd", "themeColor");
}
DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooter, "first-header-footer.docx")
@@ -294,14 +287,7 @@ DECLARE_OOXMLEXPORT_TEST(testDrawingmlFlipv, "drawingml-flipv.docx")
{
// The problem was that the shape had vertical flip only, but then we added rotation as well on export.
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
- {
- xmlXPathObjectPtr pXPath = getXPathNode(pXmlDoc, "//a:xfrm");
- xmlNodeSetPtr pXmlNodes = pXPath->nodesetval;
- CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
- xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
- // The attribute existed, so xmlGetProp() returned non-NULL.
- CPPUNIT_ASSERT_EQUAL(static_cast<xmlChar*>(0), xmlGetProp(pXmlNode, BAD_CAST("rot")));
- }
+ assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "rot");
}
DECLARE_OOXMLEXPORT_TEST(testRot90Fliph, "rot90-fliph.docx")
diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx
index 5ba9162dcac1..32908a068699 100644
--- a/test/source/xmltesttools.cxx
+++ b/test/source/xmltesttools.cxx
@@ -114,6 +114,18 @@ void XmlTestTools::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath,
#endif
}
+void XmlTestTools::assertXPathNoAttribute(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
+{
+ xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath);
+ xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
+ 1, xmlXPathNodeSetGetLength(pXmlNodes));
+ xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(),
+ static_cast<xmlChar*>(0), xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
+ xmlXPathFreeObject(pXmlObj);
+}
+
int XmlTestTools::getXPathPosition(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rChildName)
{
xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath);