LCOV - code coverage report
Current view: top level - test/source/sheet - datapilotfield.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 116 122 95.1 %
Date: 2015-06-13 12:38:46 Functions: 7 7 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/datapilotfield.hxx>
      11             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      12             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      13             : #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
      14             : #include <com/sun/star/sheet/XDataPilotTables.hpp>
      15             : #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
      16             : #include <com/sun/star/beans/XPropertySet.hpp>
      17             : #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
      18             : #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
      19             : #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
      20             : #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
      21             : #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
      22             : #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
      23             : #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
      24             : 
      25             : #include <rtl/ustring.hxx>
      26             : #include "cppunit/extensions/HelperMacros.h"
      27             : #include <iostream>
      28             : 
      29             : using namespace css;
      30             : using namespace css::uno;
      31             : 
      32             : namespace apitest {
      33             : 
      34           1 : void DataPilotField::testSortInfo()
      35             : {
      36           1 :     uno::Reference< beans::XPropertySet> xPropSet(init(),UNO_QUERY_THROW);
      37           2 :     sheet::DataPilotFieldSortInfo aSortInfoValue;
      38           2 :     OUString aSortInfo("SortInfo");
      39           1 :     aSortInfoValue.Field = "Col1";
      40           1 :     aSortInfoValue.IsAscending = false;
      41           1 :     aSortInfoValue.Mode = sheet::DataPilotFieldSortMode::MANUAL;
      42           2 :     uno::Any xValue;
      43           1 :     xValue <<= aSortInfoValue;
      44           1 :     xPropSet->setPropertyValue(aSortInfo, xValue);
      45             : 
      46           2 :     sheet::DataPilotFieldSortInfo aNewSortInfoValue;
      47           1 :     xValue = xPropSet->getPropertyValue(aSortInfo);
      48           1 :     CPPUNIT_ASSERT( xValue >>= aNewSortInfoValue );
      49           2 :     CPPUNIT_ASSERT_MESSAGE("set value should be the same as got value", aNewSortInfoValue.Field == aSortInfoValue.Field
      50           1 :             && aNewSortInfoValue.Mode == aSortInfoValue.Mode && aNewSortInfoValue.IsAscending == aSortInfoValue.IsAscending);
      51             : 
      52             :     //setting HasSortInfo only makes sense for false, for true the uno implementation does nothing
      53           1 :     bool bHasSortInfo(false);
      54           2 :     OUString aHasSortInfo("HasSortInfo");
      55           1 :     xValue = xPropSet->getPropertyValue(aHasSortInfo);
      56           1 :     CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
      57           1 :     CPPUNIT_ASSERT_MESSAGE("should have sort info", bHasSortInfo);
      58             : 
      59           1 :     bHasSortInfo = false;
      60           1 :     xValue <<= bHasSortInfo;
      61           1 :     xPropSet->setPropertyValue(aHasSortInfo, xValue);
      62             : 
      63           1 :     xValue = xPropSet->getPropertyValue(aHasSortInfo);
      64           1 :     CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
      65           2 :     CPPUNIT_ASSERT_MESSAGE("should have no sort info", !bHasSortInfo);
      66           1 : }
      67             : 
      68           1 : void DataPilotField::testLayoutInfo()
      69             : {
      70           1 :     uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
      71           1 :     sheet::DataPilotFieldLayoutInfo aLayoutInfoValue;
      72           2 :     OUString aLayoutInfo("LayoutInfo");
      73           1 :     aLayoutInfoValue.AddEmptyLines = false;
      74           1 :     aLayoutInfoValue.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
      75           2 :     uno::Any xValue;
      76           1 :     xValue <<= aLayoutInfoValue;
      77           1 :     xPropSet->setPropertyValue(aLayoutInfo, xValue);
      78             : 
      79           1 :     sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue;
      80           1 :     xValue = xPropSet->getPropertyValue(aLayoutInfo);
      81           1 :     CPPUNIT_ASSERT( xValue >>= aNewLayoutInfoValue );
      82           2 :     CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewLayoutInfoValue.LayoutMode == aLayoutInfoValue.LayoutMode &&
      83           1 :             aNewLayoutInfoValue.AddEmptyLines == aLayoutInfoValue.AddEmptyLines);
      84             : 
      85             :     //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
      86           1 :     bool bHasLayoutInfo(false);
      87           2 :     OUString aHasLayoutInfo("HasLayoutInfo");
      88           1 :     xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
      89           1 :     CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
      90           1 :     CPPUNIT_ASSERT_MESSAGE("should have layout information", bHasLayoutInfo);
      91             : 
      92           1 :     bHasLayoutInfo = false;
      93           1 :     xValue <<= bHasLayoutInfo;
      94           1 :     xPropSet->setPropertyValue(aHasLayoutInfo, xValue);
      95             : 
      96           1 :     xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
      97           1 :     CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
      98           2 :     CPPUNIT_ASSERT_MESSAGE("should have no longer sort information", !bHasLayoutInfo);
      99           1 : }
     100             : 
     101           1 : void DataPilotField::testAutoShowInfo()
     102             : {
     103           1 :     uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
     104           2 :     sheet::DataPilotFieldAutoShowInfo aAutoShowInfoValue;
     105           1 :     aAutoShowInfoValue.DataField = "Col1";
     106           1 :     aAutoShowInfoValue.IsEnabled = true;
     107           2 :     OUString aAutoShowInfo("AutoShowInfo");
     108           2 :     uno::Any xValue;
     109           1 :     xValue <<= aAutoShowInfoValue;
     110           1 :     xPropSet->setPropertyValue(aAutoShowInfo, xValue);
     111             : 
     112           2 :     sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue;
     113           1 :     xValue = xPropSet->getPropertyValue(aAutoShowInfo);
     114           1 :     CPPUNIT_ASSERT( xValue >>= aNewAutoShowInfoValue );
     115           2 :     CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewAutoShowInfoValue.DataField == aAutoShowInfoValue.DataField &&
     116           1 :             aNewAutoShowInfoValue.IsEnabled == aAutoShowInfoValue.IsEnabled);
     117             : 
     118             :     //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
     119           1 :     bool bHasAutoShowInfo(false);
     120           2 :     OUString aHasAutoShowInfo("HasAutoShowInfo");
     121           1 :     xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
     122           1 :     CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
     123           1 :     CPPUNIT_ASSERT_MESSAGE("should have AutoShow information", bHasAutoShowInfo);
     124             : 
     125           1 :     bHasAutoShowInfo = false;
     126           1 :     xValue <<= bHasAutoShowInfo;
     127           1 :     xPropSet->setPropertyValue(aHasAutoShowInfo, xValue);
     128             : 
     129           1 :     xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
     130           1 :     CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
     131           2 :     CPPUNIT_ASSERT_MESSAGE("should have no longer AutoShow information", !bHasAutoShowInfo);
     132           1 : }
     133             : 
     134           1 : void DataPilotField::testReference()
     135             : {
     136           1 :     uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
     137           2 :     sheet::DataPilotFieldReference aReferenceValue;
     138           1 :     aReferenceValue.ReferenceField = "Col1";
     139           1 :     aReferenceValue.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
     140           2 :     OUString aReference("Reference");
     141           2 :     uno::Any xValue;
     142           1 :     xValue <<= aReferenceValue;
     143           1 :     xPropSet->setPropertyValue(aReference, xValue);
     144             : 
     145           2 :     sheet::DataPilotFieldReference aNewReferenceValue;
     146           1 :     xValue = xPropSet->getPropertyValue(aReference);
     147           1 :     CPPUNIT_ASSERT( xValue >>= aNewReferenceValue );
     148           2 :     CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField == aNewReferenceValue.ReferenceField
     149           1 :             && aReferenceValue.ReferenceItemType == aNewReferenceValue.ReferenceItemType);
     150             : 
     151             :     //setting HasReference only makes sense for false, tor true the uno implementation does nothing
     152           1 :     bool bHasReference(false);
     153           2 :     OUString aHasReference("HasReference");
     154           1 :     xValue = xPropSet->getPropertyValue(aHasReference);
     155           1 :     CPPUNIT_ASSERT( xValue >>= bHasReference );
     156           1 :     CPPUNIT_ASSERT_MESSAGE("should have Reference information", bHasReference);
     157             : 
     158           1 :     bHasReference = false;
     159           1 :     xValue <<= bHasReference;
     160           1 :     xPropSet->setPropertyValue(aHasReference, xValue);
     161             : 
     162           1 :     xValue = xPropSet->getPropertyValue(aHasReference);
     163           1 :     CPPUNIT_ASSERT( xValue >>= bHasReference );
     164           2 :     CPPUNIT_ASSERT_MESSAGE("should have no longer reference information", !bHasReference);
     165           1 : }
     166             : 
     167           1 : void DataPilotField::testIsGroupField()
     168             : {
     169           1 :     uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
     170           2 :     uno::Any xValue;
     171           2 :     OUString aIsGroupField("IsGroupField");
     172           1 :     bool bIsGroupField(false);
     173             : 
     174           1 :     xValue = xPropSet->getPropertyValue(aIsGroupField);
     175           1 :     CPPUNIT_ASSERT( xValue >>= bIsGroupField);
     176             :     //only setting to false is supported
     177           1 :     if (bIsGroupField)
     178             :     {
     179           0 :         bIsGroupField = false;
     180           0 :         xValue <<= bIsGroupField;
     181             : 
     182           0 :         xPropSet->setPropertyValue(aIsGroupField, xValue);
     183           0 :         xValue = xPropSet->getPropertyValue(aIsGroupField);
     184           0 :         CPPUNIT_ASSERT(xValue >>= bIsGroupField);
     185           0 :         CPPUNIT_ASSERT_MESSAGE("setting IsGroupField is supported and should have happened", !bIsGroupField);
     186             :     }
     187             :     else
     188           2 :         std::cout << "Could not test IsGroupField" << std::endl;
     189           1 : }
     190             : 
     191          90 : }
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11