LCOV - code coverage report
Current view: top level - sc/qa/extras - scdatapilottableobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 80 81 98.8 %
Date: 2015-06-13 12:38:46 Functions: 17 18 94.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <test/calc_unoapi_test.hxx>
      11             : #include <test/sheet/xdatapilottable.hxx>
      12             : #include <test/sheet/xdatapilottable2.hxx>
      13             : #include <test/sheet/xdatapilotdescriptor.hxx>
      14             : #include <test/container/xnamed.hxx>
      15             : 
      16             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      17             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      18             : #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
      19             : #include <com/sun/star/sheet/XDataPilotTables.hpp>
      20             : #include <com/sun/star/sheet/XDataPilotTable.hpp>
      21             : 
      22             : using namespace css;
      23             : using namespace css::uno;
      24             : 
      25             : namespace sc_apitest {
      26             : 
      27             : #define NUMBER_OF_TESTS 16
      28             : 
      29          32 : class ScDataPilotTableObj : public CalcUnoApiTest, apitest::XDataPilotDescriptor, apitest::XDataPilotTable,
      30             :                                 apitest::XNamed, apitest::XDataPilotTable2
      31             : {
      32             : public:
      33             :     ScDataPilotTableObj();
      34             : 
      35             :     virtual void setUp() SAL_OVERRIDE;
      36             :     virtual void tearDown() SAL_OVERRIDE;
      37             :     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
      38             :     virtual uno::Reference< uno::XInterface > initDP2() SAL_OVERRIDE;
      39             :     virtual uno::Reference< uno::XInterface > getSheets() SAL_OVERRIDE;
      40             : 
      41           2 :     CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
      42           1 :     CPPUNIT_TEST(testRefresh);
      43             :     //CPPUNIT_TEST(testGetHiddenFields);
      44           1 :     CPPUNIT_TEST(testGetOutputRange);
      45           1 :     CPPUNIT_TEST(testSourceRange);
      46           1 :     CPPUNIT_TEST(testTag);
      47           1 :     CPPUNIT_TEST(testGetFilterDescriptor);
      48           1 :     CPPUNIT_TEST(testGetDataPilotFields);
      49           1 :     CPPUNIT_TEST(testGetColumnFields);
      50           1 :     CPPUNIT_TEST(testGetRowFields);
      51           1 :     CPPUNIT_TEST(testGetPageFields);
      52           1 :     CPPUNIT_TEST(testGetDataFields);
      53           1 :     CPPUNIT_TEST(testGetName);
      54           1 :     CPPUNIT_TEST(testSetName);
      55           1 :     CPPUNIT_TEST(testGetDrillDownData);
      56           1 :     CPPUNIT_TEST(testInsertDrillDownSheet);
      57           1 :     CPPUNIT_TEST(testGetPositionData);
      58           1 :     CPPUNIT_TEST(testGetOutputRangeByType);
      59           5 :     CPPUNIT_TEST_SUITE_END();
      60             : 
      61             : private:
      62             :     static sal_Int32 nTest;
      63             :     static uno::Reference< lang::XComponent > mxComponent;
      64             : };
      65             : 
      66             : sal_Int32 ScDataPilotTableObj::nTest = 0;
      67           1 : uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
      68             : 
      69          16 : ScDataPilotTableObj::ScDataPilotTableObj()
      70             :     : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
      71          16 :       apitest::XNamed(OUString("DataPilotTable"))
      72             : {
      73          16 : }
      74             : 
      75          12 : uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
      76             : {
      77          12 :     OUString aFileURL;
      78          12 :     createFileURL("ScDataPilotTableObj.ods", aFileURL);
      79          12 :     if(!mxComponent.is())
      80           1 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      81          12 :     CPPUNIT_ASSERT(mxComponent.is());
      82             : 
      83          24 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      84          24 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      85          24 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
      86             : 
      87             :     // set variables from xdatapilottable.[ch]xx
      88          12 :     xCellForChange = xSheet->getCellByPosition( 1, 5 );
      89          12 :     xCellForCheck = xSheet->getCellByPosition( 7, 11 );
      90          12 :     CPPUNIT_ASSERT(xCellForCheck.is());
      91          12 :     CPPUNIT_ASSERT(xCellForChange.is());
      92             : 
      93          12 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
      94          24 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
      95          12 :     CPPUNIT_ASSERT(xDPTS.is());
      96          24 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
      97          12 :     CPPUNIT_ASSERT(xDPT.is());
      98             : 
      99          24 :     uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName("DataPilotTable"),UNO_QUERY_THROW);
     100             : 
     101          12 :     CPPUNIT_ASSERT(xDPTable.is());
     102          24 :     return xDPTable;
     103             : }
     104             : 
     105           1 : uno::Reference< uno::XInterface > ScDataPilotTableObj::getSheets()
     106             : {
     107           1 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     108           1 :     uno::Reference< uno::XInterface > xSheets(xDoc->getSheets());
     109           1 :     return xSheets;
     110             : }
     111             : 
     112           4 : uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
     113             : {
     114           4 :     OUString aFileURL;
     115           4 :     createFileURL(OUString("ScDataPilotTableObj.ods"), aFileURL);
     116           4 :     if(!mxComponent.is())
     117           0 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
     118           4 :     CPPUNIT_ASSERT(mxComponent.is());
     119             : 
     120           8 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     121           8 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
     122           8 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
     123             : 
     124             :     // set variables from xdatapilottable.[ch]xx
     125           4 :     xCellForChange = xSheet->getCellByPosition( 1, 5 );
     126           4 :     xCellForCheck = xSheet->getCellByPosition( 7, 11 );
     127           4 :     CPPUNIT_ASSERT(xCellForCheck.is());
     128           4 :     CPPUNIT_ASSERT(xCellForChange.is());
     129             : 
     130           4 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
     131           8 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
     132           4 :     CPPUNIT_ASSERT(xDPTS.is());
     133           8 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
     134           4 :     CPPUNIT_ASSERT(xDPT.is());
     135             : 
     136           8 :     uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName("DataPilotTable2"),UNO_QUERY_THROW);
     137             : 
     138           4 :     CPPUNIT_ASSERT(xDPTable.is());
     139           8 :     return xDPTable;
     140             : }
     141             : 
     142          16 : void ScDataPilotTableObj::setUp()
     143             : {
     144          16 :     nTest++;
     145          16 :     CalcUnoApiTest::setUp();
     146          16 : }
     147             : 
     148          16 : void ScDataPilotTableObj::tearDown()
     149             : {
     150          16 :     if (nTest == NUMBER_OF_TESTS)
     151             :     {
     152           1 :         closeDocument(mxComponent);
     153           1 :         mxComponent.clear();
     154             :     }
     155             : 
     156          16 :     CalcUnoApiTest::tearDown();
     157          16 : }
     158             : 
     159           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj);
     160             : 
     161             : }
     162             : 
     163           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11