[Libreoffice-commits] .: Branch 'feature/gsoc_test_improvements2' - sc/qa sd/qa test/inc test/source

Michael Stahl mst at kemper.freedesktop.org
Fri Jul 13 03:31:11 PDT 2012


 sc/qa/extras/regression-test.cxx |    5 --
 sd/qa/unit/regression-test.cxx   |    9 ++--
 test/inc/test/xmldiff.hxx        |   70 +-------------------------------
 test/source/diff/diff.cxx        |   84 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 94 insertions(+), 74 deletions(-)

New commits:
commit 87c6beddfb684cee702ec1c9225497b8541a780d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jul 13 12:29:03 2012 +0200

    test: move XMLDiff implementation details to cxx file
    
    This makes it unnecessary to link clients against libxml2.
    
    Change-Id: Ifd295623c01bdc6f579afbf81d5b609a2b29f4bf

diff --git a/sc/qa/extras/regression-test.cxx b/sc/qa/extras/regression-test.cxx
index 2c28105..e909467 100644
--- a/sc/qa/extras/regression-test.cxx
+++ b/sc/qa/extras/regression-test.cxx
@@ -73,9 +73,8 @@ bool checkDumpAgainstFile( const rtl::OUString& rDump, const rtl::OUString aFile
     CPPUNIT_ASSERT_MESSAGE("dump is empty", !rDump.isEmpty());
 
     rtl::OString aDump = rtl::OUStringToOString(rDump, RTL_TEXTENCODING_UTF8);
-    XMLDiff aDiff(aOFile.getStr(), aDump.getStr(),static_cast<int>(rDump.getLength()), aToleranceFile.getStr());
-
-    return aDiff.compare();
+    return doXMLDiff(aOFile.getStr(), aDump.getStr(),
+            static_cast<int>(rDump.getLength()), aToleranceFile.getStr());
 }
 
 }
diff --git a/sd/qa/unit/regression-test.cxx b/sd/qa/unit/regression-test.cxx
index 7cb0609..0b1dee1 100644
--- a/sd/qa/unit/regression-test.cxx
+++ b/sd/qa/unit/regression-test.cxx
@@ -214,10 +214,13 @@ void SdFiltersTest::testStuff(::sd::DrawDocShellRef xDocShRef, const rtl::OStrin
 
         rtl::OString aFileName = aFileNameBuf.makeStringAndClear();
 
-        XMLDiff aDiff(aFileName.getStr(), rtl::OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(), static_cast<int>(aString.getLength()),
-                rtl::OUStringToOString(getPathFromSrc("/sd/qa/unit/data/tolerance.xml"), RTL_TEXTENCODING_UTF8).getStr());
         std::cout << aString << std::endl;
-        aDiff.compare();
+        doXMLDiff(aFileName.getStr(),
+            rtl::OUStringToOString(aString, RTL_TEXTENCODING_UTF8).getStr(),
+            static_cast<int>(aString.getLength()),
+            rtl::OUStringToOString(
+                getPathFromSrc("/sd/qa/unit/data/tolerance.xml"),
+                RTL_TEXTENCODING_UTF8).getStr());
     }
     xDocShRef->DoClose();
 }
diff --git a/test/inc/test/xmldiff.hxx b/test/inc/test/xmldiff.hxx
index 0d768ae..cdba298 100644
--- a/test/inc/test/xmldiff.hxx
+++ b/test/inc/test/xmldiff.hxx
@@ -26,74 +26,10 @@
  * instead of those above.
  */
 
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xmlmemory.h>
-#include <string>
-#include <set>
 #include <test/testdllapi.hxx>
 
