LCOV - code coverage report
Current view: top level - sc/qa/extras - scannotationsobj.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 37 37 100.0 %
Date: 2014-04-11 Functions: 13 14 92.9 %
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/xsheetannotations.hxx>
      12             : 
      13             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      14             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      15             : 
      16             : #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
      17             : 
      18             : using namespace css;
      19             : using namespace css::uno;
      20             : 
      21             : namespace sc_apitest {
      22             : 
      23             : #define NUMBER_OF_TESTS 3
      24             : 
      25           6 : class ScAnnontationsObj : public CalcUnoApiTest, apitest::XSheetAnnotations
      26             : {
      27             : public:
      28             :     ScAnnontationsObj();
      29             : 
      30             :     virtual void setUp() SAL_OVERRIDE;
      31             :     virtual void tearDown() SAL_OVERRIDE;
      32             : 
      33             :     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
      34             :     virtual uno::Reference< sheet::XSheetAnnotations > getAnnotations(long nIndex) SAL_OVERRIDE;
      35             : 
      36           2 :     CPPUNIT_TEST_SUITE(ScAnnontationsObj);
      37           1 :     CPPUNIT_TEST(testInsertNew);
      38           1 :     CPPUNIT_TEST(testRemoveByIndex);
      39           1 :     CPPUNIT_TEST(testCount);
      40           2 :     CPPUNIT_TEST_SUITE_END();
      41             : private:
      42             : 
      43             :     static sal_Int32 nTest;
      44             :     static uno::Reference< lang::XComponent > mxComponent;
      45             : };
      46             : 
      47             : sal_Int32 ScAnnontationsObj::nTest = 0;
      48           1 : uno::Reference< lang::XComponent > ScAnnontationsObj::mxComponent;
      49             : 
      50           3 : ScAnnontationsObj::ScAnnontationsObj()
      51           3 :        : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      52             : {
      53           3 : }
      54             : 
      55           4 : uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations(long nIndex)
      56             : {
      57             :     // get the sheet
      58           4 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      59           8 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      60           8 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(nIndex), UNO_QUERY_THROW);
      61             : 
      62             :     // get the annotations collection
      63           8 :     uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
      64           4 :     uno::Reference< sheet::XSheetAnnotations > xSheetAnnotations( xAnnotationSupplier->getAnnotations(), UNO_QUERY_THROW);
      65             : 
      66           4 :     CPPUNIT_ASSERT(xSheetAnnotations.is());
      67             : 
      68           8 :     return xSheetAnnotations;
      69             : }
      70             : 
      71           3 : uno::Reference< uno::XInterface > ScAnnontationsObj::init()
      72             : {
      73             :     // get the test file
      74           3 :     OUString aFileURL;
      75           3 :     createFileURL(OUString("ScAnnotationObj.ods"), aFileURL);
      76           3 :     if(!mxComponent.is())
      77           1 :         mxComponent = loadFromDesktop(aFileURL);
      78           3 :     CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
      79             : 
      80           3 :     return getAnnotations(0);
      81             : }
      82           3 : void ScAnnontationsObj::setUp()
      83             : {
      84           3 :     nTest++;
      85           3 :     CalcUnoApiTest::setUp();
      86           3 : }
      87             : 
      88           3 : void ScAnnontationsObj::tearDown()
      89             : {
      90           3 :     if (nTest == NUMBER_OF_TESTS)
      91           1 :         closeDocument(mxComponent);
      92             : 
      93           3 :     CalcUnoApiTest::tearDown();
      94           3 : }
      95             : 
      96           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationsObj);
      97             : 
      98           1 : CPPUNIT_PLUGIN_IMPLEMENT();
      99             : 
     100           3 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10