summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-09-28 15:09:00 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-09-28 15:09:49 +0100
commit37fd0d9884b41491bc14d9b4e00ad1f9a00dd712 (patch)
tree06f68e8e2390a2ce14a6324f4bec0d16121cbad7 /sw
parent4b7cc85c4ed02876a1e4851274129d0d89c398cc (diff)
sw: switch filters-test to the new shared unit test code
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_swdoc_test.mk1
-rw-r--r--sw/CppunitTest_sw_test_filters.mk1
-rw-r--r--sw/qa/core/filters-test.cxx109
-rw-r--r--sw/qa/core/swdoc-test.cxx50
4 files changed, 26 insertions, 135 deletions
diff --git a/sw/CppunitTest_sw_swdoc_test.mk b/sw/CppunitTest_sw_swdoc_test.mk
index 0c9c1bc0fe3a..d1ea1d3e06c0 100644
--- a/sw/CppunitTest_sw_swdoc_test.mk
+++ b/sw/CppunitTest_sw_swdoc_test.mk
@@ -58,6 +58,7 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sw_swdoc_test, \
svx \
svxcore \
swd \
+ test \
tk \
tl \
ucbhelper \
diff --git a/sw/CppunitTest_sw_test_filters.mk b/sw/CppunitTest_sw_test_filters.mk
index ba5f1a4542e0..6541bf75ffaa 100644
--- a/sw/CppunitTest_sw_test_filters.mk
+++ b/sw/CppunitTest_sw_test_filters.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_filters_test, \
$(call gb_CxxObject_get_target,sw/qa/core/filters-test): $(WORKDIR)/AllLangRes/sw
$(eval $(call gb_CppunitTest_add_linked_libs,sw_filters_test, \
+ test \
sw \
sfx \
svl \
diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index 9084c1e351d4..6bd2ba80f90c 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -27,34 +27,14 @@
* instead of those above.
*/
-#include "sal/config.h"
-#include "sal/precppunit.hxx"
-
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
+#include <sal/config.h>
+#include <test/bootstrapfixture.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
-#include <cppuhelper/compbase1.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/basemutex.hxx>
-
-#include <comphelper/processfactory.hxx>
-
-#include <i18npool/mslangid.hxx>
-
#include <tools/urlobj.hxx>
-#include <unotools/tempfile.hxx>
-#include <unotools/syslocaleoptions.hxx>
-
-#include <vcl/svapp.hxx>
-
-#include <ucbhelper/contentbroker.hxx>
-
#include <sfx2/app.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
@@ -76,11 +56,10 @@ using namespace ::com::sun::star;
/* Implementation of Filters test */
-class FiltersTest : public CppUnit::TestFixture
+class FiltersTest : public test::BootstrapFixture
{
public:
FiltersTest();
- ~FiltersTest();
virtual void setUp();
virtual void tearDown();
@@ -88,9 +67,7 @@ public:
void recursiveScan(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData, int nExpected);
bool load(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData);
- /**
- * Ensure CVEs remain unbroken
- */
+ // Ensure CVEs remain unbroken
void testCVEs();
CPPUNIT_TEST_SUITE(FiltersTest);
@@ -98,8 +75,6 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- uno::Reference<uno::XComponentContext> m_xContext;
- uno::Reference<lang::XMultiComponentFactory> m_xFactory;
uno::Reference<uno::XInterface> m_xWriterComponent;
::rtl::OUString m_aSrcRoot;
int m_nLoadedDocs;
@@ -172,86 +147,44 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
void FiltersTest::testCVEs()
{
- recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/xml/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), true);
+ recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")),
+ getURLFromSrc("/sw/qa/core/data/xml/pass"),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), true);
- recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/xml/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), false);
+ recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")),
+ getURLFromSrc("/sw/qa/core/data/xml/fail"),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), false);
- recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), true);
+ recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")),
+ getURLFromSrc("/sw/qa/core/data/ww8/pass"),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), true);
- recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), false);
+ recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")),
+ getURLFromSrc("/sw/qa/core/data/ww8/fail"),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), false);
- recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/indeterminate")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), indeterminate);
+ recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")),
+ getURLFromSrc("/sw/qa/core/data/ww8/indeterminate"),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), indeterminate);
printf("Writer: tested %d files\n", m_nLoadedDocs);
}
FiltersTest::FiltersTest()
- : m_aSrcRoot(RTL_CONSTASCII_USTRINGPARAM("file://"))
- , m_nLoadedDocs(0)
+ : m_nLoadedDocs(0)
{
- m_xContext = cppu::defaultBootstrap_InitialComponentContext();
- m_xFactory = m_xContext->getServiceManager();
-
- uno::Reference<lang::XMultiServiceFactory> xSM(m_xFactory, uno::UNO_QUERY_THROW);
-
- //Without this we're crashing because callees are using
- //getProcessServiceFactory. In general those should be removed in favour
- //of retaining references to the root ServiceFactory as its passed around
- comphelper::setProcessServiceFactory(xSM);
-
- // initialise UCB-Broker
- uno::Sequence<uno::Any> aUcbInitSequence(2);
- aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
- aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
- bool bInitUcb = ucbhelper::ContentBroker::initialize(xSM, aUcbInitSequence);
- CPPUNIT_ASSERT_MESSAGE("Should be able to initialize UCB", bInitUcb);
-
- uno::Reference<ucb::XContentProviderManager> xUcb =
- ucbhelper::ContentBroker::get()->getContentProviderManagerInterface();
- uno::Reference<ucb::XContentProvider> xFileProvider(xSM->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.FileContentProvider"))), uno::UNO_QUERY);
- xUcb->registerContentProvider(xFileProvider, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file")), sal_True);
-
- // force locale (and resource files loaded) to en-US
- const LanguageType eLang=LANGUAGE_ENGLISH_US;
-
- rtl::OUString aLang, aCountry;
- MsLangId::convertLanguageToIsoNames(eLang, aLang, aCountry);
- lang::Locale aLocale(aLang, aCountry, rtl::OUString());
- ResMgr::SetDefaultLocale( aLocale );
-
- SvtSysLocaleOptions aLocalOptions;
- aLocalOptions.SetUILocaleConfigString(
- MsLangId::convertLanguageToIsoString( eLang ) );
-
- InitVCL(xSM);
-
//This is a bit of a fudge, we do this to ensure that SwGlobals::ensure,
//which is a private symbol to us, gets called
m_xWriterComponent =
- xSM->createInstance(rtl::OUString(
+ getMultiServiceFactory()->createInstance(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.TextDocument")));
CPPUNIT_ASSERT_MESSAGE("no writer component!", m_xWriterComponent.is());
-
- const char* pSrcRoot = getenv( "SRC_ROOT" );
- CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != NULL && pSrcRoot[0] != 0);
-
-#ifdef WNT
- if (pSrcRoot[1] == ':')
- m_aSrcRoot += rtl::OUString::createFromAscii( "/" );
-#endif
- m_aSrcRoot += rtl::OUString::createFromAscii( pSrcRoot );
}
void FiltersTest::setUp()
{
}
-FiltersTest::~FiltersTest()
-{
- uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
-}
-
void FiltersTest::tearDown()
{
}
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index cb120309ce54..e707cbd59df2 100644
--- a/sw/qa/core/swdoc-test.cxx
+++ b/sw/qa/core/swdoc-test.cxx
@@ -28,31 +28,15 @@
* instead of those above.
*/
-#include "sal/config.h"
-#include "sal/precppunit.hxx"
-
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
+#include <sal/config.h>
+#include <test/bootstrapfixture.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
-#include <cppuhelper/compbase1.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/basemutex.hxx>
-
-#include <comphelper/processfactory.hxx>
-
#include <tools/urlobj.hxx>
-
#include <unotools/tempfile.hxx>
-#include <ucbhelper/contentbroker.hxx>
-
-#include <vcl/svapp.hxx>
-
#include <sfx2/app.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
@@ -79,7 +63,7 @@ using namespace ::com::sun::star;
/* Implementation of Swdoc-Test class */
-class SwDocTest : public CppUnit::TestFixture
+class SwDocTest : public test::BootstrapFixture
{
public:
SwDocTest();
@@ -105,8 +89,6 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- uno::Reference<uno::XComponentContext> m_xContext;
- uno::Reference<lang::XMultiComponentFactory> m_xFactory;
SwDoc *m_pDoc;
SwDocShellRef m_xDocShRef;
};
@@ -462,32 +444,6 @@ void SwDocTest::randomTest()
SwDocTest::SwDocTest()
{
- m_xContext = cppu::defaultBootstrap_InitialComponentContext();
- m_xFactory = m_xContext->getServiceManager();
-
- uno::Reference<lang::XMultiServiceFactory> xSM(m_xFactory, uno::UNO_QUERY_THROW);
-
- //Without this we're crashing because callees are using
- //getProcessServiceFactory. In general those should be removed in favour
- //of retaining references to the root ServiceFactory as its passed around
- comphelper::setProcessServiceFactory(xSM);
-
- // initialise UCB-Broker
- uno::Sequence<uno::Any> aUcbInitSequence(2);
- aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
- aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
- bool bInitUcb = ucbhelper::ContentBroker::initialize(xSM, aUcbInitSequence);
- CPPUNIT_ASSERT_MESSAGE("Should be able to initialize UCB", bInitUcb);
-
- uno::Reference<ucb::XContentProviderManager> xUcb =
- ucbhelper::ContentBroker::get()->getContentProviderManagerInterface();
- uno::Reference<ucb::XContentProvider> xFileProvider(xSM->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.FileContentProvider"))), uno::UNO_QUERY);
- xUcb->registerContentProvider(xFileProvider, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file")), sal_True);
-
-
- InitVCL(xSM);
-
SwGlobals::ensure();
}