[Libreoffice-commits] .: sw/qa

Miklos Vajna vmiklos at kemper.freedesktop.org
Wed May 9 06:30:11 PDT 2012


 sw/qa/extras/ooxmltok/ooxmltok.cxx   |   27 +----------
 sw/qa/extras/rtfexport/rtfexport.cxx |   48 +--------------------
 sw/qa/extras/rtftok/rtftok.cxx       |   50 +--------------------
 sw/qa/extras/swmodeltestbase.hxx     |   80 +++++++++++++++++++++++++++++++++++
 sw/qa/extras/ww8tok/ww8tok.cxx       |   26 +----------
 5 files changed, 92 insertions(+), 139 deletions(-)

New commits:
commit 333ba4627e4c6ae56377773b22526881388c335b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed May 9 15:25:44 2012 +0200

    sw: move common methods of subsequent filter tests to a SwModelTestBase
    
    Change-Id: I71316d6c5b6f4fb820bd541be1cfbb4d39dd261e

diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 00aa2c2..2c672d2 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -25,6 +25,8 @@
  * instead of those above.
  */
 
+#include "../swmodeltestbase.hxx"
+
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -33,25 +35,19 @@
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/XDependentTextField.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
-#include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
 #include <vcl/svapp.hxx>
 
 using rtl::OString;
 using rtl::OUString;
 using rtl::OUStringBuffer;
-using namespace com::sun::star;
 
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public SwModelTestBase
 {
 public:
-    virtual void setUp();
-    virtual void tearDown();
     void testN751054();
     void testN751117();
     void testN751017();
@@ -71,7 +67,6 @@ public:
 private:
     /// Load an OOXML file and make the document available via mxComponent.
     void load(const OUString& rURL);
-    uno::Reference<lang::XComponent> mxComponent;
 };
 
 void Test::load(const OUString& rFilename)
@@ -79,22 +74,6 @@ void Test::load(const OUString& rFilename)
     mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ooxmltok/data/") + rFilename);
 }
 
