From db5a5ffa82f835c81cf9a411d24f4cb0b1bb8fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 12 Oct 2011 15:19:21 +0100 Subject: [PATCH] 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 --- .../CppunitTest_hwpfilter_test_hwpfilter.mk | 3 +- hwpfilter/qa/cppunit/test_hwpfilter.cxx | 9 +- ...unitTest_lotuswordpro_test_lotuswordpro.mk | 3 +- lotuswordpro/qa/cppunit/test_lotuswordpro.cxx | 11 +- sc/CppunitTest_sc_filters_test.mk | 5 +- sc/qa/unit/filters-test.cxx | 11 +- sot/CppunitTest_sot_test_sot.mk | 3 +- sot/prj/build.lst | 2 +- sot/qa/cppunit/data/pass/fdo41642-2.compound | Bin 0 -> 35335 bytes sot/qa/cppunit/test_sot.cxx | 16 ++- svtools/CppunitTest_svtools_filters_test.mk | 3 +- svtools/qa/cppunit/filters-test.cxx | 9 +- sw/CppunitTest_sw_filters_test.mk | 5 +- sw/qa/core/filters-test.cxx | 9 +- test/inc/test/bootstrapfixture.hxx | 22 +--- test/prj/d.lst | 1 - test/source/bootstrapfixture.cxx | 33 +----- test/source/makefile.mk | 3 +- unotest/inc/unotest/bootstrapfixturebase.hxx | 88 ++++++++++++++++ .../inc/unotest}/filters-test.hxx | 9 +- unotest/prj/build.lst | 2 +- unotest/prj/d.lst | 2 + unotest/source/cpp/bootstrapfixturebase.cxx | 98 ++++++++++++++++++ .../source/cpp}/filters-test.cxx | 5 +- unotest/source/cpp/makefile.mk | 3 + .../CppunitTest_writerfilter_rtftok.mk | 3 +- .../qa/cppunittests/rtftok/testrtftok.cxx | 9 +- 27 files changed, 262 insertions(+), 105 deletions(-) create mode 100644 sot/qa/cppunit/data/pass/fdo41642-2.compound create mode 100644 unotest/inc/unotest/bootstrapfixturebase.hxx rename {test/inc/test => unotest/inc/unotest}/filters-test.hxx (89%) create mode 100644 unotest/source/cpp/bootstrapfixturebase.cxx rename {test/source => unotest/source/cpp}/filters-test.cxx (98%) 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 +#include +#include #include #include @@ -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 +#include +#include #include #include @@ -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 -#include +#include +#include #include #include @@ -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 new file mode 100644 index 0000000000000000000000000000000000000000..b1ae6dd63046a5cb1d34e3c063cfaa81ef1c1a72 GIT binary patch liter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yv4Uj=IXTJ8N>9{<(8Cb9 zKOK4)@*e7l0I5xqajW-x{^y8jnnfZEz^{*fmtTsVPo<;riIh}t>?5Kken1gBl)ynb zex(ie$L_yK{!&IXCrHL*$22#DAA|h;?U>5C>#Iwacc2m3^_^q=WJ%*S0=_FDJ~}DW zrcDoi!OVaxW0GVcMvgCP8IrPkH~V`fqGNkxw|S$?W_p!85A%gM-# zX1X~>8q1kL4*Dff-{g;_UZtNl%8S7(&T?D)tw>xk)9Ot8pBSGUsHzxw^gfCrK$Zha zji|7qV#I}{tlkGI{IoMz)?xIa5I_3(N`#;oCF~NlKrzbSE=y2faL|onjKLp%V@*C~ zhDkBfPv4rqzDp$s-6#q=f(Wg2#DB;!NtzVZ@#ZMNqk4lJ5%hhb%kMg5Pbc|pHDZ!^n(xezB=R9}}Tj)peA~X{m zSiRdH^P^~$b&R7VkE2OZk=_~j6O45{ zt}ssq7h6K*K5Lj8Ggi+uI(+8~2&dk3z2*3T7M+Z-m zFj0yWM(T?!SJ?iUoav>88s!DcDO+r?L%#Q8g-wCnpFE_nd$A;W`=;0)+7dauI%@@vMXLyvjC?cbp2g3^CboP5%L7*T5GZdn&j=J%_=Ne-1lNUbfo2vmkwI1PWb-pEWF(tnl7 +#include +#include #include #include @@ -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 +#include +#include #include #include @@ -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 +#include +#include #include #include @@ -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 m_xContext; - com::sun::star::uno::Reference m_xSFactory; - com::sun::star::uno::Reference m_xFactory; public: BootstrapFixture( bool bAssertOnDialog = true, bool bNeedUCB = true ); virtual ~BootstrapFixture(); - com::sun::star::uno::Reference - getComponentContext() { return m_xContext; } - com::sun::star::uno::Reference - 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 (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 + * + * 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 + +#include +#include +#include +#include + +#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 m_xContext; + com::sun::star::uno::Reference m_xSFactory; + com::sun::star::uno::Reference m_xFactory; + +public: + BootstrapFixtureBase(); + virtual ~BootstrapFixtureBase(); + + com::sun::star::uno::Reference + getComponentContext() { return m_xContext; } + com::sun::star::uno::Reference + 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 similarity index 89% rename from test/inc/test/filters-test.hxx rename to 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 -#include -#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 + * Caolán McNamara + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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 (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 similarity index 98% rename from test/source/filters-test.cxx rename to 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 +#include #include #include #include -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 +#include +#include #include #include @@ -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"))),