include/test/xmltesttools.hxx            |    4 ++++
 sw/qa/extras/inc/swmodeltestbase.hxx     |    4 +++-
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |   18 ++----------------
 test/source/xmltesttools.cxx             |   12 ++++++++++++
 4 files changed, 21 insertions(+), 17 deletions(-)

New commits:
commit 548b360c0e4693aac0cbdd2fcc1aab433fc54010
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Tue Sep 30 11:48:59 2014 +0200

    Factor out duplicated code to XmlTestTools::assertXPathNoAttribute()
    
    Change-Id: I1eb3778e6bcdd8c44ffb9a7548add109331fc83b

diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx
index 6709c1c..a3ac5d6 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 207970d..d136875 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 5ba9162..32908a0 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);
commit a87d0bc0f5ace66c5d0d71f310f99ba9dbebc543
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Tue Sep 30 11:48:08 2014 +0200

    SwModelTestBase: include name of document in CPPUNIT_ASSERT msgs
    
    Change-Id: Ice6834702419e6d2e8b7eb3051aeea2c9b596249

diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx 
b/sw/qa/extras/inc/swmodeltestbase.hxx
index 2658f12..fdce9f1 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -654,7 +654,9 @@ protected:
         uno::Reference<io::XInputStream> 
xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY);
         boost::shared_ptr<SvStream> 
pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
 
-        return parseXmlStream(pStream.get());
+        xmlDocPtr pXmlDoc = parseXmlStream(pStream.get());
+        pXmlDoc->name = reinterpret_cast<char 
*>(xmlStrdup(reinterpret_cast<xmlChar const 
*>(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
+        return pXmlDoc;
     }
 
     /**
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to