Kaydet (Commit) 333ba462 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw: move common methods of subsequent filter tests to a SwModelTestBase

Change-Id: I71316d6c5b6f4fb820bd541be1cfbb4d39dd261e
üst f909446c
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
/*
* 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: */
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment