[Libreoffice-commits] .: chart2/qa sc/qa test/inc test/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Fri Apr 27 04:51:39 PDT 2012


 chart2/qa/unit/data/tolerance.xml |    7 +++++++
 sc/qa/extras/regression-test.cxx  |    7 ++++---
 test/inc/test/xmldiff.hxx         |    2 +-
 test/source/diff/diff.cxx         |   10 ++++++++--
 4 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit 60d39b758dc9308d6ce7464875b3a17f26be3d79
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 27 13:50:37 2012 +0200

    add tolerance to chart regression test
    
    Change-Id: I5e7694571815df48e54488a33435bb7d022e6889

diff --git a/chart2/qa/unit/data/tolerance.xml b/chart2/qa/unit/data/tolerance.xml
new file mode 100644
index 0000000..d2c00fb
--- /dev/null
+++ b/chart2/qa/unit/data/tolerance.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<tolerances>
+    <tolerance elementName="XShape" attribName="positionX" value="2" relative="false"/>
+    <tolerance elementName="XShape" attribName="positionY" value="2" relative="false"/>
+    <tolerance elementName="XShape" attribName="sizeX" value="2" relative="false"/>
+    <tolerance elementName="XShape" attribName="sizeY" value="2" relative="false"/>
+</tolerances>
diff --git a/sc/qa/extras/regression-test.cxx b/sc/qa/extras/regression-test.cxx
index 77a7557..2c28105 100644
--- a/sc/qa/extras/regression-test.cxx
+++ b/sc/qa/extras/regression-test.cxx
@@ -65,14 +65,15 @@ using namespace ::com::sun::star::uno;
 
 namespace {
 
-bool checkDumpAgainstFile( const rtl::OUString& rDump, const rtl::OUString aFilePath )
+bool checkDumpAgainstFile( const rtl::OUString& rDump, const rtl::OUString aFilePath, const rtl::OUString& rToleranceFile)
 {
     rtl::OString aOFile = rtl::OUStringToOString(aFilePath, RTL_TEXTENCODING_UTF8);
+    rtl::OString aToleranceFile = rtl::OUStringToOString(rToleranceFile, RTL_TEXTENCODING_UTF8);
 
     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()));
+    XMLDiff aDiff(aOFile.getStr(), aDump.getStr(),static_cast<int>(rDump.getLength()), aToleranceFile.getStr());
 
     return aDiff.compare();
 }
@@ -148,7 +149,7 @@ void ScChartRegressionTest::test()
 
     rtl::OUString aDump = xDumper->dump();
     std::cout << aDump;
-    bool bCompare = checkDumpAgainstFile( aDump, getPathFromSrc("/chart2/qa/unit/data/reference/testChart.xml") );
+    bool bCompare = checkDumpAgainstFile( aDump, getPathFromSrc("/chart2/qa/unit/data/reference/testChart.xml"), getPathFromSrc("/chart2/qa/unit/data/tolerance.xml") );
     CPPUNIT_ASSERT(bCompare);
 }
 
diff --git a/test/inc/test/xmldiff.hxx b/test/inc/test/xmldiff.hxx
index a787132..c092637 100644
--- a/test/inc/test/xmldiff.hxx
+++ b/test/inc/test/xmldiff.hxx
@@ -78,7 +78,7 @@ class OOO_DLLPUBLIC_TEST XMLDiff
 public:
     XMLDiff(const std::string& file1, const std::string& file2, const std::string& toleranceFile);
     XMLDiff(const std::string& file1, const std::string& file2);
-    XMLDiff(const char* pFileName, const char* pContent, int size);
+    XMLDiff(const char* pFileName, const char* pContent, int size, const char* pToleranceFileName);
     ~XMLDiff();
 
     bool compare();
diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx
index 8587fd7..574805d 100644
--- a/test/source/diff/diff.cxx
+++ b/test/source/diff/diff.cxx
@@ -56,10 +56,14 @@ XMLDiff::XMLDiff(const std::string& file1, const std::string& file2)
     xmlFile2 = xmlParseFile(file2.c_str());
 }
 
-XMLDiff::XMLDiff( const char* pFileName, const char* pContent, int size)
+XMLDiff::XMLDiff( const char* pFileName, const char* pContent, int size, const char* pToleranceFile)
 {
     xmlFile1 = xmlParseFile(pFileName);
     xmlFile2 = xmlParseMemory(pContent, size);
+
+    xmlDocPtr xmlToleranceFile = xmlParseFile(pToleranceFile);
+    loadToleranceFile(xmlToleranceFile);
+    xmlFreeDoc(xmlToleranceFile);
 }
 
 XMLDiff::~XMLDiff()
@@ -84,7 +88,9 @@ void readAttributesForTolerance(xmlNodePtr node, tolerance& tol)
     tol.value = val;
 
     xmlChar* relative = xmlGetProp(node, BAD_CAST("relative"));
-    bool rel = xmlXPathCastStringToBoolean(relative);
+    bool rel = false;
+    if(xmlStrEqual(relative, BAD_CAST("true")))
+        rel = true;
     xmlFree(relative);
     tol.relative = rel;
 }


More information about the Libreoffice-commits mailing list