LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/qa/extras - scannotationsobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 36 100.0 %
Date: 2013-07-09 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/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 2
      24             : 
      25           4 : class ScAnnontationsObj : public UnoApiTest, apitest::XSheetAnnotations
      26             : {
      27             : public:
      28             :     ScAnnontationsObj();
      29             : 
      30             :     virtual void setUp();
      31             :     virtual void tearDown();
      32             : 
      33             :     virtual uno::Reference< uno::XInterface > init();
      34             :     virtual uno::Reference< sheet::XSheetAnnotations> getAnnotations();
      35             : 
      36           2 :     CPPUNIT_TEST_SUITE(ScAnnontationsObj);
      37           1 :     CPPUNIT_TEST(testInsertNew);
      38           1 :     CPPUNIT_TEST(testRemoveByIndex);
      39           2 :     CPPUNIT_TEST_SUITE_END();
      40             : private:
      41             : 
      42             :     static sal_Int32 nTest;
      43             :     static uno::Reference< lang::XComponent > mxComponent;
      44             : };
      45             : 
      46             : sal_Int32 ScAnnontationsObj::nTest = 0;
      47           1 : uno::Reference< lang::XComponent > ScAnnontationsObj::mxComponent;
      48             : 
      49           2 : ScAnnontationsObj::ScAnnontationsObj()
      50           2 :        : UnoApiTest("/sc/qa/extras/testdocuments")
      51             : {
      52           2 : }
      53             : 
      54           2 : uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations()
      55             : {
      56             :     // get the sheet
      57           2 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      58           4 :     uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
      59           4 :     uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
      60             : 
      61             :     // get the annotations collection
      62           4 :     uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
      63           2 :     uno::Reference< sheet::XSheetAnnotations > xSheetAnnotations( xAnnotationSupplier->getAnnotations(), UNO_QUERY_THROW);
      64             : 
      65           2 :     CPPUNIT_ASSERT(xSheetAnnotations.is());
      66             : 
      67           4 :     return xSheetAnnotations;
      68             : }
      69             : 
      70           2 : uno::Reference< uno::XInterface > ScAnnontationsObj::init()
      71             : {
      72             :     // get the test file
      73           2 :     OUString aFileURL;
      74           2 :     createFileURL(OUString("ScAnnotationObj.ods"), aFileURL);
      75           2 :     if(!mxComponent.is())
      76           1 :         mxComponent = loadFromDesktop(aFileURL);
      77           2 :     CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
      78             : 
      79           2 :     return getAnnotations();
      80             : }
      81             : 
      82           2 : void ScAnnontationsObj::setUp()
      83             : {
      84           2 :     nTest++;
      85           2 :     UnoApiTest::setUp();
      86           2 : }
      87             : 
      88           2 : void ScAnnontationsObj::tearDown()
      89             : {
      90           2 :     if (nTest == NUMBER_OF_TESTS)
      91           1 :         closeDocument(mxComponent);
      92             : 
      93           2 :     UnoApiTest::tearDown();
      94           2 : }
      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