LCOV - code coverage report
Current view: top level - sc/qa/extras - scdatabaserangeobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 37 37 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/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          24 : 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           4 :     CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
      36           2 :     CPPUNIT_TEST(testDataArea);
      37           2 :     CPPUNIT_TEST(testGetSortDescriptor);
      38           2 :     CPPUNIT_TEST(testGetSubtotalDescriptor);
      39           2 :     CPPUNIT_TEST(testGetImportDescriptor);
      40           2 :     CPPUNIT_TEST(testGetFilterDescriptor);
      41           2 :     CPPUNIT_TEST(testRefresh);
      42           4 :     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           2 : uno::Reference< lang::XComponent > ScDatabaseRangeObj::mxComponent;
      50             : 
      51          12 : ScDatabaseRangeObj::ScDatabaseRangeObj()
      52          12 :       : CalcUnoApiTest("/sc/qa/extras/testdocuments")
      53             : {
      54          12 : }
      55             : 
      56          12 : uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const OUString& rDBName )
      57             : {
      58          12 :     OUString aFileURL;
      59          12 :     createFileURL("ScDatabaseRangeObj.ods", aFileURL);
      60          12 :     if(!mxComponent.is())
      61           2 :         mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
      62          12 :     CPPUNIT_ASSERT(mxComponent.is());
      63             : 
      64          24 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      65          24 :     uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW);
      66          24 :     uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue("DatabaseRanges"), UNO_QUERY_THROW);
      67          24 :     uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
      68          12 :     CPPUNIT_ASSERT(xDBRange.is());
      69          24 :     return xDBRange;
      70             : }
      71             : 
      72          12 : void ScDatabaseRangeObj::setUp()
      73             : {
      74          12 :     nTest++;
      75          12 :     CalcUnoApiTest::setUp();
      76          12 : }
      77             : 
      78          12 : void ScDatabaseRangeObj::tearDown()
      79             : {
      80          12 :     if (nTest == NUMBER_OF_TESTS)
      81             :     {
      82           2 :         closeDocument(mxComponent);
      83           2 :         mxComponent.clear();
      84             :     }
      85             : 
      86          12 :     CalcUnoApiTest::tearDown();
      87          12 : }
      88             : 
      89           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj);
      90             : 
      91             : }
      92             : 
      93           8 : CPPUNIT_PLUGIN_IMPLEMENT();
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10