[Libreoffice-commits] core.git: sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Wed Nov 13 13:30:40 PST 2013


 sw/qa/extras/htmlexport/htmlexport.cxx |   68 ++++++++++++++++-----------------
 sw/qa/extras/inc/swmodeltestbase.hxx   |   21 +++++++---
 2 files changed, 51 insertions(+), 38 deletions(-)

New commits:
commit 70ad8ec6d5bd9b2b146d7409ec06d3414cd8551c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Nov 13 22:04:41 2013 +0100

    Make CppunitTest_sw_htmlexport use DECLARE_SW_ROUNDTRIP_TEST()
    
    Change-Id: Idc524ce084e117a9cfe816e5012ef33ea774fef6

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index b200cda..c86b2f4 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -8,6 +8,9 @@
  */
 
 #include <swmodeltestbase.hxx>
+
+#if !defined(MACOSX) && !defined(WNT)
+
 #include <com/sun/star/awt/Gradient.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
 #include <swmodule.hxx>
@@ -16,56 +19,55 @@
 class Test : public SwModelTestBase
 {
 public:
-    void testFdo62336();
-    void testCharacterBorder();
-
-    CPPUNIT_TEST_SUITE(Test);
-#if !defined(MACOSX) && !defined(WNT)
-    CPPUNIT_TEST(run);
-#endif
-    CPPUNIT_TEST_SUITE_END();
+    Test()
+        : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"),
+        m_eUnit(FUNIT_NONE)
+    {
+    }
 
 private:
-    void run();
-};
+    bool mustCalcLayoutOf(const char* filename) SAL_OVERRIDE
+    {
+        return OString(filename) != "fdo62336.docx";
+    }
 
-void Test::run()
-{
-    MethodEntry<Test> aMethods[] = {
-        {"fdo62336.docx", &Test::testFdo62336},
-        {"charborder.odt", &Test::testCharacterBorder},
-    };
-    header();
-    for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
+    bool mustTestImportOf(const char* filename) const SAL_OVERRIDE
     {
-        MethodEntry<Test>& rEntry = aMethods[i];
-        FieldUnit eUnit = FUNIT_NONE;
-        if (OString(rEntry.pName) == "charborder.odt")
+        return OString(filename) != "fdo62336.docx";
+    }
+
+    void preTest(const char* filename) SAL_OVERRIDE
+    {
+        if (OString(filename) == "charborder.odt")
         {
             // FIXME if padding-top gets exported as inches, not cms, we get rounding errors.
             SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
-            eUnit = pPref->GetMetric();
+            m_eUnit = pPref->GetMetric();
             pPref->SetMetric(FUNIT_CM);
         }
-        load("/sw/qa/extras/htmlexport/data/", rEntry.pName,
-             false /* not doing layout is required for this test */);
-        reload("HTML (StarWriter)");
-        if (OString(rEntry.pName) == "charborder.odt")
+    }
+
+    void postTest(const char* filename) SAL_OVERRIDE
+    {
+        if (OString(filename) == "charborder.odt")
         {
             SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
-            pPref->SetMetric(eUnit);
+            pPref->SetMetric(m_eUnit);
         }
-        (this->*rEntry.pMethod)();
-        finish();
     }
-}
 
-void Test::testFdo62336()
+    FieldUnit m_eUnit;
+};
+
+#define DECLARE_HTMLEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
+
+DECLARE_HTMLEXPORT_TEST(testFdo62336, "fdo62336.docx")
 {
     // The problem was essentially a crash during table export as docx/rtf/html
+    // If either of no-calc-layout or no-test-import is enabled, the crash does not occur
 }
 
-void Test::testCharacterBorder()
+DECLARE_HTMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
 {
 
     uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
@@ -88,7 +90,7 @@ void Test::testCharacterBorder()
     // No shadow
 }
 
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+#endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 27cacf2..79eb8af 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -139,8 +139,10 @@ protected:
     void executeImportExportImportTest(const char* filename)
     {
         header();
+        preTest(filename);
         load(mpTestDocumentPath, filename);
-        reload(mpFilter);
+        reload(mpFilter, filename);
+        postTest(filename);
         verify();
         finish();
     }
@@ -174,6 +176,14 @@ protected:
     {
     }
 
+    /**
+     * Override this function if not calcing layout is needed
+     */
+    virtual bool mustCalcLayoutOf(const char* /*filename*/)
+    {
+        return true;
+    }
+
 private:
     void dumpLayout()
     {
@@ -391,7 +401,7 @@ protected:
         std::cerr << "File tested,Execution Time (ms)" << std::endl;
     }
 
-    void load(const char* pDir, const char* pName, bool bCalcLayout = true)
+    void load(const char* pDir, const char* pName)
     {
         if (mxComponent.is())
             mxComponent->dispose();
@@ -399,11 +409,11 @@ protected:
         std::cerr << pName << ",";
         m_nStartTime = osl_getGlobalTimer();
         mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
-        if (bCalcLayout)
+        if (mustCalcLayoutOf(pName))
             calcLayout();
     }
 
-    void reload(const char* pFilter)
+    void reload(const char* pFilter, const char* filename)
     {
         uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
         uno::Sequence<beans::PropertyValue> aArgs(1);
@@ -420,7 +430,8 @@ protected:
             xmlBufferFree(mpXmlBuffer);
             mpXmlBuffer = 0;
         }
-        calcLayout();
+        if (mustCalcLayoutOf(filename))
+            calcLayout();
     }
 
     /// Save the loaded document to a tempfile. Can be used to check the resulting docx/odt directly as a ZIP file.


More information about the Libreoffice-commits mailing list