LCOV - code coverage report
Current view: top level - sc/qa/extras - scannotationsobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 38 38 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 17 94.1 %
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 4
      24             : 
      25           8 : 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           1 :     CPPUNIT_TEST(testGetByIndex);
      41           5 :     CPPUNIT_TEST_SUITE_END();
      42             : private:
      43             : 
      44             :     static sal_Int32 nTest;
      45             :     static uno::Reference< lang::XComponent > mxComponent;
      46             : };
      47             : 
      48             : sal_Int32 ScAnnontationsObj::nTest = 0;
      49           1 : uno::Reference< lang::XComponent > ScAnnontationsObj::mxComponent;
      50             : 
      51           4 : ScAnnontationsObj::ScAnnontationsObj()
      52           4 :        : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      53             : {
      54           4 : }
      55             : 
      56           7 : uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations(long nIndex)
      57             : {
      58             :     // get the sheet
      59           7 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      60          14 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      61          14 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(nIndex), UNO_QUERY_THROW);
      62             : 
      63             :     // get the annotations collection
      64          14 :     uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
      65           7 :     uno::Reference< sheet::XSheetAnnotations > xSheetAnnotations( xAnnotationSupplier->getAnnotations(), UNO_QUERY_THROW);
      66             : 
      67           7 :     CPPUNIT_ASSERT(xSheetAnnotations.is());
      68             : 
      69          14 :     return xSheetAnnotations;
      70             : }
      71             : 
      72           4 : uno::Reference< uno::XInterface > ScAnnontationsObj::init()
      73             : {
      74             :     // get the test file
      75           4 :     OUString aFileURL;
      76           4 :     createFileURL(OUString("ScAnnotationObj.ods"), aFileURL);
      77           4 :     if(!mxComponent.is())
      78           1 :         mxComponent = loadFromDesktop(aFileURL);
      79           4 :     CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
      80             : 
      81           4 :     return getAnnotations(0);
      82             : }
      83           4 : void ScAnnontationsObj::setUp()
      84             : {
      85           4 :     nTest++;
      86           4 :     CalcUnoApiTest::setUp();
      87           4 : }
      88             : 
      89           4 : void ScAnnontationsObj::tearDown()
      90             : {
      91           4 :     if (nTest == NUMBER_OF_TESTS)
      92             :     {
      93           1 :         closeDocument(mxComponent);
      94           1 :         mxComponent.clear();
      95             :     }
      96             : 
      97           4 :     CalcUnoApiTest::tearDown();
      98           4 : }
      99             : 
     100           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationsObj);
     101             : 
     102             : }
     103             : 
     104           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11