LCOV - code coverage report
Current view: top level - libreoffice/sc/qa/extras - scdatapilotfieldobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 43 100.0 %
Date: 2012-12-17 Functions: 12 13 92.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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include <test/unoapi_test.hxx>
      30             : #include <test/sheet/xdatapilotfieldgrouping.hxx>
      31             : #include <test/sheet/datapilotfield.hxx>
      32             : 
      33             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      34             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      35             : #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
      36             : #include <com/sun/star/sheet/XDataPilotTables.hpp>
      37             : #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
      38             : 
      39             : namespace sc_apitest {
      40             : 
      41             : #define NUMBER_OF_TESTS 6
      42             : 
      43          36 : class ScDataPilotFieldObj : public UnoApiTest, apitest::XDataPilotFieldGrouping,
      44             :                                 apitest::DataPilotField
      45             : {
      46             : public:
      47             :     virtual void setUp();
      48             :     virtual void tearDown();
      49             :     virtual uno::Reference< uno::XInterface > init();
      50             : 
      51           4 :     CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
      52           2 :     CPPUNIT_TEST(testSortInfo);
      53           2 :     CPPUNIT_TEST(testLayoutInfo);
      54           2 :     CPPUNIT_TEST(testAutoShowInfo);
      55           2 :     CPPUNIT_TEST(testReference);
      56           2 :     CPPUNIT_TEST(testIsGroupField);
      57           2 :     CPPUNIT_TEST(testCreateNameGroup);
      58             :     // see fdo#
      59             :     //CPPUNIT_TEST(testCreateDateGroup);
      60           4 :     CPPUNIT_TEST_SUITE_END();
      61             : private:
      62             :     static sal_Int32 nTest;
      63             :     static uno::Reference< lang::XComponent > mxComponent;
      64             : };
      65             : 
      66             : sal_Int32 ScDataPilotFieldObj::nTest = 0;
      67           2 : uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
      68             : 
      69          12 : uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
      70             : {
      71          12 :     rtl::OUString aFileURL;
      72          12 :     createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")), aFileURL);
      73          12 :     if(!mxComponent.is())
      74           2 :         mxComponent = loadFromDesktop(aFileURL);
      75          12 :     CPPUNIT_ASSERT(mxComponent.is());
      76             : 
      77          12 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      78          12 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      79          12 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
      80             : 
      81          12 :     CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
      82          12 :     uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
      83          12 :     CPPUNIT_ASSERT(xDPTS.is());
      84          12 :     uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
      85          12 :     CPPUNIT_ASSERT(xDPT.is());
      86          12 :     uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
      87             : 
      88          12 :     uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW);
      89          12 :     CPPUNIT_ASSERT(xDPDsc.is());
      90          12 :     uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
      91          12 :     uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
      92          12 :     CPPUNIT_ASSERT(xReturnValue.is());
      93          12 :     return xReturnValue;
      94             : }
      95             : 
      96          12 : void ScDataPilotFieldObj::setUp()
      97             : {
      98          12 :     nTest++;
      99          12 :     UnoApiTest::setUp();
     100          12 : }
     101             : 
     102          12 : void ScDataPilotFieldObj::tearDown()
     103             : {
     104          12 :     if (nTest == NUMBER_OF_TESTS)
     105           2 :         closeDocument(mxComponent);
     106             : 
     107          12 :     UnoApiTest::tearDown();
     108          12 : }
     109             : 
     110           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
     111             : 
     112           2 : CPPUNIT_PLUGIN_IMPLEMENT();
     113             : 
     114           6 : }
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10