LCOV - code coverage report
Current view: top level - sc/qa/extras - sctablesheetsobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 47 95.7 %
Date: 2014-11-03 Functions: 14 16 87.5 %
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/xspreadsheets2.hxx>
      12             : #include <test/container/xnamecontainer.hxx>
      13             : 
      14             : #include <com/sun/star/beans/XPropertySet.hpp>
      15             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      16             : 
      17             : using namespace css;
      18             : using namespace css::uno;
      19             : 
      20             : namespace sc_apitest {
      21             : 
      22             : #define NUMBER_OF_TESTS 11
      23             : 
      24          44 : class ScTableSheetsObj : public CalcUnoApiTest, public ::apitest::XSpreadsheets2, apitest::XNameContainer
      25             : {
      26             : public:
      27             :     ScTableSheetsObj();
      28             : 
      29             :     virtual void setUp() SAL_OVERRIDE;
      30             :     virtual void tearDown() SAL_OVERRIDE;
      31             : 
      32           4 :     CPPUNIT_TEST_SUITE(ScTableSheetsObj);
      33           2 :     CPPUNIT_TEST(testImportedSheetNameAndIndex);
      34           2 :     CPPUNIT_TEST(testImportString);
      35           2 :     CPPUNIT_TEST(testImportValue);
      36           2 :     CPPUNIT_TEST(testImportFormulaBasicMath);
      37           2 :     CPPUNIT_TEST(testImportFormulaWithNamedRange);
      38           2 :     CPPUNIT_TEST(testImportOverExistingNamedRange);
      39           2 :     CPPUNIT_TEST(testImportNamedRangeDefinedInSource);
      40           2 :     CPPUNIT_TEST(testImportNamedRangeRedefinedInSource);
      41           2 :     CPPUNIT_TEST(testImportNewNamedRange);
      42           2 :     CPPUNIT_TEST(testImportCellStyle);
      43           2 :     CPPUNIT_TEST(testRemoveByName);
      44           4 :     CPPUNIT_TEST_SUITE_END();
      45             : 
      46             :     virtual uno::Reference< lang::XComponent > getComponent() SAL_OVERRIDE;
      47             :     virtual void createFileURL(const OUString& rFileBase, OUString& rFileURL) SAL_OVERRIDE;
      48             :     virtual uno::Reference< lang::XComponent > loadFromDesktop(const OUString& rString) SAL_OVERRIDE;
      49             :     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
      50             : protected:
      51             :     static uno::Reference< lang::XComponent > mxComponent;
      52             :     static sal_Int32 nTest;
      53             : };
      54             : 
      55           2 : uno::Reference< lang::XComponent > ScTableSheetsObj::mxComponent;
      56             : sal_Int32 ScTableSheetsObj::nTest = 0;
      57             : 
      58          22 : ScTableSheetsObj::ScTableSheetsObj():
      59             :             CalcUnoApiTest("/sc/qa/extras/testdocuments"),
      60          22 :             apitest::XNameContainer(OUString("Sheet2"))
      61             : {
      62             : 
      63          22 : }
      64             : 
      65           0 : uno::Reference< lang::XComponent > ScTableSheetsObj::getComponent()
      66             : {
      67           0 :     return mxComponent;
      68             : }
      69             : 
      70          42 : void ScTableSheetsObj::createFileURL(const OUString& rFileBase, OUString& rFileURL)
      71             : {
      72          42 :     CalcUnoApiTest::createFileURL(rFileBase, rFileURL);
      73          42 : }
      74             : 
      75          22 : uno::Reference< lang::XComponent > ScTableSheetsObj::loadFromDesktop(const OUString& rString)
      76             : {
      77          22 :     return CalcUnoApiTest::loadFromDesktop(rString);
      78             : }
      79             : 
      80          22 : uno::Reference< uno::XInterface > ScTableSheetsObj::init()
      81             : {
      82          22 :     OUString aFileURL;
      83          22 :     createFileURL(OUString("rangenamessrc.ods"), aFileURL);
      84          22 :     if(!mxComponent.is())
      85           2 :         mxComponent = loadFromDesktop(aFileURL);
      86          22 :     CPPUNIT_ASSERT(mxComponent.is());
      87          22 :     xDocument = uno::Reference< sheet::XSpreadsheetDocument >(mxComponent, UNO_QUERY_THROW);
      88          22 :     uno::Reference< uno::XInterface > xReturn( xDocument->getSheets(), UNO_QUERY_THROW);
      89             : 
      90          22 :     return xReturn;
      91             : }
      92             : 
      93          22 : void ScTableSheetsObj::setUp()
      94             : {
      95          22 :     nTest++;
      96          22 :     CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
      97          22 :     CalcUnoApiTest::setUp();
      98          22 : }
      99             : 
     100          22 : void ScTableSheetsObj::tearDown()
     101             : {
     102          22 :     if (nTest == NUMBER_OF_TESTS)
     103             :     {
     104           2 :         closeDocument(mxComponent);
     105           2 :         mxComponent.clear();
     106             :     }
     107             : 
     108          22 :     CalcUnoApiTest::tearDown();
     109          22 : }
     110             : 
     111           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj);
     112             : 
     113             : }
     114             : 
     115           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10