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

Generated by: LCOV version 1.11