1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XConsolidationDescriptor.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
34 import util
.ValueComparer
;
36 import com
.sun
.star
.sheet
.GeneralFunction
;
37 import com
.sun
.star
.sheet
.XConsolidationDescriptor
;
38 import com
.sun
.star
.table
.CellAddress
;
39 import com
.sun
.star
.table
.CellRangeAddress
;
42 * Testing <code>com.sun.star.sheet.XConsolidationDescriptor</code>
45 * <li><code> getFunction()</code></li>
46 * <li><code> setFunction()</code></li>
47 * <li><code> getSources()</code></li>
48 * <li><code> setSources()</code></li>
49 * <li><code> getStartOutputPosition()</code></li>
50 * <li><code> setStartOutputPosition()</code></li>
51 * <li><code> getUseColumnHeaders()</code></li>
52 * <li><code> setUseColumnHeaders()</code></li>
53 * <li><code> getUseRowHeaders()</code></li>
54 * <li><code> setUseRowHeaders()</code></li>
55 * <li><code> getInsertLinks()</code></li>
56 * <li><code> setInsertLinks()</code></li>
58 * @see com.sun.star.sheet.XConsolidationDescriptor
60 public class _XConsolidationDescriptor
extends MultiMethodTest
{
62 public XConsolidationDescriptor oObj
= null;
63 public GeneralFunction aFunction
= null;
64 public boolean insertLinks
= false;
65 public boolean useColumnHeaders
= false;
66 public boolean useRowHeaders
= false;
67 public CellRangeAddress
[] CRaddr
= null;
68 public CellAddress addr
= null;
71 * Test calls the method, stores and checks returned value. <p>
72 * Has <b> OK </b> status if returned value isn't null. <p>
74 public void _getFunction() {
75 aFunction
= oObj
.getFunction();
76 tRes
.tested("getFunction()", aFunction
!= null );
80 * Test calls the method and stores returned value. <p>
81 * Has <b> OK </b> status if the method successfully returns. <p>
83 public void _getInsertLinks() {
84 insertLinks
= oObj
.getInsertLinks();
85 tRes
.tested("getInsertLinks()", true);
89 * Test calls the method and stores returned value. <p>
90 * Has <b> OK </b> status if the method successfully returns. <p>
92 public void _getSources() {
93 CRaddr
= oObj
.getSources();
94 int wiev
= CRaddr
.length
;
95 tRes
.tested("getSources()", true);
99 * Test calls the method and stores returned value. <p>
100 * Has <b> OK </b> status if the method successfully returns. <p>
102 public void _getStartOutputPosition() {
103 addr
= oObj
.getStartOutputPosition();
104 tRes
.tested("getStartOutputPosition()", true);
108 * Test calls the method and stores returned value. <p>
109 * Has <b> OK </b> status if the method successfully returns. <p>
111 public void _getUseColumnHeaders() {
112 useColumnHeaders
= oObj
.getUseColumnHeaders();
113 tRes
.tested("getUseColumnHeaders()", true);
117 * Test calls the method and stores returned value. <p>
118 * Has <b> OK </b> status if the method successfully returns. <p>
120 public void _getUseRowHeaders() {
121 useRowHeaders
= oObj
.getUseRowHeaders();
122 tRes
.tested("getUseRowHeaders()", true);
126 * Test sets the new current function, gets current function
127 * and compare function gotten by method <code>getFunction()</code> with
128 * function that was set. <p>
129 * Has <b> OK </b> status if the functions aren't equal. <p>
130 * The following method tests are to be completed successfully before :
132 * <li> <code> getFunction() </code> : to have current value of
133 * the function by which the ranges are consolidated </li>
136 public void _setFunction() {
137 requiredMethod("getFunction()");
138 GeneralFunction aFunction2
= null;
139 if (aFunction
.equals(GeneralFunction
.SUM
)) {
140 aFunction2
= GeneralFunction
.COUNT
;
143 aFunction2
= GeneralFunction
.SUM
;
145 oObj
.setFunction(aFunction2
);
146 aFunction2
= oObj
.getFunction();
147 tRes
.tested("setFunction()", !aFunction
.equals(aFunction2
));
151 * Test sets property to value that negative to the current value
152 * and compares returned value with value that was set. <p>
153 * Has <b> OK </b> status if returned value isn't equal to value that was
154 * stored by method <code>getInsertLinks()</code>. <p>
155 * The following method tests are to be completed successfully before :
157 * <li> <code> getInsertLinks() </code> : to have current value of
158 * this property </li>
161 public void _setInsertLinks() {
162 requiredMethod("getInsertLinks()");
163 oObj
.setInsertLinks( !insertLinks
);
164 boolean insertLinks2
= oObj
.getInsertLinks();
165 tRes
.tested("setInsertLinks()", insertLinks
!= insertLinks2
);
169 * Test sets new cell ranges and compares cell ranges gotten by method
170 * <code>getSources()</code> with the cell range that was set. <p>
171 * Has <b> OK </b> status if returned value isn't equal to value that was
172 * stored by method <code>getSources()</code>. <p>
173 * The following method tests are to be completed successfully before :
175 * <li> <code> getSources() </code> : to have the cell ranges which
176 * are consolidated </li>
179 public void _setSources() {
180 requiredMethod("getSources()");
181 oObj
.setSources(newCRaddr());
182 CellRangeAddress
[] CRaddr2
= oObj
.getSources();
183 tRes
.tested("setSources()",!ValueComparer
.equalValue(CRaddr
, CRaddr2
));
187 * Test sets new cell address for start output position and compares
188 * cell address gotten by method <code>getStartOutputPosition()</code>
189 * with the cell address that was set. <p>
190 * Has <b> OK </b> status if returned value isn't equal to value that was
191 * stored by method <code>getStartOutputPosition()</code>. <p>
192 * The following method tests are to be completed successfully before :
194 * <li> <code> getStartOutputPosition() </code> : to have the cell address
195 * of start output position </li>
198 public void _setStartOutputPosition() {
199 requiredMethod("getStartOutputPosition()");
200 CellAddress addr2
= new CellAddress();
201 addr2
.Column
= addr
.Column
+ 1;
202 addr2
.Row
= addr
.Row
+ 1;
203 oObj
.setStartOutputPosition(addr2
);
204 tRes
.tested("setStartOutputPosition()",
205 !ValueComparer
.equalValue(addr
, addr2
));
209 * Test sets property to value that negative to the current value
210 * and compares returned value with value that was set. <p>
211 * Has <b> OK </b> status if returned value isn't equal to value that was
212 * stored by method <code>getUseColumnHeaders()</code>. <p>
213 * The following method tests are to be completed successfully before :
215 * <li> <code> getUseColumnHeaders() </code> : to have current value of
216 * this property </li>
219 public void _setUseColumnHeaders() {
220 requiredMethod("getUseColumnHeaders()");
221 oObj
.setUseColumnHeaders( !useColumnHeaders
);
222 boolean uCH
= oObj
.getUseColumnHeaders();
223 tRes
.tested("setUseColumnHeaders()", useColumnHeaders
!= uCH
);
227 * Test sets property to value that negative to the current value
228 * and compares returned value with value that was set. <p>
229 * Has <b> OK </b> status if returned value isn't equal to value that was
230 * stored by method <code>getUseRowHeaders()</code>. <p>
231 * The following method tests are to be completed successfully before :
233 * <li> <code> getUseRowHeaders() </code> : to have current value of
234 * this property </li>
237 public void _setUseRowHeaders() {
238 requiredMethod("getUseRowHeaders()");
239 oObj
.setUseRowHeaders(!useRowHeaders
);
240 boolean uRH
= oObj
.getUseRowHeaders();
241 tRes
.tested("setUseRowHeaders()", useRowHeaders
!= uRH
);
245 * Constructs new cell range addresses using old cell range addresses.
246 * @param CRaddr old cell range addresses
247 * @return new cell range addresses
249 public CellRangeAddress
[] newCRaddr() {
251 CellRangeAddress
[] back
= new CellRangeAddress
[1];
253 CellRangeAddress cra1
= new CellRangeAddress();
265 } // finish class _XConsolidationDescriptor