diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-10-12 15:19:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-10-15 12:18:44 +0100 |
commit | db5a5ffa82f835c81cf9a411d24f4cb0b1bb8fa5 (patch) | |
tree | 0e320d48ea2ce24a87f33095d2959919333c0b5c | |
parent | 528a225ddb1d429eeb048626d5e9e045118bad2e (diff) |
split bootstrapfixture and move test-filters class for sot test
sot is below vcl, but is a filters test, we can split bootstrapfixture
into a vcl needing bit and and non-vcl bit and filters test api
can be standalone and combined with whichever bit in order to form
pre and post vcl filters test
27 files changed, 262 insertions, 105 deletions
diff --git a/hwpfilter/CppunitTest_hwpfilter_test_hwpfilter.mk b/hwpfilter/CppunitTest_hwpfilter_test_hwpfilter.mk index 01edac8988ba..a6c841cb9992 100644 --- a/hwpfilter/CppunitTest_hwpfilter_test_hwpfilter.mk +++ b/hwpfilter/CppunitTest_hwpfilter_test_hwpfilter.mk @@ -37,12 +37,13 @@ $(eval $(call gb_CppunitTest_add_exception_objects,hwpfilter_test_hwpfilter, \ )) $(eval $(call gb_CppunitTest_add_linked_libs,hwpfilter_test_hwpfilter, \ - test \ ucbhelper \ comphelper \ cppu \ cppuhelper \ sal \ + test \ + unotest \ $(gb_STDLIBS) \ )) diff --git a/hwpfilter/qa/cppunit/test_hwpfilter.cxx b/hwpfilter/qa/cppunit/test_hwpfilter.cxx index 2e96284da31f..cbd3aa0bdb20 100644 --- a/hwpfilter/qa/cppunit/test_hwpfilter.cxx +++ b/hwpfilter/qa/cppunit/test_hwpfilter.cxx @@ -26,7 +26,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <com/sun/star/document/XFilter.hpp> #include <osl/file.hxx> @@ -37,7 +38,9 @@ using namespace ::com::sun::star; namespace { - class HwpFilterTest : public test::FiltersTest + class HwpFilterTest + : public test::FiltersTest + , public test::BootstrapFixture { public: virtual void setUp(); @@ -53,7 +56,7 @@ namespace void HwpFilterTest::setUp() { - test::FiltersTest::setUp(); + test::BootstrapFixture::setUp(); m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( diff --git a/lotuswordpro/CppunitTest_lotuswordpro_test_lotuswordpro.mk b/lotuswordpro/CppunitTest_lotuswordpro_test_lotuswordpro.mk index 66aee3400ffe..0541ed888894 100644 --- a/lotuswordpro/CppunitTest_lotuswordpro_test_lotuswordpro.mk +++ b/lotuswordpro/CppunitTest_lotuswordpro_test_lotuswordpro.mk @@ -37,11 +37,12 @@ $(eval $(call gb_CppunitTest_add_exception_objects,lotuswordpro_test_lotuswordpr )) $(eval $(call gb_CppunitTest_add_linked_libs,lotuswordpro_test_lotuswordpro, \ - test \ comphelper \ cppu \ cppuhelper \ sal \ + test \ + unotest \ vcl \ $(gb_STDLIBS) \ )) diff --git a/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx b/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx index 7500e25317b7..1f1f4e032aa1 100644 --- a/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx +++ b/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx @@ -26,7 +26,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <com/sun/star/document/XFilter.hpp> #include <osl/file.hxx> @@ -36,10 +37,12 @@ using namespace ::com::sun::star; namespace { - class LotusWordProTest : public test::FiltersTest + class LotusWordProTest + : public test::FiltersTest + , public test::BootstrapFixture { public: - LotusWordProTest() : FiltersTest(true, false) {} + LotusWordProTest() : BootstrapFixture(true, false) {} virtual void setUp(); @@ -57,7 +60,7 @@ namespace void LotusWordProTest::setUp() { - test::FiltersTest::setUp(); + test::BootstrapFixture::setUp(); m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk index d6ea1b8b1eb7..38f013b31fef 100644 --- a/sc/CppunitTest_sc_filters_test.mk +++ b/sc/CppunitTest_sc_filters_test.mk @@ -35,7 +35,6 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_filters_test, \ )) $(eval $(call gb_CppunitTest_add_linked_libs,sc_filters_test, \ - test \ avmedia \ basegfx \ comphelper \ @@ -60,9 +59,11 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sc_filters_test, \ svt \ svx \ svxcore \ - tk \ + test \ tl \ + tk \ ucbhelper \ + unotest \ utl \ vbahelper \ vcl \ diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 38eb9401a63d..1faba35c5758 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -28,7 +28,8 @@ */ #include <sal/config.h> -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <rtl/strbuf.hxx> #include <osl/file.hxx> @@ -137,7 +138,9 @@ void testCondFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab) /* Implementation of Filters test */ -class ScFiltersTest : public test::FiltersTest +class ScFiltersTest + : public test::FiltersTest + , public test::BootstrapFixture { public: ScFiltersTest(); @@ -648,7 +651,7 @@ ScFiltersTest::ScFiltersTest() void ScFiltersTest::setUp() { - test::FiltersTest::setUp(); + test::BootstrapFixture::setUp(); // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure, // which is a private symbol to us, gets called @@ -661,7 +664,7 @@ void ScFiltersTest::setUp() void ScFiltersTest::tearDown() { uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose(); - test::FiltersTest::tearDown(); + test::BootstrapFixture::tearDown(); } CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest); diff --git a/sot/CppunitTest_sot_test_sot.mk b/sot/CppunitTest_sot_test_sot.mk index d3ac12fb251e..05365287c3ee 100644 --- a/sot/CppunitTest_sot_test_sot.mk +++ b/sot/CppunitTest_sot_test_sot.mk @@ -42,9 +42,8 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sot_test_sot, \ cppuhelper \ sal \ sot \ - test \ tl \ - vcl \ + unotest \ $(gb_STDLIBS) \ )) diff --git a/sot/prj/build.lst b/sot/prj/build.lst index 302881c0f94b..73434fb4dc71 100644 --- a/sot/prj/build.lst +++ b/sot/prj/build.lst @@ -1,2 +1,2 @@ -to sot : tools ucbhelper unotools test NULL +to sot : tools ucbhelper unotools unotest NULL to sot\prj nmake - all sot_prj NULL diff --git a/sot/qa/cppunit/data/pass/fdo41642-2.compound b/sot/qa/cppunit/data/pass/fdo41642-2.compound Binary files differnew file mode 100644 index 000000000000..b1ae6dd63046 --- /dev/null +++ b/sot/qa/cppunit/data/pass/fdo41642-2.compound diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx index 39d86cb71c9d..b695e8076e65 100644 --- a/sot/qa/cppunit/test_sot.cxx +++ b/sot/qa/cppunit/test_sot.cxx @@ -26,7 +26,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <unotest/bootstrapfixturebase.hxx> #include <osl/file.hxx> #include <osl/process.h> @@ -36,12 +37,12 @@ using namespace ::com::sun::star; namespace { - class SotTest : public test::FiltersTest + class SotTest + : public test::FiltersTest + , public test::BootstrapFixtureBase { public: - SotTest() : FiltersTest(false, false) {} - - virtual void setUp(); + SotTest() {} virtual bool load(const rtl::OUString &, const rtl::OUString &rURL, const rtl::OUString &); @@ -53,11 +54,6 @@ namespace CPPUNIT_TEST_SUITE_END(); }; - void SotTest::setUp() - { - test::FiltersTest::setUp(); - } - bool SotTest::load(const rtl::OUString &, const rtl::OUString &rURL, const rtl::OUString &) { diff --git a/svtools/CppunitTest_svtools_filters_test.mk b/svtools/CppunitTest_svtools_filters_test.mk index 8f4cd6a21559..3ccbd5d06c30 100644 --- a/svtools/CppunitTest_svtools_filters_test.mk +++ b/svtools/CppunitTest_svtools_filters_test.mk @@ -35,13 +35,14 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svtools_filters_test, \ )) $(eval $(call gb_CppunitTest_add_linked_libs,svtools_filters_test, \ - test \ comphelper \ cppu \ cppuhelper \ sal \ svt \ + test \ tl \ + unotest \ vcl \ $(gb_STDLIBS) \ )) diff --git a/svtools/qa/cppunit/filters-test.cxx b/svtools/qa/cppunit/filters-test.cxx index a216bc629a3a..a1c4a44947fd 100644 --- a/svtools/qa/cppunit/filters-test.cxx +++ b/svtools/qa/cppunit/filters-test.cxx @@ -27,7 +27,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <osl/file.hxx> #include <osl/process.h> @@ -38,10 +39,12 @@ using namespace ::com::sun::star; /* Implementation of Filters test */ -class SvtoolsFiltersTest : public test::FiltersTest +class SvtoolsFiltersTest + : public test::FiltersTest + , public test::BootstrapFixture { public: - SvtoolsFiltersTest() : FiltersTest(true, false) {} + SvtoolsFiltersTest() : BootstrapFixture(true, false) {} virtual bool load(const rtl::OUString &, const rtl::OUString &rURL, const rtl::OUString &); diff --git a/sw/CppunitTest_sw_filters_test.mk b/sw/CppunitTest_sw_filters_test.mk index 720adae32a90..7726115a3624 100644 --- a/sw/CppunitTest_sw_filters_test.mk +++ b/sw/CppunitTest_sw_filters_test.mk @@ -43,15 +43,16 @@ $(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 \ svt \ - vcl \ + test \ tl \ ucbhelper \ + unotest \ utl \ + vcl \ i18nisolang1 \ comphelper \ cppu \ diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx index 84bb4be3f8fd..cd63ebec9909 100644 --- a/sw/qa/core/filters-test.cxx +++ b/sw/qa/core/filters-test.cxx @@ -27,7 +27,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <sfx2/app.hxx> #include <sfx2/docfilt.hxx> @@ -48,7 +49,9 @@ using namespace ::com::sun::star; /* Implementation of Filters test */ -class SwFiltersTest : public test::FiltersTest +class SwFiltersTest + : public test::FiltersTest + , public test::BootstrapFixture { public: bool load(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData); @@ -92,7 +95,7 @@ void SwFiltersTest::testCVEs() void SwFiltersTest::setUp() { - test::FiltersTest::setUp(); + test::BootstrapFixture::setUp(); //This is a bit of a fudge, we do this to ensure that SwGlobals::ensure, //which is a private symbol to us, gets called diff --git a/test/inc/test/bootstrapfixture.hxx b/test/inc/test/bootstrapfixture.hxx index 3c7a91f4180e..3b9a40f515d0 100644 --- a/test/inc/test/bootstrapfixture.hxx +++ b/test/inc/test/bootstrapfixture.hxx @@ -40,6 +40,7 @@ #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" +#include "unotest/bootstrapfixturebase.hxx" #include "test/testdllapi.hxx" namespace test { @@ -51,34 +52,15 @@ namespace test { // NB. this class is instantiated multiple times during a // run of unit tests ... -class OOO_DLLPUBLIC_TEST BootstrapFixture : public CppUnit::TestFixture +class OOO_DLLPUBLIC_TEST BootstrapFixture : public BootstrapFixtureBase { bool m_bNeedUCB; bool m_bAssertOnDialog; - ::rtl::OUString m_aSrcRootURL; - ::rtl::OUString m_aSrcRootPath; - -protected: - - com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> m_xContext; - com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> m_xSFactory; - com::sun::star::uno::Reference<com::sun::star::lang::XMultiComponentFactory> m_xFactory; public: BootstrapFixture( bool bAssertOnDialog = true, bool bNeedUCB = true ); virtual ~BootstrapFixture(); - com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> - getComponentContext() { return m_xContext; } - com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> - getMultiServiceFactory() { return m_xSFactory; } - - ::rtl::OUString getSrcRootURL() { return m_aSrcRootURL; } - ::rtl::OUString getSrcRootPath() { return m_aSrcRootPath; } - - // return a URL to a given c-str path from the source directory - ::rtl::OUString getURLFromSrc( const char *pPath ); - virtual void setUp(); virtual void tearDown(); }; diff --git a/test/prj/d.lst b/test/prj/d.lst index 84491d1f2198..9211e33b9131 100644 --- a/test/prj/d.lst +++ b/test/prj/d.lst @@ -6,4 +6,3 @@ mkdir: %_DEST%\inc\test ..\%__SRC%\lib\libtest.dll.a %_DEST%\lib\libtest.dll.a ..\inc\test\testdllapi.hxx %_DEST%\inc\test\testdllapi.hxx ..\inc\test\bootstrapfixture.hxx %_DEST%\inc\test\bootstrapfixture.hxx -..\inc\test\filters-test.hxx %_DEST%\inc\test\filters-test.hxx diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index 5f246979e8ec..dccd3a4b08c6 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -61,18 +61,7 @@ static void aBasicErrorFunc( const String &rErr, const String &rAction ) test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB ) : m_bNeedUCB( bNeedUCB ) , m_bAssertOnDialog( bAssertOnDialog ) - , m_aSrcRootURL(RTL_CONSTASCII_USTRINGPARAM("file://")) { - 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_aSrcRootURL += rtl::OUString::createFromAscii( "/" ); -#endif - m_aSrcRootPath = rtl::OUString::createFromAscii( pSrcRoot ); - m_aSrcRootURL += m_aSrcRootPath; - // force locale (and resource files loaded) to en-US const LanguageType eLang=LANGUAGE_ENGLISH_US; @@ -84,20 +73,7 @@ test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB ) void test::BootstrapFixture::setUp() { - // set UserInstallation to user profile dir in test/user-template - rtl::Bootstrap aDefaultVars; - aDefaultVars.set( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserInstallation") ), - getURLFromSrc("/test/user-template")); - - m_xContext = cppu::defaultBootstrap_InitialComponentContext(); - m_xFactory = m_xContext->getServiceManager(); - m_xSFactory = uno::Reference<lang::XMultiServiceFactory> (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(m_xSFactory); - + test::BootstrapFixtureBase::setUp(); if (m_bNeedUCB) { // initialise UCB-Broker @@ -128,16 +104,11 @@ void test::BootstrapFixture::setUp() void test::BootstrapFixture::tearDown() { ucbhelper::ContentBroker::get()->deinitialize(); - // uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose(); + test::BootstrapFixtureBase::tearDown(); } test::BootstrapFixture::~BootstrapFixture() { } -::rtl::OUString test::BootstrapFixture::getURLFromSrc( const char *pPath ) -{ - return m_aSrcRootURL + rtl::OUString::createFromAscii( pPath ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/source/makefile.mk b/test/source/makefile.mk index 6f68b71ae24d..63109a819019 100644 --- a/test/source/makefile.mk +++ b/test/source/makefile.mk @@ -38,8 +38,7 @@ CDEFS += -DOOO_DLLIMPLEMENTATION_TEST CFLAGSCXX += $(CPPUNIT_CFLAGS) SLOFILES = \ - $(SLO)/bootstrapfixture.obj \ - $(SLO)/filters-test.obj + $(SLO)/bootstrapfixture.obj .IF "$(CROSS_COMPILING)" == "YES" SHL1IMPLIB = $(SHL1TARGET) diff --git a/unotest/inc/unotest/bootstrapfixturebase.hxx b/unotest/inc/unotest/bootstrapfixturebase.hxx new file mode 100644 index 000000000000..6edd3f5b5643 --- /dev/null +++ b/unotest/inc/unotest/bootstrapfixturebase.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 or as specified alternatively below. 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. + * + * Major Contributor(s): + * Copyright (C) 2011 Michael Meeks <michael.meeks@suse.com> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * 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. + */ +#ifndef INCLUDED_UNOUNOTEST_BOOTSTRAPFIXTUREBASE_HXX +#define INCLUDED_UNOUNOTEST_BOOTSTRAPFIXTUREBASE_HXX + +#include <sal/config.h> + +#include <rtl/string.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> + +#include "sal/precppunit.hxx" +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "unotest/detail/unotestdllapi.hxx" + +namespace test { + +// Class to do lots of heavy-lifting UNO & environment +// bootstrapping for unit tests, such that we can use +// almost an entire LibreOffice during compile - so +// that we can get pieces of code alone to beat them up. + +// NB. this class is instantiated multiple times during a +// run of unit tests ... +class OOO_DLLPUBLIC_UNOTEST BootstrapFixtureBase : public CppUnit::TestFixture +{ +protected: + ::rtl::OUString m_aSrcRootURL; + ::rtl::OUString m_aSrcRootPath; + + com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> m_xContext; + com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> m_xSFactory; + com::sun::star::uno::Reference<com::sun::star::lang::XMultiComponentFactory> m_xFactory; + +public: + BootstrapFixtureBase(); + virtual ~BootstrapFixtureBase(); + + com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> + getComponentContext() { return m_xContext; } + com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> + getMultiServiceFactory() { return m_xSFactory; } + + ::rtl::OUString getSrcRootURL() { return m_aSrcRootURL; } + ::rtl::OUString getSrcRootPath() { return m_aSrcRootPath; } + + // return a URL to a given c-str path from the source directory + ::rtl::OUString getURLFromSrc( const char *pPath ); + + virtual void setUp(); + virtual void tearDown(); + +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/inc/test/filters-test.hxx b/unotest/inc/unotest/filters-test.hxx index 0cc77c09f4f4..974c1fa34ecc 100644 --- a/test/inc/test/filters-test.hxx +++ b/unotest/inc/unotest/filters-test.hxx @@ -28,8 +28,7 @@ */ #include <rtl/ustring.hxx> -#include <test/bootstrapfixture.hxx> -#include "test/testdllapi.hxx" +#include "unotest/detail/unotestdllapi.hxx" namespace test { @@ -47,13 +46,9 @@ enum filterStatus * e.g. m[de]crypt --bare -a arcfour -o hex -k 435645 -s 3 */ /* Implementation of Filters test */ -class OOO_DLLPUBLIC_TEST FiltersTest : public test::BootstrapFixture +class OOO_DLLPUBLIC_UNOTEST FiltersTest { public: - FiltersTest(bool bAssertOnDialog = true, bool bNeedUCB = true) - : BootstrapFixture(bAssertOnDialog, bNeedUCB) - {} - void testDir( //filter name const rtl::OUString &rFilter, diff --git a/unotest/prj/build.lst b/unotest/prj/build.lst index d3be738a1cae..1cbe6e324327 100644 --- a/unotest/prj/build.lst +++ b/unotest/prj/build.lst @@ -1,4 +1,4 @@ -unote unotest : BOOST:boost cppu cppuhelper CPPUNIT:cppunit javaunohelper offapi ridljar sal solenv stlport unoil qadevOOo NULL +unote unotest : BOOST:boost cppu cppuhelper comphelper CPPUNIT:cppunit javaunohelper offapi ridljar sal solenv unoil qadevOOo NULL unote unotest\source\cpp nmake - all source_cpp NULL unote unotest\source\cpp\unoexceptionprotector nmake - all source_cpp_unoexceptionprotector NULL unote unotest\source\java\org\openoffice\test nmake - all source_java NULL diff --git a/unotest/prj/d.lst b/unotest/prj/d.lst index af2c362474c3..a173c2f042ab 100644 --- a/unotest/prj/d.lst +++ b/unotest/prj/d.lst @@ -9,6 +9,8 @@ mkdir: %_DEST%\inc\unotest\detail ..\%__SRC%\lib\unoexceptionprotector.dylib %_DEST%\lib\unoexceptionprotector.dylib ..\%__SRC%\lib\unoexceptionprotector.so %_DEST%\lib\unoexceptionprotector.so ..\inc\unotest\detail\unotestdllapi.hxx %_DEST%\inc\unotest\detail\unotestdllapi.hxx +..\inc\unotest\bootstrapfixturebase.hxx %_DEST%\inc\unotest\bootstrapfixturebase.hxx +..\inc\unotest\filters-test.hxx %_DEST%\inc\unotest\filters-test.hxx ..\inc\unotest\gettestargument.hxx %_DEST%\inc\unotest\gettestargument.hxx ..\inc\unotest\officeconnection.hxx %_DEST%\inc\unotest\officeconnection.hxx ..\inc\unotest\oustringostreaminserter.hxx %_DEST%\inc\unotest\oustringostreaminserter.hxx diff --git a/unotest/source/cpp/bootstrapfixturebase.cxx b/unotest/source/cpp/bootstrapfixturebase.cxx new file mode 100644 index 000000000000..5748e338737b --- /dev/null +++ b/unotest/source/cpp/bootstrapfixturebase.cxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 or as specified alternatively below. 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. + * + * Major Contributor(s): + * Copyright (C) 2011 Michael Meeks <michael.meeks@suse.com> + * Caolán McNamara <caolanm@redhat.com> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * 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 <unotest/bootstrapfixturebase.hxx> +#include <tools/errinf.hxx> +#include <rtl/strbuf.hxx> +#include <rtl/bootstrap.hxx> +#include <cppuhelper/bootstrap.hxx> +#include <ucbhelper/contentbroker.hxx> +#include <comphelper/processfactory.hxx> +#include <i18npool/mslangid.hxx> + +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vcl/svapp.hxx> +#include <tools/resmgr.hxx> +#include <unotools/syslocaleoptions.hxx> + +using namespace ::com::sun::star; + +// NB. this constructor is called before any tests are run, once for each +// test function in a rather non-intuitive way. This is why all the 'real' +// heavy lifting is deferred until setUp. setUp and tearDown are interleaved +// between the tests as you might expect. +test::BootstrapFixtureBase::BootstrapFixtureBase() + : m_aSrcRootURL(RTL_CONSTASCII_USTRINGPARAM("file://")) +{ + 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_aSrcRootURL += rtl::OUString::createFromAscii( "/" ); +#endif + m_aSrcRootPath = rtl::OUString::createFromAscii( pSrcRoot ); + m_aSrcRootURL += m_aSrcRootPath; +} + +test::BootstrapFixtureBase::~BootstrapFixtureBase() +{ +} + +::rtl::OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath ) +{ + return m_aSrcRootURL + rtl::OUString::createFromAscii( pPath ); +} + +void test::BootstrapFixtureBase::setUp() +{ + // set UserInstallation to user profile dir in test/user-template + rtl::Bootstrap aDefaultVars; + aDefaultVars.set( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserInstallation") ), + getURLFromSrc("/test/user-template")); + + m_xContext = cppu::defaultBootstrap_InitialComponentContext(); + m_xFactory = m_xContext->getServiceManager(); + m_xSFactory = uno::Reference<lang::XMultiServiceFactory> (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(m_xSFactory); +} + +void test::BootstrapFixtureBase::tearDown() +{ + // uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose(); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/source/filters-test.cxx b/unotest/source/cpp/filters-test.cxx index f36e01494768..f3801da712dc 100644 --- a/test/source/filters-test.cxx +++ b/unotest/source/cpp/filters-test.cxx @@ -27,12 +27,13 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> #include <osl/file.hxx> #include <osl/thread.h> #include <rtl/cipher.h> -using namespace ::com::sun::star; +#include "sal/precppunit.hxx" +#include "cppunit/TestAssert.h" namespace test { diff --git a/unotest/source/cpp/makefile.mk b/unotest/source/cpp/makefile.mk index b28b1edb2b22..928a8b230681 100644 --- a/unotest/source/cpp/makefile.mk +++ b/unotest/source/cpp/makefile.mk @@ -38,6 +38,8 @@ CDEFS += -DOOO_DLLIMPLEMENTATION_UNOTEST CFLAGSCXX += $(CPPUNIT_CFLAGS) SLOFILES = \ + $(SLO)/bootstrapfixturebase.obj \ + $(SLO)/filters-test.obj \ $(SLO)/getargument.obj \ $(SLO)/gettestargument.obj \ $(SLO)/officeconnection.obj \ @@ -52,6 +54,7 @@ SHL1IMPLIB = i$(SHL1TARGET) SHL1OBJS = $(SLOFILES) SHL1RPATH = NONE SHL1STDLIBS = \ + $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(CPPUNITLIB) \ diff --git a/writerfilter/CppunitTest_writerfilter_rtftok.mk b/writerfilter/CppunitTest_writerfilter_rtftok.mk index a8639941b26c..a104cfe756ff 100644 --- a/writerfilter/CppunitTest_writerfilter_rtftok.mk +++ b/writerfilter/CppunitTest_writerfilter_rtftok.mk @@ -35,12 +35,13 @@ $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_rtftok, \ )) $(eval $(call gb_CppunitTest_add_linked_libs,writerfilter_rtftok, \ - test \ comphelper \ cppu \ cppuhelper \ sal \ + test \ ucbhelper \ + unotest \ vcl \ writerfilter \ $(gb_STDLIBS) \ diff --git a/writerfilter/qa/cppunittests/rtftok/testrtftok.cxx b/writerfilter/qa/cppunittests/rtftok/testrtftok.cxx index 9a012d3eec90..986c67fd8356 100644 --- a/writerfilter/qa/cppunittests/rtftok/testrtftok.cxx +++ b/writerfilter/qa/cppunittests/rtftok/testrtftok.cxx @@ -26,7 +26,8 @@ * instead of those above. */ -#include <test/filters-test.hxx> +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> #include <com/sun/star/document/XFilter.hpp> #include <osl/file.hxx> @@ -34,7 +35,9 @@ using namespace ::com::sun::star; -class RtfTest : public test::FiltersTest +class RtfTest + : public test::FiltersTest + , public test::BootstrapFixture { public: @@ -52,7 +55,7 @@ private: void RtfTest::setUp() { - test::FiltersTest::setUp(); + test::BootstrapFixture::setUp(); m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.RtfFilter"))), |