Kaydet (Commit) 00bf3c83 authored tarafından Jens Carl's avatar Jens Carl

Remove shared mxSourceComponent and mxTargetComponent (test documents)

in scstyleloaderobj

Change-Id: I7702f6458a56a9a4f8514a354505cf8f93ec8390
Reviewed-on: https://gerrit.libreoffice.org/48932Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 0d4ab5f6
...@@ -9,17 +9,16 @@ ...@@ -9,17 +9,16 @@
#include <test/calc_unoapi_test.hxx> #include <test/calc_unoapi_test.hxx>
#include <test/sheet/xstyleloader.hxx> #include <test/sheet/xstyleloader.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
using namespace css; using namespace css;
using namespace css::uno; using namespace css::uno;
namespace sc_apitest { namespace sc_apitest {
#define NUMBER_OF_TESTS 2
class ScStyleLoaderObj : public CalcUnoApiTest, public apitest::XStyleLoader class ScStyleLoaderObj : public CalcUnoApiTest, public apitest::XStyleLoader
{ {
public: public:
...@@ -29,97 +28,65 @@ public: ...@@ -29,97 +28,65 @@ public:
virtual void tearDown() override; virtual void tearDown() override;
virtual uno::Reference< uno::XInterface > init() override; virtual uno::Reference< uno::XInterface > init() override;
virtual uno::Reference< lang::XComponent > getTargetComponent() override; virtual uno::Reference< lang::XComponent > getTargetComponent() override;
virtual uno::Reference< lang::XComponent > getSourceComponent() override; virtual uno::Reference< lang::XComponent > getSourceComponent() override;
virtual OUString getTestURL() override; virtual OUString getTestURL() override;
CPPUNIT_TEST_SUITE(ScStyleLoaderObj); CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
// XStyleLoader
CPPUNIT_TEST(testLoadStylesFromURL); CPPUNIT_TEST(testLoadStylesFromURL);
CPPUNIT_TEST(testLoadStylesFromDocument); CPPUNIT_TEST(testLoadStylesFromDocument);
CPPUNIT_TEST_SUITE_END();
CPPUNIT_TEST_SUITE_END();
private: private:
uno::Reference< lang::XComponent > mxSourceComponent;
static sal_Int32 nTest; uno::Reference< lang::XComponent > mxTargetComponent;
static uno::Reference< lang::XComponent > mxSourceComponent;
static uno::Reference< lang::XComponent > mxTargetComponent;
}; };
sal_Int32 ScStyleLoaderObj::nTest = 0;
uno::Reference< lang::XComponent > ScStyleLoaderObj::mxSourceComponent;
uno::Reference< lang::XComponent > ScStyleLoaderObj::mxTargetComponent;
ScStyleLoaderObj::ScStyleLoaderObj() ScStyleLoaderObj::ScStyleLoaderObj()
: CalcUnoApiTest("sc/qa/extras/testdocuments") : CalcUnoApiTest("sc/qa/extras/testdocuments")
{ {
} }
uno::Reference< uno::XInterface > ScStyleLoaderObj::init() uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
{ {
return getTargetComponent(); return getTargetComponent();
} }
uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent()
uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent(){ {
// target is always an empty document // target is always an empty document
if (mxTargetComponent.is())
closeDocument(mxTargetComponent);
mxTargetComponent = loadFromDesktop("private:factory/scalc");
return mxTargetComponent; return mxTargetComponent;
} }
uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent(){ uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent()
{
if (mxSourceComponent.is()) CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
closeDocument(mxSourceComponent);
// get the test file url
OUString aFileURL = getTestURL();
if(!mxSourceComponent.is())
mxSourceComponent = loadFromDesktop(aFileURL);
CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
return mxSourceComponent; return mxSourceComponent;
} }
OUString ScStyleLoaderObj::getTestURL(){ OUString ScStyleLoaderObj::getTestURL()
{
OUString aFileURL; OUString aFileURL;
createFileURL("ScStyleLoaderObj.ods", aFileURL); createFileURL("ScStyleLoaderObj.ods", aFileURL);
return aFileURL; return aFileURL;
} }
void ScStyleLoaderObj::setUp() void ScStyleLoaderObj::setUp()
{ {
nTest++;
CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
CalcUnoApiTest::setUp(); CalcUnoApiTest::setUp();
mxTargetComponent = loadFromDesktop("private:factory/scalc");
// get the test file url
OUString aFileURL = getTestURL();
mxSourceComponent = loadFromDesktop(aFileURL);
} }
void ScStyleLoaderObj::tearDown() void ScStyleLoaderObj::tearDown()
{ {
if (nTest == NUMBER_OF_TESTS) closeDocument(mxSourceComponent);
{ closeDocument(mxTargetComponent);
if (mxSourceComponent.is())
{
closeDocument(mxSourceComponent);
mxSourceComponent.clear();
}
if (mxTargetComponent.is())
{
closeDocument(mxTargetComponent);
mxTargetComponent.clear();
}
}
CalcUnoApiTest::tearDown(); CalcUnoApiTest::tearDown();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment