LCOV - code coverage report
Current view: top level - sc/qa/extras - scdatapilotfieldobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 46 46 100.0 %
Date: 2015-06-13 12:38:46 Functions: 15 16 93.8 %
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/xdatapilotfieldgrouping.hxx>
      12             : #include <test/sheet/datapilotfield.hxx>
      13             : 
      14             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      15             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      16             : #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
      17             : #include <com/sun/star/sheet/XDataPilotTables.hpp>
      18             : #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
      19             : 
      20             : using namespace css;
      21             : using namespace css::uno;
      22             : 
      23             : namespace sc_apitest {
      24             : 
      25             : #define NUMBER_OF_TESTS 6
      26             : 
      27          12 : class ScDataPilotFieldObj : public CalcUnoApiTest, apitest::XDataPilotFieldGrouping,
      28             :                                 apitest::DataPilotField
      29             : {
      30             : public:
      31             :     virtual void setUp() SAL_OVERRIDE;
      32             :     virtual void tearDown() SAL_OVERRIDE;
      33             :     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
      34             : 
      35             :     ScDataPilotFieldObj();
      36             : 
      37           2 :     CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
      38           1 :     CPPUNIT_TEST(testSortInfo);
      39           1 :     CPPUNIT_TEST(testLayoutInfo);
      40           1 :     CPPUNIT_TEST(testAutoShowInfo);
      41           1 :     CPPUNIT_TEST(testReference);
      42           1 :     CPPUNIT_TEST(testIsGroupField);
      43           1 :     CPPUNIT_TEST(testCreateNameGroup);
      44             :     // see fdo#
      45             :     //CPPUNIT_TEST(testCreateDateGroup);
      46           5 :     CPPUNIT_TEST_SUITE_END();
      47             : private:
      48             :     static sal_Int32 nTest;
      49             :     static uno::Reference< lang::XComponent > mxComponent;
      50             : };
      51             : 
      52             : sal_Int32 ScDataPilotFieldObj::nTest = 0;
      53           1 : uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
      54             : 
      55           6 : ScDataPilotFieldObj::ScDataPilotFieldObj()
      56           6 :      : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      57             : {
      58           6 : }
      59             : 
      60           6 : uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
      61             : {
      62           6 :     OUString aFileURL;
      63           6 :     createFileURL(OUString("scdatapilotfieldobj.ods"), aFileURL);
      64           6 :     if(!mxComponent.is())
      65           1 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      66           6 :     CPPUNIT_ASSERT(mxComponent.is());
      67             : 
      68          12 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      69          12 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      70          12 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
      71             : 
      72           6 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
      73          12 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
      74           6 :     CPPUNIT_ASSERT(xDPTS.is());
      75          12 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
      76           6 :     CPPUNIT_ASSERT(xDPT.is());
      77          12 :     uno::Sequence<OUString> aElementNames = xDPT->getElementNames();
      78             :     (void) aElementNames;
      79             : 
      80          12 :     uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName("DataPilot1"),UNO_QUERY_THROW);
      81           6 :     CPPUNIT_ASSERT(xDPDsc.is());
      82          12 :     uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
      83           6 :     uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
      84           6 :     CPPUNIT_ASSERT(xReturnValue.is());
      85          12 :     return xReturnValue;
      86             : }
      87             : 
      88           6 : void ScDataPilotFieldObj::setUp()
      89             : {
      90           6 :     nTest++;
      91           6 :     CalcUnoApiTest::setUp();
      92           6 : }
      93             : 
      94           6 : void ScDataPilotFieldObj::tearDown()
      95             : {
      96           6 :     if (nTest == NUMBER_OF_TESTS)
      97             :     {
      98           1 :         closeDocument(mxComponent);
      99           1 :         mxComponent.clear();
     100             :     }
     101             : 
     102           6 :     CalcUnoApiTest::tearDown();
     103           6 : }
     104             : 
     105           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
     106             : 
     107             : }
     108             : 
     109           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11