LCOV - code coverage report
Current view: top level - test/source/sheet - xnamedrange.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 64 0.0 %
Date: 2014-04-14 Functions: 0 8 0.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/xnamedrange.hxx>
      11             : 
      12             : #include <com/sun/star/beans/XPropertySet.hpp>
      13             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      14             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      15             : #include <com/sun/star/table/XCellRange.hpp>
      16             : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      17             : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      18             : #include <com/sun/star/sheet/XNamedRanges.hpp>
      19             : #include <com/sun/star/sheet/XNamedRange.hpp>
      20             : #include <com/sun/star/table/XCell.hpp>
      21             : #include <com/sun/star/text/XTextRange.hpp>
      22             : 
      23             : #include <com/sun/star/table/CellAddress.hpp>
      24             : #include <com/sun/star/table/CellRangeAddress.hpp>
      25             : #include <com/sun/star/sheet/Border.hpp>
      26             : #include <com/sun/star/sheet/NamedRangeFlag.hpp>
      27             : 
      28             : #include "cppunit/extensions/HelperMacros.h"
      29             : #include <rtl/ustring.hxx>
      30             : 
      31             : using namespace css;
      32             : using namespace css::uno;
      33             : 
      34             : namespace apitest {
      35             : 
      36           0 : void XNamedRange::testGetContent()
      37             : {
      38           0 :     OUString aTestedNamedRangeString("initial1");
      39           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
      40             : 
      41           0 :     OUString aExpectedContent("$Sheet1.$B$1");
      42           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent));
      43           0 : }
      44             : 
      45           0 : void XNamedRange::testSetContent()
      46             : {
      47           0 :     OUString aTestedNamedRangeString("initial1");
      48           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
      49             : 
      50           0 :     OUString aExpectedContent;
      51             : 
      52             :     // test a cell
      53           0 :     aExpectedContent = "D1";
      54           0 :     xNamedRange->setContent(aExpectedContent);
      55           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent));
      56             : 
      57             :     // test a cellrange
      58           0 :     aExpectedContent = "D1:D10";
      59           0 :     xNamedRange->setContent(aExpectedContent);
      60           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent));
      61             : 
      62             :     // test a formula
      63           0 :     aExpectedContent = "=D10";
      64           0 :     xNamedRange->setContent(aExpectedContent);
      65           0 :     aExpectedContent = "D10";
      66           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent));
      67             : 
      68           0 : }
      69             : 
      70           0 : void XNamedRange::testGetType()
      71             : {
      72           0 :     OUString aTestedNamedRangeString("initial1");
      73           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
      74           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0);
      75           0 : }
      76             : 
      77           0 : void XNamedRange::testSetType()
      78             : {
      79           0 :     OUString aTestedNamedRangeString("initial1");
      80           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
      81             : 
      82           0 :     sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;;
      83           0 :     xNamedRange->setType(nType);
      84           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType);
      85             : 
      86           0 :     nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
      87           0 :     xNamedRange->setType(nType);
      88           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType);
      89             : 
      90           0 :     nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
      91           0 :     xNamedRange->setType(nType);
      92           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType);
      93             : 
      94           0 :     nType = ::sheet::NamedRangeFlag::PRINT_AREA;
      95           0 :     xNamedRange->setType(nType);
      96           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType);
      97             : 
      98           0 :     nType = 0;
      99           0 :     xNamedRange->setType(nType);
     100           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType);
     101           0 : }
     102             : 
     103           0 : void XNamedRange::testGetReferencePosition()
     104             : {
     105           0 :     OUString aTestedNamedRangeString("initial2");
     106           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
     107             : 
     108           0 :     table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
     109             :     // the expeted address is on B1, as it was the active cell when intial2 created
     110           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0);
     111           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1);
     112           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0);
     113           0 : }
     114             : 
     115           0 : void XNamedRange::testSetReferencePosition()
     116             : {
     117           0 :     OUString aTestedNamedRangeString("initial1");
     118           0 :     uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
     119             : 
     120           0 :     table::CellAddress aBaseAddress = table::CellAddress(1,2,3);
     121             : 
     122           0 :     xNamedRange->setReferencePosition(aBaseAddress);
     123             : 
     124           0 :     table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
     125           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1);
     126           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2);
     127           0 :     CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3);
     128           0 : }
     129             : 
     130           0 : }
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10