-void Test::setUp()
-{
-    test::BootstrapFixture::setUp();
-
-    mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void Test::tearDown()
-{
-    if (mxComponent.is())
-        mxComponent->dispose();
-
-    test::BootstrapFixture::tearDown();
-}
-
 void Test::testN751054()
 {
     load("n751054.docx");
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 9f2cb18..74b0ca8 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -25,26 +25,22 @@
  * instead of those above.
  */
 
+#include "../swmodeltestbase.hxx"
+
 #include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
 #include <unotools/tempfile.hxx>
 #include <vcl/svapp.hxx>
 
 using rtl::OString;
 using rtl::OUString;
 using rtl::OUStringBuffer;
-using namespace com::sun::star;
 
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public SwModelTestBase
 {
 public:
-    virtual void setUp();
-    virtual void tearDown();
     void testZoom();
     void testFdo38176();
     void testFdo49683();
@@ -59,9 +55,6 @@ public:
 
 private:
     void roundtrip(const OUString& rURL);
-    /// Get the length of the whole document.
-    int getLength();
-    uno::Reference<lang::XComponent> mxComponent;
 };
 
 void Test::roundtrip(const OUString& rFilename)
@@ -77,41 +70,6 @@ void Test::roundtrip(const OUString& rFilename)
     mxComponent = loadFromDesktop(aTempFile.GetURL());
 }
 
-int Test::getLength()
-{
-    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-    OUStringBuffer aBuf;
-    while (xParaEnum->hasMoreElements())
-    {
-        uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
-        while (xRangeEnum->hasMoreElements())
-        {
-            uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
-            aBuf.append(xRange->getString());
-        }
-    }
-    return aBuf.getLength();
-}
-
-void Test::setUp()
-{
-    test::BootstrapFixture::setUp();
-
-    mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void Test::tearDown()
-{
-    if (mxComponent.is())
-        mxComponent->dispose();
-
-    test::BootstrapFixture::tearDown();
-}
-
 void Test::testZoom()
 {
     roundtrip("zoom.rtf");
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index 8b41569..e7c51fa 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -25,7 +25,8 @@
  * instead of those above.
  */
 
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include "../swmodeltestbase.hxx"
+
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/style/CaseMap.hpp>
@@ -39,7 +40,6 @@
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/XFootnotesSupplier.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
-#include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
@@ -48,24 +48,18 @@
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 
 #include <rtl/oustringostreaminserter.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/svapp.hxx>
-#include <vcl/fontmanager.hxx>
 
 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
 
 using rtl::OString;
 using rtl::OUString;
 using rtl::OUStringBuffer;
-using namespace com::sun::star;
 
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public SwModelTestBase
 {
 public:
-    virtual void setUp();
-    virtual void tearDown();
     void testFdo45553();
     void testN192129();
     void testFdo45543();
@@ -135,12 +129,9 @@ public:
 private:
     /// Load an RTF file and make the document available via mxComponent.
     void load(const OUString& rURL);
-    /// Get the length of the whole document.
-    int getLength();
     /// Get page count.
     int getPages();
     uno::Reference<container::XNameAccess> getStyles(OUString aFamily);
-    uno::Reference<lang::XComponent> mxComponent;
 };
 
 void Test::load(const OUString& rFilename)
@@ -148,25 +139,6 @@ void Test::load(const OUString& rFilename)
     mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtftok/data/") + rFilename);
 }
 
-int Test::getLength()
-{
-    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-    OUStringBuffer aBuf;
-    while (xParaEnum->hasMoreElements())
-    {
-        uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
-        while (xRangeEnum->hasMoreElements())
-        {
-            uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
-            aBuf.append(xRange->getString());
-        }
-    }
-    return aBuf.getLength();
-}
-
 int Test::getPages()
 {
     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
@@ -184,22 +156,6 @@ uno::Reference<container::XNameAccess> Test::getStyles(OUString aFamily)
     return xPageStyles;
 }
 
-void Test::setUp()
-{
-    test::BootstrapFixture::setUp();
-
-    mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void Test::tearDown()
-{
-    if (mxComponent.is())
-        mxComponent->dispose();
-
-    test::BootstrapFixture::tearDown();
-}
-
 void Test::testFdo45553()
 {
     load("fdo45553.rtf");
diff --git a/sw/qa/extras/swmodeltestbase.hxx b/sw/qa/extras/swmodeltestbase.hxx
new file mode 100644
index 0000000..347d408
--- /dev/null
+++ b/sw/qa/extras/swmodeltestbase.hxx
@@ -0,0 +1,80 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/text/XTextDocument.hpp>
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace com::sun::star;
+
+/// Base class for filter tests loading or roundtriping a document, then asserting the document model.
+class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
+{
+public:
+    virtual void setUp()
+    {
+        test::BootstrapFixture::setUp();
+
+        mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
+        CPPUNIT_ASSERT(mxDesktop.is());
+    }
+
+    virtual void tearDown()
+    {
+        if (mxComponent.is())
+            mxComponent->dispose();
+
+        test::BootstrapFixture::tearDown();
+    }
+
+protected:
+    /// Get the length of the whole document.
+    int getLength()
+    {
+        uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+        rtl::OUStringBuffer aBuf;
+        while (xParaEnum->hasMoreElements())
+        {
+            uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+            uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
+            while (xRangeEnum->hasMoreElements())
+            {
+                uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
+                aBuf.append(xRange->getString());
+            }
+        }
+        return aBuf.getLength();
+    }
+
+    uno::Reference<lang::XComponent> mxComponent;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8tok/ww8tok.cxx b/sw/qa/extras/ww8tok/ww8tok.cxx
index a7e2ae8..6a3ec74 100644
--- a/sw/qa/extras/ww8tok/ww8tok.cxx
+++ b/sw/qa/extras/ww8tok/ww8tok.cxx
@@ -25,24 +25,21 @@
  * instead of those above.
  */
 
+#include "../swmodeltestbase.hxx"
+
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/text/XDependentTextField.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
 #include <vcl/svapp.hxx>
 
 using rtl::OString;
 using rtl::OUString;
 using rtl::OUStringBuffer;
-using namespace com::sun::star;
 
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public SwModelTestBase
 {
 public:
-    virtual void setUp();
-    virtual void tearDown();
     void testN757910();
 
     CPPUNIT_TEST_SUITE(Test);
@@ -54,7 +51,6 @@ public:
 private:
     /// Load a WW8 file and make the document available via mxComponent.
     void load(const OUString& rURL);
-    uno::Reference<lang::XComponent> mxComponent;
 };
 
 void Test::load(const OUString& rFilename)
@@ -62,22 +58,6 @@ void Test::load(const OUString& rFilename)
     mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ww8tok/data/") + rFilename);
 }
 
-void Test::setUp()
-{
-    test::BootstrapFixture::setUp();
-
-    mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
-    CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void Test::tearDown()
-{
-    if (mxComponent.is())
-        mxComponent->dispose();
-
-    test::BootstrapFixture::tearDown();
-}
-
 void Test::testN757910()
 {
     load("n757910.doc");


More information about the Libreoffice-commits mailing list