diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-05-09 15:25:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-05-09 15:30:12 +0200 |
commit | 333ba4627e4c6ae56377773b22526881388c335b (patch) | |
tree | f2039ffc6c58ae74a8ea5e494bfe136b7bac829c /sw/qa | |
parent | f909446caae6d4e091c2bb2dae36ae648491eef2 (diff) |
sw: move common methods of subsequent filter tests to a SwModelTestBase
Change-Id: I71316d6c5b6f4fb820bd541be1cfbb4d39dd261e
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmltok/ooxmltok.cxx | 27 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 48 | ||||
-rw-r--r-- | sw/qa/extras/rtftok/rtftok.cxx | 50 | ||||
-rw-r--r-- | sw/qa/extras/swmodeltestbase.hxx | 80 | ||||
-rw-r--r-- | sw/qa/extras/ww8tok/ww8tok.cxx | 26 |
5 files changed, 92 insertions, 139 deletions
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx index 00aa2c22530c..2c672d2c41b3 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 9f2cb1854ab3..74b0ca80841f 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 8b41569d826a..e7c51fa6bba4 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 000000000000..347d408c9b30 --- /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@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 a7e2ae8e2a40..6a3ec7423c4d 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"); |