LCOV - code coverage report
Current view: top level - sc/qa/extras - scnamedrangesobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 35 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/xnamedranges.hxx>
      12             : 
      13             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      14             : #include <com/sun/star/beans/XPropertySet.hpp>
      15             : #include <com/sun/star/sheet/XNamedRanges.hpp>
      16             : 
      17             : using namespace css;
      18             : using namespace css::uno;
      19             : 
      20             : namespace sc_apitest {
      21             : 
      22             : #define NUMBER_OF_TESTS 3
      23             : 
      24           6 : class ScNamedRangesObj : public CalcUnoApiTest, apitest::XNamedRanges
      25             : {
      26             : public:
      27             :     virtual void setUp() SAL_OVERRIDE;
      28             :     virtual void tearDown() SAL_OVERRIDE;
      29             : 
      30             :     virtual uno::Reference< uno::XInterface > init(sal_Int32 nSheet) SAL_OVERRIDE;
      31             : 
      32             :     ScNamedRangesObj();
      33             : 
      34           2 :     CPPUNIT_TEST_SUITE(ScNamedRangesObj);
      35           1 :     CPPUNIT_TEST(testAddNewByName);
      36           1 :     CPPUNIT_TEST(testAddNewFromTitles);
      37             :     //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
      38           1 :     CPPUNIT_TEST(testOutputList);
      39           5 :     CPPUNIT_TEST_SUITE_END();
      40             : 
      41             : private:
      42             :     static sal_Int32 nTest;
      43             :     static uno::Reference< lang::XComponent > mxComponent;
      44             : };
      45             : 
      46             : sal_Int32 ScNamedRangesObj::nTest = 0;
      47           1 : uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent;
      48             : 
      49           3 : ScNamedRangesObj::ScNamedRangesObj()
      50           3 :      : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      51             : {
      52           3 : }
      53             : 
      54           5 : uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
      55             : {
      56           5 :     OUString aFileURL;
      57           5 :     createFileURL(OUString("ScNamedRangeObj.ods"), aFileURL);
      58           5 :     if(!mxComponent.is())
      59           1 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      60           5 :     CPPUNIT_ASSERT(mxComponent.is());
      61             : 
      62          10 :     uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
      63          10 :     OUString aNamedRangesPropertyString("NamedRanges");
      64          10 :     uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
      65             : 
      66             :     //set value from xnamedranges.hxx
      67          10 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      68          10 :     uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW);
      69           5 :     xSheet = uno::Reference< sheet::XSpreadsheet >(xIndexAccess->getByIndex(nSheet),UNO_QUERY_THROW);
      70             : 
      71          10 :     return xNamedRanges;
      72             : }
      73             : 
      74           3 : void ScNamedRangesObj::setUp()
      75             : {
      76           3 :     nTest++;
      77           3 :     CalcUnoApiTest::setUp();
      78           3 : }
      79             : 
      80           3 : void ScNamedRangesObj::tearDown()
      81             : {
      82           3 :     if (nTest == NUMBER_OF_TESTS)
      83             :     {
      84           1 :         closeDocument(mxComponent);
      85           1 :         mxComponent.clear();
      86             :     }
      87             : 
      88           3 :     CalcUnoApiTest::tearDown();
      89           3 : }
      90             : 
      91           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj);
      92             : 
      93             : }
      94             : 
      95           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11