diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-01-17 12:41:31 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-01-18 18:12:11 +0100 |
commit | 7fb6d6250792311d1a55d7435569c0b89efecba6 (patch) | |
tree | 489bc57b4078937a8008c25474c92e31aae887fb /sc/qa | |
parent | correctly terminate cellproperties (diff) | |
download | core-7fb6d6250792311d1a55d7435569c0b89efecba6.tar.gz core-7fb6d6250792311d1a55d7435569c0b89efecba6.zip |
terminate xdatabaserange correctly
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/xdatabaserange.cxx | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/sc/qa/extras/xdatabaserange.cxx b/sc/qa/extras/xdatabaserange.cxx index 64a4f09b61da..22a2680c9805 100644 --- a/sc/qa/extras/xdatabaserange.cxx +++ b/sc/qa/extras/xdatabaserange.cxx @@ -34,14 +34,18 @@ #include <com/sun/star/sheet/XDatabaseRange.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> #include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <rtl/oustringostreaminserter.hxx> namespace ScDatabaseRangeObj { +#define NUMBER_OF_TESTS 3 + class ScXDatabaseRange : public UnoApiTest { - uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName); + virtual void setUp(); + virtual void tearDown(); void testDataArea(); void testGetSortDescriptor(); @@ -52,8 +56,16 @@ class ScXDatabaseRange : public UnoApiTest CPPUNIT_TEST(testGetSortDescriptor); CPPUNIT_TEST(testGetSubtotalDescriptor); CPPUNIT_TEST_SUITE_END(); +private: + uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName); + + static int nTest; + static uno::Reference< lang::XComponent > xComponent; }; +int ScXDatabaseRange::nTest = 0; +uno::Reference< lang::XComponent > ScXDatabaseRange::xComponent; + /** * tests setDataArea and getDataArea */ @@ -154,7 +166,6 @@ uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUStri const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods")); createFileURL(aFileBase, aFileURL); std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - static uno::Reference< lang::XComponent > xComponent; if( !xComponent.is()) xComponent = loadFromDesktop(aFileURL); uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); @@ -166,6 +177,29 @@ uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUStri return xDBRange; } +void ScXDatabaseRange::setUp() +{ + nTest += 1; + UnoApiTest::setUp(); +} + +void ScXDatabaseRange::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); + xCloseable->close( false ); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScXDatabaseRange); CPPUNIT_PLUGIN_IMPLEMENT(); |