LCOV - code coverage report
Current view: top level - libreoffice/sc/qa/extras - scdatabaserangeobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 34 100.0 %
Date: 2012-12-17 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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include <test/unoapi_test.hxx>
      30             : #include <test/sheet/xdatabaserange.hxx>
      31             : 
      32             : #include <com/sun/star/beans/XPropertySet.hpp>
      33             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      34             : #include <com/sun/star/container/XNameAccess.hpp>
      35             : #include <com/sun/star/sheet/XDatabaseRange.hpp>
      36             : 
      37             : 
      38             : namespace sc_apitest {
      39             : 
      40             : #define NUMBER_OF_TESTS 6
      41             : 
      42          36 : class ScDatabaseRangeObj : public UnoApiTest, apitest::XDatabaseRange
      43             : {
      44             : public:
      45             :     virtual void setUp();
      46             :     virtual void tearDown();
      47             : 
      48             :     virtual uno::Reference< uno::XInterface > init( const rtl::OUString& rDBName );
      49             : 
      50           4 :     CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
      51           2 :     CPPUNIT_TEST(testDataArea);
      52           2 :     CPPUNIT_TEST(testGetSortDescriptor);
      53           2 :     CPPUNIT_TEST(testGetSubtotalDescriptor);
      54           2 :     CPPUNIT_TEST(testGetImportDescriptor);
      55           2 :     CPPUNIT_TEST(testGetFilterDescriptor);
      56           2 :     CPPUNIT_TEST(testRefresh);
      57           4 :     CPPUNIT_TEST_SUITE_END();
      58             : private:
      59             :     static sal_Int32 nTest;
      60             :     static uno::Reference< lang::XComponent > mxComponent;
      61             : };
      62             : 
      63             : sal_Int32 ScDatabaseRangeObj::nTest = 0;
      64           2 : uno::Reference< lang::XComponent > ScDatabaseRangeObj::mxComponent;
      65             : 
      66          12 : uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString& rDBName )
      67             : {
      68          12 :     rtl::OUString aFileURL;
      69          12 :     createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDatabaseRangeObj.ods")), aFileURL);
      70          12 :     if(!mxComponent.is())
      71           2 :         mxComponent = loadFromDesktop(aFileURL);
      72          12 :     CPPUNIT_ASSERT(mxComponent.is());
      73             : 
      74          12 :     uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
      75          12 :     uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW);
      76          12 :     uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges"))), UNO_QUERY_THROW);
      77          12 :     uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
      78          12 :     CPPUNIT_ASSERT(xDBRange.is());
      79          12 :     return xDBRange;
      80             : }
      81             : 
      82          12 : void ScDatabaseRangeObj::setUp()
      83             : {
      84          12 :     nTest++;
      85          12 :     UnoApiTest::setUp();
      86          12 : }
      87             : 
      88          12 : void ScDatabaseRangeObj::tearDown()
      89             : {
      90          12 :     if (nTest == NUMBER_OF_TESTS)
      91           2 :         closeDocument(mxComponent);
      92             : 
      93          12 :     UnoApiTest::tearDown();
      94          12 : }
      95             : 
      96           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj);
      97             : 
      98           2 : CPPUNIT_PLUGIN_IMPLEMENT();
      99             : 
     100           6 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10