LCOV - code coverage report
Current view: top level - test/source/sheet - xdatabaserange.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 99 99 100.0 %
Date: 2014-11-03 Functions: 8 8 100.0 %
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/sheet/xdatabaserange.hxx>
      11             : 
      12             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      13             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      14             : #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
      15             : #include <com/sun/star/beans/PropertyValue.hpp>
      16             : #include <com/sun/star/sheet/XDatabaseRange.hpp>
      17             : #include <com/sun/star/sheet/XDatabaseRanges.hpp>
      18             : #include <com/sun/star/table/CellRangeAddress.hpp>
      19             : #include <com/sun/star/util/XCloseable.hpp>
      20             : #include <com/sun/star/beans/XPropertySet.hpp>
      21             : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      22             : #include <com/sun/star/table/XCell.hpp>
      23             : #include <com/sun/star/table/XTableRows.hpp>
      24             : #include <com/sun/star/table/XColumnRowRange.hpp>
      25             : 
      26             : #include <rtl/ustring.hxx>
      27             : #include "cppunit/extensions/HelperMacros.h"
      28             : #include <iostream>
      29             : 
      30             : using namespace css;
      31             : using namespace css::uno;
      32             : 
      33             : namespace apitest {
      34             : 
      35             : /**
      36             :  * tests setDataArea and getDataArea
      37             :  */
      38           2 : void XDatabaseRange::testDataArea()
      39             : {
      40           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("DataArea")), UNO_QUERY_THROW);
      41             : 
      42           2 :     table::CellRangeAddress aCellAddress;
      43           2 :     aCellAddress.Sheet = 0;
      44           2 :     aCellAddress.StartColumn = 1;
      45           2 :     aCellAddress.EndColumn = 4;
      46           2 :     aCellAddress.StartRow = 2;
      47           2 :     aCellAddress.EndRow = 5;
      48           2 :     xDBRange->setDataArea(aCellAddress);
      49           2 :     table::CellRangeAddress aValue;
      50           2 :     aValue = xDBRange->getDataArea();
      51           2 :     CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
      52           2 :     CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
      53           2 :     CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
      54           2 :     CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
      55           2 :     CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
      56           2 : }
      57             : 
      58           2 : void XDatabaseRange::testGetSubtotalDescriptor()
      59             : {
      60           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SubtotalDescriptor")), UNO_QUERY_THROW);
      61           4 :     uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
      62           4 :     CPPUNIT_ASSERT(xSubtotalDescr.is());
      63           2 : }
      64             : 
      65           2 : void XDatabaseRange::testGetSortDescriptor()
      66             : {
      67           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SortDescriptor")), UNO_QUERY_THROW);
      68           4 :     uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
      69          20 :     for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
      70             :     {
      71          18 :         beans::PropertyValue xProp = xSortDescr[i];
      72             :         //std::cout << "Prop " << i << " Name: " << OUString(xProp.Name) << std::endl;
      73             : 
      74          18 :         if (xProp.Name == "IsSortColumns")
      75             :         {
      76           2 :             bool bIsSortColumns = true;
      77           2 :             xProp.Value >>= bIsSortColumns;
      78           2 :             CPPUNIT_ASSERT(bIsSortColumns);
      79             :         }
      80          16 :         else if (xProp.Name == "ContainsHeader")
      81             :         {
      82           2 :             bool bContainsHeader = true;
      83           2 :             xProp.Value >>= bContainsHeader;
      84           2 :             CPPUNIT_ASSERT(bContainsHeader);
      85             :         }
      86          14 :         else if (xProp.Name == "MaxFieldCount")
      87             :         {
      88           2 :             sal_Int32 nMaxFieldCount = 0;
      89           2 :             xProp.Value >>= nMaxFieldCount;
      90           2 :             std::cout << "Value: " << nMaxFieldCount << std::endl;
      91             : 
      92             :         }
      93          12 :         else if (xProp.Name == "SortFields")
      94             :         {
      95             : 
      96             :         }
      97          10 :         else if (xProp.Name == "BindFormatsToContent")
      98             :         {
      99           2 :             bool bBindFormatsToContent = false;
     100           2 :             xProp.Value >>= bBindFormatsToContent;
     101           2 :             CPPUNIT_ASSERT(bBindFormatsToContent);
     102             :         }
     103           8 :         else if (xProp.Name == "CopyOutputData")
     104             :         {
     105           2 :             bool bCopyOutputData = true;
     106           2 :             xProp.Value >>= bCopyOutputData;
     107           2 :             CPPUNIT_ASSERT(bCopyOutputData == false);
     108             :         }
     109           6 :         else if (xProp.Name == "OutputPosition")
     110             :         {
     111             : 
     112             :         }
     113           4 :         else if (xProp.Name == "IsUserListEnabled")
     114             :         {
     115           2 :             bool bIsUserListEnabled  = true;
     116           2 :             xProp.Value >>= bIsUserListEnabled;
     117           2 :             CPPUNIT_ASSERT(bIsUserListEnabled == false);
     118             : 
     119             :         }
     120           2 :         else if (xProp.Name == "UserListIndex")
     121             :         {
     122           2 :             sal_Int32 nUserListIndex = 1;
     123           2 :             xProp.Value >>= nUserListIndex;
     124           2 :             CPPUNIT_ASSERT(nUserListIndex == 0);
     125             :         }
     126          20 :     }
     127           2 : }
     128             : 
     129           2 : void XDatabaseRange::testGetFilterDescriptor()
     130             : {
     131           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("FilterDescriptor")), UNO_QUERY_THROW);
     132           4 :     uno::Reference< uno::XInterface > xFilterDescr( xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
     133           4 :     CPPUNIT_ASSERT(xFilterDescr.is());
     134           2 : }
     135             : 
     136           2 : void XDatabaseRange::testGetImportDescriptor()
     137             : {
     138           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("ImportDescriptor")), UNO_QUERY_THROW);
     139           2 :     uno::Sequence< beans::PropertyValue > xImportDescr = xDBRange->getImportDescriptor();
     140           2 :     (void) xImportDescr;
     141           2 : }
     142             : 
     143           2 : void XDatabaseRange::testRefresh()
     144             : {
     145           2 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("Refresh")), UNO_QUERY_THROW);
     146             : 
     147           2 :     const sal_Int32 nCol = 0;
     148           4 :     OUString aHidden("IsVisible");
     149           4 :     uno::Reference< sheet::XCellRangeReferrer > xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
     150           4 :     uno::Reference< table::XCellRange > xCellRange = xCellRangeReferrer->getReferredCells();
     151             : 
     152          10 :     for (sal_Int32 i = 1; i < 5; ++i)
     153             :     {
     154           8 :         uno::Reference< table::XCell > xCell = xCellRange->getCellByPosition(nCol, i);
     155           8 :         xCell->setValue(0);
     156           8 :     }
     157             : 
     158           8 :     for (sal_Int32 i = 2; i < 5; ++i)
     159             :     {
     160           6 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     161          12 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     162          12 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     163          12 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     164          12 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     165             : 
     166           6 :         CPPUNIT_ASSERT(aAny.get<sal_Bool>() == sal_True);
     167           6 :     }
     168             : 
     169           2 :     xDBRange->refresh();
     170           2 :     std::cout << "after refresh" << std::endl;
     171             : 
     172          10 :     for (sal_Int32 i = 1; i < 5; ++i)
     173             :     {
     174           8 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     175          16 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     176          16 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     177          16 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     178          16 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     179             : 
     180           8 :         CPPUNIT_ASSERT(aAny.get<sal_Bool>() == sal_False);
     181          10 :     }
     182             : 
     183             : 
     184           2 : }
     185             : 
     186         144 : }
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10