LibreOffice Module test (master)  1
xconsolidationdescriptor.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 
12 
13 #include <com/sun/star/sheet/GeneralFunction.hpp>
14 #include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
15 #include <com/sun/star/table/CellAddress.hpp>
16 #include <com/sun/star/table/CellRangeAddress.hpp>
17 #include <com/sun/star/uno/Reference.hxx>
18 #include <com/sun/star/uno/Sequence.hxx>
19 
20 #include <cppunit/TestAssert.h>
21 
22 using namespace css;
23 using namespace css::uno;
24 
25 namespace apitest
26 {
27 void XConsolidationDescriptor::testGetFunction()
28 {
29  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
30  UNO_QUERY_THROW);
31 
32  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get function", sheet::GeneralFunction_SUM,
33  xConsolidationDescriptor->getFunction());
34 }
35 
36 void XConsolidationDescriptor::testSetFunction()
37 {
38  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
39  UNO_QUERY_THROW);
40 
41  xConsolidationDescriptor->setFunction(sheet::GeneralFunction_COUNT);
42  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set function", sheet::GeneralFunction_COUNT,
43  xConsolidationDescriptor->getFunction());
44 }
45 
46 void XConsolidationDescriptor::testGetSources()
47 {
48  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
49  UNO_QUERY_THROW);
50 
51  uno::Sequence<table::CellRangeAddress> aSources = xConsolidationDescriptor->getSources();
52  CPPUNIT_ASSERT_MESSAGE("Unable to get sources", !aSources.hasElements());
53 }
54 
55 void XConsolidationDescriptor::testSetSources()
56 {
57  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
58  UNO_QUERY_THROW);
59 
60  uno::Sequence<table::CellRangeAddress> aSources(1);
61  aSources[0] = table::CellRangeAddress(0, 1, 1, 5, 5);
62  xConsolidationDescriptor->setSources(aSources);
63  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set sources", table::CellRangeAddress(0, 1, 1, 5, 5),
64  xConsolidationDescriptor->getSources()[0]);
65 }
66 
67 void XConsolidationDescriptor::testGetStartOutputPosition()
68 {
69  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
70  UNO_QUERY_THROW);
71 
72  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get start output position", table::CellAddress(0, 0, 0),
73  xConsolidationDescriptor->getStartOutputPosition());
74 }
75 
76 void XConsolidationDescriptor::testSetStartOutputPosition()
77 {
78  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
79  UNO_QUERY_THROW);
80 
81  xConsolidationDescriptor->setStartOutputPosition(table::CellAddress(0, 1, 2));
82  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set start output position", table::CellAddress(0, 1, 2),
83  xConsolidationDescriptor->getStartOutputPosition());
84 }
85 
86 void XConsolidationDescriptor::testGetUseColumnHeaders()
87 {
88  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
89  UNO_QUERY_THROW);
90 
91  CPPUNIT_ASSERT_MESSAGE("Unable to get use column headers",
92  !xConsolidationDescriptor->getUseColumnHeaders());
93 }
94 
95 void XConsolidationDescriptor::testSetUseColumnHeaders()
96 {
97  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
98  UNO_QUERY_THROW);
99 
100  xConsolidationDescriptor->setUseColumnHeaders(true);
101  CPPUNIT_ASSERT_MESSAGE("Unable to set use column headers",
102  xConsolidationDescriptor->getUseColumnHeaders());
103 }
104 
105 void XConsolidationDescriptor::testGetUseRowHeaders()
106 {
107  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
108  UNO_QUERY_THROW);
109 
110  CPPUNIT_ASSERT_MESSAGE("Unable to get use row headers",
111  !xConsolidationDescriptor->getUseRowHeaders());
112 }
113 
114 void XConsolidationDescriptor::testSetUseRowHeaders()
115 {
116  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
117  UNO_QUERY_THROW);
118 
119  xConsolidationDescriptor->setUseRowHeaders(true);
120  CPPUNIT_ASSERT_MESSAGE("Unable to set use row headers",
121  xConsolidationDescriptor->getUseRowHeaders());
122 }
123 
124 void XConsolidationDescriptor::testGetInsertLinks()
125 {
126  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
127  UNO_QUERY_THROW);
128 
129  CPPUNIT_ASSERT_MESSAGE("Unable to get use insert links",
130  !xConsolidationDescriptor->getInsertLinks());
131 }
132 
133 void XConsolidationDescriptor::testSetInsertLinks()
134 {
135  uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
136  UNO_QUERY_THROW);
137 
138  xConsolidationDescriptor->setInsertLinks(true);
139  CPPUNIT_ASSERT_MESSAGE("Unable to set use insert links",
140  xConsolidationDescriptor->getInsertLinks());
141 }
142 }
143 
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
FILE * init(int, char **)