LCOV - code coverage report
Current view: top level - sc/qa/extras - scdatapilottableobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 80 81 98.8 %
Date: 2014-11-03 Functions: 14 15 93.3 %
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          64 : 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           4 :     CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
      42           2 :     CPPUNIT_TEST(testRefresh);
      43             :     //CPPUNIT_TEST(testGetHiddenFields);
      44           2 :     CPPUNIT_TEST(testGetOutputRange);
      45           2 :     CPPUNIT_TEST(testSourceRange);
      46           2 :     CPPUNIT_TEST(testTag);
      47           2 :     CPPUNIT_TEST(testGetFilterDescriptor);
      48           2 :     CPPUNIT_TEST(testGetDataPilotFields);
      49           2 :     CPPUNIT_TEST(testGetColumnFields);
      50           2 :     CPPUNIT_TEST(testGetRowFields);
      51           2 :     CPPUNIT_TEST(testGetPageFields);
      52           2 :     CPPUNIT_TEST(testGetDataFields);
      53           2 :     CPPUNIT_TEST(testGetName);
      54           2 :     CPPUNIT_TEST(testSetName);
      55           2 :     CPPUNIT_TEST(testGetDrillDownData);
      56           2 :     CPPUNIT_TEST(testInsertDrillDownSheet);
      57           2 :     CPPUNIT_TEST(testGetPositionData);
      58           2 :     CPPUNIT_TEST(testGetOutputRangeByType);
      59           4 :     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           2 : uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
      68             : 
      69          32 : ScDataPilotTableObj::ScDataPilotTableObj()
      70             :     : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
      71          32 :       apitest::XNamed(OUString("DataPilotTable"))
      72             : {
      73          32 : }
      74             : 
      75          24 : uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
      76             : {
      77          24 :     OUString aFileURL;
      78          24 :     createFileURL("ScDataPilotTableObj.ods", aFileURL);
      79          24 :     if(!mxComponent.is())
      80           2 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      81          24 :     CPPUNIT_ASSERT(mxComponent.is());
      82             : 
      83          48 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      84          48 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      85          48 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
      86             : 
      87             :     // set variables from xdatapilottable.[ch]xx
      88          24 :     xCellForChange = xSheet->getCellByPosition( 1, 5 );
      89          24 :     xCellForCheck = xSheet->getCellByPosition( 7, 11 );
      90          24 :     CPPUNIT_ASSERT(xCellForCheck.is());
      91          24 :     CPPUNIT_ASSERT(xCellForChange.is());
      92             : 
      93          24 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
      94          48 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
      95          24 :     CPPUNIT_ASSERT(xDPTS.is());
      96          48 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
      97          24 :     CPPUNIT_ASSERT(xDPT.is());
      98             : 
      99          48 :     uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName("DataPilotTable"),UNO_QUERY_THROW);
     100             : 
     101          24 :     CPPUNIT_ASSERT(xDPTable.is());
     102          48 :     return xDPTable;
     103             : }
     104             : 
     105           2 : uno::Reference< uno::XInterface > ScDataPilotTableObj::getSheets()
     106             : {
     107           2 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     108           2 :     uno::Reference< uno::XInterface > xSheets(xDoc->getSheets());
     109           2 :     return xSheets;
     110             : }
     111             : 
     112           8 : uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
     113             : {
     114           8 :     OUString aFileURL;
     115           8 :     createFileURL(OUString("ScDataPilotTableObj.ods"), aFileURL);
     116           8 :     if(!mxComponent.is())
     117           0 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
     118           8 :     CPPUNIT_ASSERT(mxComponent.is());
     119             : 
     120          16 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
     121          16 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
     122          16 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
     123             : 
     124             :     // set variables from xdatapilottable.[ch]xx
     125           8 :     xCellForChange = xSheet->getCellByPosition( 1, 5 );
     126           8 :     xCellForCheck = xSheet->getCellByPosition( 7, 11 );
     127           8 :     CPPUNIT_ASSERT(xCellForCheck.is());
     128           8 :     CPPUNIT_ASSERT(xCellForChange.is());
     129             : 
     130           8 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
     131          16 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
     132           8 :     CPPUNIT_ASSERT(xDPTS.is());
     133          16 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
     134           8 :     CPPUNIT_ASSERT(xDPT.is());
     135             : 
     136          16 :     uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName("DataPilotTable2"),UNO_QUERY_THROW);
     137             : 
     138           8 :     CPPUNIT_ASSERT(xDPTable.is());
     139          16 :     return xDPTable;
     140             : }
     141             : 
     142          32 : void ScDataPilotTableObj::setUp()
     143             : {
     144          32 :     nTest++;
     145          32 :     CalcUnoApiTest::setUp();
     146          32 : }
     147             : 
     148          32 : void ScDataPilotTableObj::tearDown()
     149             : {
     150          32 :     if (nTest == NUMBER_OF_TESTS)
     151             :     {
     152           2 :         closeDocument(mxComponent);
     153           2 :         mxComponent.clear();
     154             :     }
     155             : 
     156          32 :     CalcUnoApiTest::tearDown();
     157          32 : }
     158             : 
     159           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj);
     160             : 
     161             : }
     162             : 
     163           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10