summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-10-05 16:00:44 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-05 16:02:28 +0100
commit8a0d0457a79836fa9d8ea8d4c48ecbf7bac2e95b (patch)
tree242935d062542ef2993a4e0bc3aeb3f188bef1a4 /sc
parent9767483eea7800aadd18b4489069ad633ce7a79c (diff)
test fix: use setUp and tearDown not constructors to init LibreOffice
It turns out the constructors are all run back-to-back one per filter, and we need to init and de-init in a sensible order to make multiple tests that otherwise share the ContentBroker work properly.
Diffstat (limited to 'sc')
-rw-r--r--sc/RdbTarget_sc_filters_test.mk1
-rw-r--r--sc/qa/unit/filters-test.cxx31
-rw-r--r--sc/qa/unit/ucalc.cxx6
3 files changed, 31 insertions, 7 deletions
diff --git a/sc/RdbTarget_sc_filters_test.mk b/sc/RdbTarget_sc_filters_test.mk
index a0d32bbd2420..d6d1bc8e909b 100644
--- a/sc/RdbTarget_sc_filters_test.mk
+++ b/sc/RdbTarget_sc_filters_test.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_RdbTarget_add_old_components,sc_filters_test,\
configmgr \
ucb1 \
ucpfile1 \
+ ucptdoc1 \
))
# vim: set noet sw=4 ts=4:
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index bdb899797281..766cb6bad32b 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -39,6 +39,7 @@
#include <editeng/brshitem.hxx>
#include <editeng/justifyitem.hxx>
+#include <basic/sbxdef.hxx>
#include "helper/csv_handler.hxx"
#include "orcus/csv_parser.hpp"
@@ -55,6 +56,7 @@
#define XLSX 2
using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
namespace {
@@ -140,6 +142,9 @@ public:
void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath);
+ virtual void setUp();
+ virtual void tearDown();
+
/**
* Ensure CVEs remain unbroken
*/
@@ -165,6 +170,7 @@ public:
CPPUNIT_TEST(testBugFixesODS);
CPPUNIT_TEST(testBugFixesXLS);
CPPUNIT_TEST(testBugFixesXLSX);
+
CPPUNIT_TEST_SUITE_END();
private:
@@ -178,16 +184,16 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr
sal_uInt32 nFormat = 0;
if (nFormatType)
nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
- SfxFilter aFilter(
+ SfxFilter* aFilter = new SfxFilter(
rFilter,
rtl::OUString(), nFormatType, nFormat, rTypeName, 0, rtl::OUString(),
rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
- aFilter.SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
ScDocShellRef xDocShRef = new ScDocShell;
- SfxMedium aSrcMed(rURL, STREAM_STD_READ, true);
- aSrcMed.SetFilter(&aFilter);
- if (!xDocShRef->DoLoad(&aSrcMed))
+ SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, true);
+ pSrcMed->SetFilter(aFilter);
+ if (!xDocShRef->DoLoad(pSrcMed))
// load failed.
xDocShRef.Clear();
else if (nFormatType)
@@ -281,6 +287,7 @@ void ScFiltersTest::testRangeName()
CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
testRangeNameImpl(pDoc);
+ xDocSh->DoClose();
}
}
@@ -537,8 +544,14 @@ void ScFiltersTest::testBugFixesXLSX()
}
ScFiltersTest::ScFiltersTest()
- : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
+ : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
+{
+}
+
+void ScFiltersTest::setUp()
{
+ test::FiltersTest::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
m_xCalcComponent =
@@ -547,6 +560,12 @@ ScFiltersTest::ScFiltersTest()
CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
}
+void ScFiltersTest::tearDown()
+{
+ uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
+ test::FiltersTest::tearDown();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index aae35e3e8633..0ccf27b0b5fe 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -291,11 +291,13 @@ private:
Test::Test()
: m_pDoc(0)
{
- ScDLL::Init();
}
void Test::setUp()
{
+ BootstrapFixture::setUp();
+
+ ScDLL::Init();
m_xDocShRef = new ScDocShell(
SFXMODEL_STANDARD |
SFXMODEL_DISABLE_EMBEDDED_SCRIPTS |
@@ -307,6 +309,8 @@ void Test::setUp()
void Test::tearDown()
{
m_xDocShRef.Clear();
+
+ BootstrapFixture::tearDown();
}
void Test::testCollator()