-#define USE_CPPUNIT 1
-
-struct tolerance
-{
-    ~tolerance()
-    {
-        xmlFree(elementName);
-        xmlFree(attribName);
-    }
-
-    tolerance()
-    {
-        elementName = NULL;
-        attribName = NULL;
-    }
-
-    tolerance(const tolerance& tol)
-    {
-        elementName = xmlStrdup(tol.elementName);
-        attribName = xmlStrdup(tol.attribName);
-        relative = tol.relative;
-        value = tol.value;
-    }
-
-    xmlChar* elementName;
-    xmlChar* attribName;
-    bool relative;
-    double value;
-    bool operator==(const tolerance& rTol) const { return xmlStrEqual(elementName, rTol.elementName) && xmlStrEqual(attribName, rTol.attribName); }
-    bool operator<(const tolerance& rTol) const
-    {
-        int cmp = xmlStrcmp(elementName, rTol.elementName);
-        if(cmp == 0)
-        {
-            cmp = xmlStrcmp(attribName, rTol.attribName);
-        }
-
-        if(cmp>=0)
-            return false;
-        else
-            return true;
-    }
-};
-
-class OOO_DLLPUBLIC_TEST XMLDiff
-{
-public:
-    XMLDiff(const char* pFileName, const char* pContent, int size, const char* pToleranceFileName);
-    ~XMLDiff();
-
-    bool compare();
-private:
-    typedef std::set<tolerance> ToleranceContainer;
-
-    void loadToleranceFile(xmlDocPtr xmlTolerance);
-    bool compareAttributes(xmlNodePtr node1, xmlNodePtr node2);
-    bool compareElements(xmlNodePtr node1, xmlNodePtr node2);
-
-    ToleranceContainer toleranceContainer;
-    xmlDocPtr xmlFile1;
-    xmlDocPtr xmlFile2;
-};
+bool OOO_DLLPUBLIC_TEST
+doXMLDiff(const char* pFileName, const char* pContent, int size,
+          const char* pToleranceFileName);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx
index 00e1444..048e783 100644
--- a/test/source/diff/diff.cxx
+++ b/test/source/diff/diff.cxx
@@ -26,10 +26,16 @@
  * instead of those above.
  */
 
+#define USE_CPPUNIT 1
 
 #include "test/xmldiff.hxx"
+
 #include <libxml/xpath.h>
-#include <rtl/math.hxx>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlmemory.h>
+
+#include <set>
 #include <cstring>
 #include <sstream>
 #include <cmath>
@@ -39,6 +45,73 @@
 #include <cppunit/extensions/HelperMacros.h>
 #endif
 
+#include <rtl/math.hxx>
+
+
+struct tolerance
+{
+    ~tolerance()
+    {
+        xmlFree(elementName);
+        xmlFree(attribName);
+    }
+
+    tolerance()
+    {
+        elementName = NULL;
+        attribName = NULL;
+    }
+
+    tolerance(const tolerance& tol)
+    {
+        elementName = xmlStrdup(tol.elementName);
+        attribName = xmlStrdup(tol.attribName);
+        relative = tol.relative;
+        value = tol.value;
+    }
+
+    xmlChar* elementName;
+    xmlChar* attribName;
+    bool relative;
+    double value;
+    bool operator==(const tolerance& rTol) const { return xmlStrEqual(elementName, rTol.elementName) && xmlStrEqual(attribName, rTol.attribName); }
+    bool operator<(const tolerance& rTol) const
+    {
+        int cmp = xmlStrcmp(elementName, rTol.elementName);
+        if(cmp == 0)
+        {
+            cmp = xmlStrcmp(attribName, rTol.attribName);
+        }
+
+        if(cmp>=0)
+            return false;
+        else
+            return true;
+    }
+};
+
+class XMLDiff
+{
+public:
+    XMLDiff(const char* pFileName, const char* pContent, int size, const char* pToleranceFileName);
+    ~XMLDiff();
+
+    bool compare();
+private:
+    typedef std::set<tolerance> ToleranceContainer;
+
+    void loadToleranceFile(xmlDocPtr xmlTolerance);
+    bool compareAttributes(xmlNodePtr node1, xmlNodePtr node2);
+    bool compareElements(xmlNodePtr node1, xmlNodePtr node2);
+
+    ToleranceContainer toleranceContainer;
+    xmlDocPtr xmlFile1;
+    xmlDocPtr xmlFile2;
+};
+
+
+
+
 XMLDiff::XMLDiff( const char* pFileName, const char* pContent, int size, const char* pToleranceFile)
 {
     xmlFile1 = xmlParseFile(pFileName);
@@ -290,4 +363,13 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
     return true;
 }
 
+
+bool
+doXMLDiff(char const*const pFileName, char const*const pContent, int const size,
+          char const*const pToleranceFileName)
+{
+    XMLDiff aDiff(pFileName, pContent, size, pToleranceFileName);
+    return aDiff.compare();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list