LCOV - code coverage report
Current view: top level - sc/qa/extras - scnamedrangesobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 35 100.0 %
Date: 2014-11-03 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             :  * 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          12 : 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           4 :     CPPUNIT_TEST_SUITE(ScNamedRangesObj);
      35           2 :     CPPUNIT_TEST(testAddNewByName);
      36           2 :     CPPUNIT_TEST(testAddNewFromTitles);
      37             :     //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
      38           2 :     CPPUNIT_TEST(testOutputList);
      39           4 :     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           2 : uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent;
      48             : 
      49           6 : ScNamedRangesObj::ScNamedRangesObj()
      50           6 :      : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      51             : {
      52           6 : }
      53             : 
      54          10 : uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
      55             : {
      56          10 :     OUString aFileURL;
      57          10 :     createFileURL(OUString("ScNamedRangeObj.ods"), aFileURL);
      58          10 :     if(!mxComponent.is())
      59           2 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      60          10 :     CPPUNIT_ASSERT(mxComponent.is());
      61             : 
      62          20 :     uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
      63          20 :     OUString aNamedRangesPropertyString("NamedRanges");
      64          20 :     uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
      65             : 
      66             :     //set value from xnamedranges.hxx
      67          20 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      68          20 :     uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW);
      69          10 :     xSheet = uno::Reference< sheet::XSpreadsheet >(xIndexAccess->getByIndex(nSheet),UNO_QUERY_THROW);
      70             : 
      71          20 :     return xNamedRanges;
      72             : }
      73             : 
      74           6 : void ScNamedRangesObj::setUp()
      75             : {
      76           6 :     nTest++;
      77           6 :     CalcUnoApiTest::setUp();
      78           6 : }
      79             : 
      80           6 : void ScNamedRangesObj::tearDown()
      81             : {
      82           6 :     if (nTest == NUMBER_OF_TESTS)
      83             :     {
      84           2 :         closeDocument(mxComponent);
      85           2 :         mxComponent.clear();
      86             :     }
      87             : 
      88           6 :     CalcUnoApiTest::tearDown();
      89           6 : }
      90             : 
      91           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj);
      92             : 
      93             : }
      94             : 
      95           8 : CPPUNIT_PLUGIN_IMPLEMENT();
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10