[Libreoffice-commits] core.git: sc/qa test/source

Jens Carl j.carl43 at gmx.de
Thu Feb 1 02:17:36 UTC 2018


 sc/qa/extras/scdatapilottableobj.cxx       |   64 ++++++++++++-----------------
 test/source/sheet/xdatapilotdescriptor.cxx |    7 ---
 2 files changed, 28 insertions(+), 43 deletions(-)

New commits:
commit e587def20d1735474857f56dd3d2c06cf7673db3
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Wed Jan 31 21:10:56 2018 +0000

    Remove shared mxComponent in scdatapilottableobj
    
    Change-Id: I2cf424ecfa2748cfca0f85bab8da820c6286d331
    Reviewed-on: https://gerrit.libreoffice.org/49061
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx
index b7919b6890c6..ebc14b04191b 100644
--- a/sc/qa/extras/scdatapilottableobj.cxx
+++ b/sc/qa/extras/scdatapilottableobj.cxx
@@ -8,11 +8,12 @@
  */
 
 #include <test/calc_unoapi_test.hxx>
+#include <test/container/xnamed.hxx>
+#include <test/sheet/xdatapilotdescriptor.hxx>
 #include <test/sheet/xdatapilottable.hxx>
 #include <test/sheet/xdatapilottable2.hxx>
-#include <test/sheet/xdatapilotdescriptor.hxx>
-#include <test/container/xnamed.hxx>
 
+#include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/sheet/XSpreadsheet.hpp>
 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
@@ -24,10 +25,11 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 16
-
-class ScDataPilotTableObj : public CalcUnoApiTest, public apitest::XDataPilotDescriptor, public apitest::XDataPilotTable,
-                                public apitest::XNamed, public apitest::XDataPilotTable2
+class ScDataPilotTableObj : public CalcUnoApiTest,
+                            public apitest::XDataPilotDescriptor,
+                            public apitest::XDataPilotTable,
+                            public apitest::XDataPilotTable2,
+                            public apitest::XNamed
 {
 public:
     ScDataPilotTableObj();
@@ -39,9 +41,8 @@ public:
     virtual uno::Reference< uno::XInterface > getSheets() override;
 
     CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
-    CPPUNIT_TEST(testRefresh);
-    //CPPUNIT_TEST(testGetHiddenFields);
-    CPPUNIT_TEST(testGetOutputRange);
+
+    // XDataPilotDescriptor
     CPPUNIT_TEST(testSourceRange);
     CPPUNIT_TEST(testTag);
     CPPUNIT_TEST(testGetFilterDescriptor);
@@ -50,22 +51,28 @@ public:
     CPPUNIT_TEST(testGetRowFields);
     CPPUNIT_TEST(testGetPageFields);
     CPPUNIT_TEST(testGetDataFields);
-    CPPUNIT_TEST(testGetName);
-    CPPUNIT_TEST(testSetName);
+    //CPPUNIT_TEST(testGetHiddenFields);
+
+    // XDataPilotTable
+    CPPUNIT_TEST(testGetOutputRange);
+    CPPUNIT_TEST(testRefresh);
+
+    // XDataPilotTable2
     CPPUNIT_TEST(testGetDrillDownData);
     CPPUNIT_TEST(testInsertDrillDownSheet);
     CPPUNIT_TEST(testGetPositionData);
     CPPUNIT_TEST(testGetOutputRangeByType);
+
+    // XNamed
+    CPPUNIT_TEST(testGetName);
+    CPPUNIT_TEST(testSetName);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
-    static sal_Int32 nTest;
-    static uno::Reference< lang::XComponent > mxComponent;
+    uno::Reference< lang::XComponent > mxComponent;
 };
 
-sal_Int32 ScDataPilotTableObj::nTest = 0;
-uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
-
 ScDataPilotTableObj::ScDataPilotTableObj()
     : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
       apitest::XNamed("DataPilotTable")
@@ -74,12 +81,6 @@ ScDataPilotTableObj::ScDataPilotTableObj()
 
 uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
 {
-    OUString aFileURL;
-    createFileURL("ScDataPilotTableObj.ods", aFileURL);
-    if(!mxComponent.is())
-        mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
-    CPPUNIT_ASSERT(mxComponent.is());
-
     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
 
@@ -113,12 +114,6 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::getSheets()
 
 uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
 {
-    OUString aFileURL;
-    createFileURL("ScDataPilotTableObj.ods", aFileURL);
-    if(!mxComponent.is())
-        mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
-    CPPUNIT_ASSERT(mxComponent.is());
-
     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
@@ -143,19 +138,16 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
 
 void ScDataPilotTableObj::setUp()
 {
-    nTest++;
-    CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
     CalcUnoApiTest::setUp();
+    // create a calc document
+    OUString aFileURL;
+    createFileURL("ScDataPilotTableObj.ods", aFileURL);
+    mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
 }
 
 void ScDataPilotTableObj::tearDown()
 {
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        closeDocument(mxComponent);
-        mxComponent.clear();
-    }
-
+    closeDocument(mxComponent);
     CalcUnoApiTest::tearDown();
 }
 
diff --git a/test/source/sheet/xdatapilotdescriptor.cxx b/test/source/sheet/xdatapilotdescriptor.cxx
index 5315734eb5ad..33557a72fa99 100644
--- a/test/source/sheet/xdatapilotdescriptor.cxx
+++ b/test/source/sheet/xdatapilotdescriptor.cxx
@@ -69,13 +69,6 @@ void XDataPilotDescriptor::testGetFilterDescriptor()
 
 void XDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > const & xDescr)
 {
-    //this method should only be called once but needs to be called before any of the other tests
-    static bool bCalled = false;
-    if (bCalled)
-        return;
-    else
-        bCalled = true;
-
     uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW);
     CPPUNIT_ASSERT( xIndex.is());
 


More information about the Libreoffice-commits mailing list