sc/qa/extras/scstyleloaderobj.cxx |   83 +++++++++++---------------------------
 1 file changed, 25 insertions(+), 58 deletions(-)

New commits:
commit 00bf3c837120fa95bfa9df5cc4de33bacb9b5288
Author: Jens Carl <j.car...@gmx.de>
Date:   Tue Jan 30 20:17:28 2018 +0000

    Remove shared mxSourceComponent and mxTargetComponent (test documents)
    
    in scstyleloaderobj
    
    Change-Id: I7702f6458a56a9a4f8514a354505cf8f93ec8390
    Reviewed-on: https://gerrit.libreoffice.org/48932
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Jens Carl <j.car...@gmx.de>

diff --git a/sc/qa/extras/scstyleloaderobj.cxx 
b/sc/qa/extras/scstyleloaderobj.cxx
index e9a2a2170c29..ef4e9d5e9bfe 100644
--- a/sc/qa/extras/scstyleloaderobj.cxx
+++ b/sc/qa/extras/scstyleloaderobj.cxx
@@ -9,17 +9,16 @@
 
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/xstyleloader.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 
-
 using namespace css;
 using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 2
-
 class ScStyleLoaderObj : public CalcUnoApiTest, public apitest::XStyleLoader
 {
 public:
@@ -29,97 +28,65 @@ public:
     virtual void tearDown() 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 OUString getTestURL() override;
 
     CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
+
+    // XStyleLoader
     CPPUNIT_TEST(testLoadStylesFromURL);
     CPPUNIT_TEST(testLoadStylesFromDocument);
-    CPPUNIT_TEST_SUITE_END();
 
+    CPPUNIT_TEST_SUITE_END();
 private:
-
-    static sal_Int32 nTest;
-    static uno::Reference< lang::XComponent > mxSourceComponent;
-    static uno::Reference< lang::XComponent > mxTargetComponent;
-
-
+    uno::Reference< lang::XComponent > mxSourceComponent;
+    uno::Reference< lang::XComponent > mxTargetComponent;
 };
 
-sal_Int32 ScStyleLoaderObj::nTest = 0;
-uno::Reference< lang::XComponent > ScStyleLoaderObj::mxSourceComponent;
-uno::Reference< lang::XComponent > ScStyleLoaderObj::mxTargetComponent;
-
-
 ScStyleLoaderObj::ScStyleLoaderObj()
-       : CalcUnoApiTest("sc/qa/extras/testdocuments")
+    : CalcUnoApiTest("sc/qa/extras/testdocuments")
 {
 }
 
-
 uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
 {
-  return getTargetComponent();
+    return getTargetComponent();
 }
 
-
-uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent(){
-  // target is always an empty document
-
-    if (mxTargetComponent.is())
-        closeDocument(mxTargetComponent);
-
-    mxTargetComponent = loadFromDesktop("private:factory/scalc");
-
+uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent()
+{
+    // target is always an empty document
     return mxTargetComponent;
 }
 
-uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent(){
-
-    if (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());
-
+uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent()
+{
+    CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
     return mxSourceComponent;
 }
 
-OUString ScStyleLoaderObj::getTestURL(){
-
+OUString ScStyleLoaderObj::getTestURL()
+{
       OUString aFileURL;
       createFileURL("ScStyleLoaderObj.ods", aFileURL);
-
       return aFileURL;
 }
 
 void ScStyleLoaderObj::setUp()
 {
-    nTest++;
-    CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
     CalcUnoApiTest::setUp();
+
+    mxTargetComponent = loadFromDesktop("private:factory/scalc");
+    // get the test file url
+    OUString aFileURL = getTestURL();
+    mxSourceComponent = loadFromDesktop(aFileURL);
 }
 
 void ScStyleLoaderObj::tearDown()
 {
-    if (nTest == NUMBER_OF_TESTS)
-    {
-      if (mxSourceComponent.is())
-      {
-          closeDocument(mxSourceComponent);
-          mxSourceComponent.clear();
-      }
-      if (mxTargetComponent.is())
-      {
-          closeDocument(mxTargetComponent);
-          mxTargetComponent.clear();
-      }
-    }
+    closeDocument(mxSourceComponent);
+    closeDocument(mxTargetComponent);
     CalcUnoApiTest::tearDown();
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to