From 2f3d6644197a98e1c191df7943da3e50e80d606f Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 28 Sep 2011 15:32:14 +0100 Subject: more unit test cut/paste redux --- sc/CppunitTest_sc_ucalc.mk | 1 + sc/qa/unit/filters-test.cxx | 4 --- sc/qa/unit/ucalc.cxx | 85 ++------------------------------------------- 3 files changed, 3 insertions(+), 87 deletions(-) (limited to 'sc') diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk index c7a6b2f81b66..5bd1e5c160dc 100644 --- a/sc/CppunitTest_sc_ucalc.mk +++ b/sc/CppunitTest_sc_ucalc.mk @@ -63,6 +63,7 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sc_ucalc, \ svt \ svx \ svxcore \ + test \ tk \ tl \ ucbhelper \ diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 45916ff3f384..dfc4cc9db6da 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -29,12 +29,8 @@ #include #include - #include #include -#include - -#include #include #include diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index b3f6fd3f8ad9..aae35e3e8633 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -26,39 +26,12 @@ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable * instead of those above. */ - -// TODO ... -// officecfg: can we move this into our skeleton ? -// Solve the Setup.xcu problem pleasantly [ custom version ? ] -// deliver.pl -// don't call regcomp if we don't have it. -// In an ideal world -// a) scp2 goes away and logic moved into the deliver d.lst -// b) install set gets built incrementally as the build progresses -// c) the new .xml component registration stuff then removes -// the need for manually calling regcomp and knowing what -// services we need, and in what .so they are implemented - - #include -#include "sal/precppunit.hxx" - -#include "cppunit/TestAssert.h" -#include "cppunit/TestFixture.h" -#include "cppunit/extensions/HelperMacros.h" -#include "cppunit/plugin/TestPlugIn.h" +#include #include #include -#include - -#include -#include -#include -#include -#include -#include #include "scdll.hxx" #include "document.hxx" #include "stringutil.hxx" @@ -234,10 +207,9 @@ private: MatrixType maMatrix; }; -class Test : public CppUnit::TestFixture { +class Test : public test::BootstrapFixture { public: Test(); - ~Test(); virtual void setUp(); virtual void tearDown(); @@ -312,62 +284,14 @@ public: CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< uno::XComponentContext > m_xContext; ScDocument *m_pDoc; ScDocShellRef m_xDocShRef; - ::rtl::OUString m_aSrcRoot; }; Test::Test() : m_pDoc(0) - , m_aSrcRoot(RTL_CONSTASCII_USTRINGPARAM("file://")) { - m_xContext = cppu::defaultBootstrap_InitialComponentContext(); - - uno::Reference xFactory(m_xContext->getServiceManager()); - uno::Reference xSM(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 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 xUcb = - ucbhelper::ContentBroker::get()->getContentProviderManagerInterface(); - uno::Reference 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); ScDLL::Init(); - - 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 Test::setUp() @@ -385,11 +309,6 @@ void Test::tearDown() m_xDocShRef.Clear(); } -Test::~Test() -{ - uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose(); -} - void Test::testCollator() { OUString s1(RTL_CONSTASCII_USTRINGPARAM("A")); -- cgit