1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
31 import util
.ValueComparer
;
33 import com
.sun
.star
.sheet
.GeneralFunction
;
34 import com
.sun
.star
.sheet
.XConsolidationDescriptor
;
35 import com
.sun
.star
.table
.CellAddress
;
36 import com
.sun
.star
.table
.CellRangeAddress
;
39 * Testing <code>com.sun.star.sheet.XConsolidationDescriptor</code>
42 * <li><code> getFunction()</code></li>
43 * <li><code> setFunction()</code></li>
44 * <li><code> getSources()</code></li>
45 * <li><code> setSources()</code></li>
46 * <li><code> getStartOutputPosition()</code></li>
47 * <li><code> setStartOutputPosition()</code></li>
48 * <li><code> getUseColumnHeaders()</code></li>
49 * <li><code> setUseColumnHeaders()</code></li>
50 * <li><code> getUseRowHeaders()</code></li>
51 * <li><code> setUseRowHeaders()</code></li>
52 * <li><code> getInsertLinks()</code></li>
53 * <li><code> setInsertLinks()</code></li>
55 * @see com.sun.star.sheet.XConsolidationDescriptor
57 public class _XConsolidationDescriptor
extends MultiMethodTest
{
59 public XConsolidationDescriptor oObj
= null;
60 public GeneralFunction aFunction
= null;
61 public boolean insertLinks
= false;
62 public boolean useColumnHeaders
= false;
63 public boolean useRowHeaders
= false;
64 public CellRangeAddress
[] CRaddr
= null;
65 public CellAddress addr
= null;
68 * Test calls the method, stores and checks returned value. <p>
69 * Has <b> OK </b> status if returned value isn't null. <p>
71 public void _getFunction() {
72 aFunction
= oObj
.getFunction();
73 tRes
.tested("getFunction()", aFunction
!= null );
77 * Test calls the method and stores returned value. <p>
78 * Has <b> OK </b> status if the method successfully returns. <p>
80 public void _getInsertLinks() {
81 insertLinks
= oObj
.getInsertLinks();
82 tRes
.tested("getInsertLinks()", true);
86 * Test calls the method and stores returned value. <p>
87 * Has <b> OK </b> status if the method successfully returns. <p>
89 public void _getSources() {
90 CRaddr
= oObj
.getSources();
91 int wiev
= CRaddr
.length
;
92 tRes
.tested("getSources()", true);
96 * Test calls the method and stores returned value. <p>
97 * Has <b> OK </b> status if the method successfully returns. <p>
99 public void _getStartOutputPosition() {
100 addr
= oObj
.getStartOutputPosition();
101 tRes
.tested("getStartOutputPosition()", true);
105 * Test calls the method and stores returned value. <p>
106 * Has <b> OK </b> status if the method successfully returns. <p>
108 public void _getUseColumnHeaders() {
109 useColumnHeaders
= oObj
.getUseColumnHeaders();
110 tRes
.tested("getUseColumnHeaders()", true);
114 * Test calls the method and stores returned value. <p>
115 * Has <b> OK </b> status if the method successfully returns. <p>
117 public void _getUseRowHeaders() {
118 useRowHeaders
= oObj
.getUseRowHeaders();
119 tRes
.tested("getUseRowHeaders()", true);
123 * Test sets the new current function, gets current function
124 * and compare function gotten by method <code>getFunction()</code> with
125 * function that was set. <p>
126 * Has <b> OK </b> status if the functions aren't equal. <p>
127 * The following method tests are to be completed successfully before :
129 * <li> <code> getFunction() </code> : to have current value of
130 * the function by which the ranges are consolidated </li>
133 public void _setFunction() {
134 requiredMethod("getFunction()");
135 GeneralFunction aFunction2
= null;
136 if (aFunction
.equals(GeneralFunction
.SUM
)) {
137 aFunction2
= GeneralFunction
.COUNT
;
140 aFunction2
= GeneralFunction
.SUM
;
142 oObj
.setFunction(aFunction2
);
143 aFunction2
= oObj
.getFunction();
144 tRes
.tested("setFunction()", !aFunction
.equals(aFunction2
));
148 * Test sets property to value that negative to the current value
149 * and compares returned value with value that was set. <p>
150 * Has <b> OK </b> status if returned value isn't equal to value that was
151 * stored by method <code>getInsertLinks()</code>. <p>
152 * The following method tests are to be completed successfully before :
154 * <li> <code> getInsertLinks() </code> : to have current value of
155 * this property </li>
158 public void _setInsertLinks() {
159 requiredMethod("getInsertLinks()");
160 oObj
.setInsertLinks( !insertLinks
);
161 boolean insertLinks2
= oObj
.getInsertLinks();
162 tRes
.tested("setInsertLinks()", insertLinks
!= insertLinks2
);
166 * Test sets new cell ranges and compares cell ranges gotten by method
167 * <code>getSources()</code> with the cell range that was set. <p>
168 * Has <b> OK </b> status if returned value isn't equal to value that was
169 * stored by method <code>getSources()</code>. <p>
170 * The following method tests are to be completed successfully before :
172 * <li> <code> getSources() </code> : to have the cell ranges which
173 * are consolidated </li>
176 public void _setSources() {
177 requiredMethod("getSources()");
178 oObj
.setSources(newCRaddr());
179 CellRangeAddress
[] CRaddr2
= oObj
.getSources();
180 tRes
.tested("setSources()",!ValueComparer
.equalValue(CRaddr
, CRaddr2
));
184 * Test sets new cell address for start output position and compares
185 * cell address gotten by method <code>getStartOutputPosition()</code>
186 * with the cell address that was set. <p>
187 * Has <b> OK </b> status if returned value isn't equal to value that was
188 * stored by method <code>getStartOutputPosition()</code>. <p>
189 * The following method tests are to be completed successfully before :
191 * <li> <code> getStartOutputPosition() </code> : to have the cell address
192 * of start output position </li>
195 public void _setStartOutputPosition() {
196 requiredMethod("getStartOutputPosition()");
197 CellAddress addr2
= new CellAddress();
198 addr2
.Column
= addr
.Column
+ 1;
199 addr2
.Row
= addr
.Row
+ 1;
200 oObj
.setStartOutputPosition(addr2
);
201 tRes
.tested("setStartOutputPosition()",
202 !ValueComparer
.equalValue(addr
, addr2
));
206 * Test sets property to value that negative to the current value
207 * and compares returned value with value that was set. <p>
208 * Has <b> OK </b> status if returned value isn't equal to value that was
209 * stored by method <code>getUseColumnHeaders()</code>. <p>
210 * The following method tests are to be completed successfully before :
212 * <li> <code> getUseColumnHeaders() </code> : to have current value of
213 * this property </li>
216 public void _setUseColumnHeaders() {
217 requiredMethod("getUseColumnHeaders()");
218 oObj
.setUseColumnHeaders( !useColumnHeaders
);
219 boolean uCH
= oObj
.getUseColumnHeaders();
220 tRes
.tested("setUseColumnHeaders()", useColumnHeaders
!= uCH
);
224 * Test sets property to value that negative to the current value
225 * and compares returned value with value that was set. <p>
226 * Has <b> OK </b> status if returned value isn't equal to value that was
227 * stored by method <code>getUseRowHeaders()</code>. <p>
228 * The following method tests are to be completed successfully before :
230 * <li> <code> getUseRowHeaders() </code> : to have current value of
231 * this property </li>
234 public void _setUseRowHeaders() {
235 requiredMethod("getUseRowHeaders()");
236 oObj
.setUseRowHeaders(!useRowHeaders
);
237 boolean uRH
= oObj
.getUseRowHeaders();
238 tRes
.tested("setUseRowHeaders()", useRowHeaders
!= uRH
);
242 * Constructs new cell range addresses using old cell range addresses.
243 * @param CRaddr old cell range addresses
244 * @return new cell range addresses
246 public CellRangeAddress
[] newCRaddr() {
248 CellRangeAddress
[] back
= new CellRangeAddress
[1];
250 CellRangeAddress cra1
= new CellRangeAddress();
262 } // finish class _XConsolidationDescriptor