1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.sheet;
25 
26 import lib.MultiMethodTest;
27 import util.ValueComparer;
28 
29 import com.sun.star.sheet.GeneralFunction;
30 import com.sun.star.sheet.XConsolidationDescriptor;
31 import com.sun.star.table.CellAddress;
32 import com.sun.star.table.CellRangeAddress;
33 
34 /**
35 * Testing <code>com.sun.star.sheet.XConsolidationDescriptor</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> getFunction()</code></li>
39 *  <li><code> setFunction()</code></li>
40 *  <li><code> getSources()</code></li>
41 *  <li><code> setSources()</code></li>
42 *  <li><code> getStartOutputPosition()</code></li>
43 *  <li><code> setStartOutputPosition()</code></li>
44 *  <li><code> getUseColumnHeaders()</code></li>
45 *  <li><code> setUseColumnHeaders()</code></li>
46 *  <li><code> getUseRowHeaders()</code></li>
47 *  <li><code> setUseRowHeaders()</code></li>
48 *  <li><code> getInsertLinks()</code></li>
49 *  <li><code> setInsertLinks()</code></li>
50 * </ul> <p>
51 * @see com.sun.star.sheet.XConsolidationDescriptor
52 */
53 public class _XConsolidationDescriptor extends MultiMethodTest {
54 
55     public XConsolidationDescriptor oObj = null;
56     public GeneralFunction aFunction = null;
57     public boolean insertLinks = false;
58     public boolean useColumnHeaders = false;
59     public boolean useRowHeaders = false;
60     public CellRangeAddress[] CRaddr = null;
61     public CellAddress addr = null;
62 
63     /**
64     * Test calls the method, stores and checks returned value. <p>
65     * Has <b> OK </b> status if returned value isn't null. <p>
66     */
_getFunction()67     public void _getFunction() {
68         aFunction = oObj.getFunction();
69         tRes.tested("getFunction()", aFunction != null );
70     }
71 
72     /**
73     * Test calls the method and stores returned value. <p>
74     * Has <b> OK </b> status if the method successfully returns. <p>
75     */
_getInsertLinks()76     public void _getInsertLinks() {
77         insertLinks = oObj.getInsertLinks();
78         tRes.tested("getInsertLinks()", true);
79     }
80 
81     /**
82     * Test calls the method and stores returned value. <p>
83     * Has <b> OK </b> status if the method successfully returns. <p>
84     */
_getSources()85     public void _getSources() {
86         CRaddr = oObj.getSources();
87         int wiev = CRaddr.length;
88         tRes.tested("getSources()", true);
89     }
90 
91     /**
92     * Test calls the method and stores returned value. <p>
93     * Has <b> OK </b> status if the method successfully returns. <p>
94     */
_getStartOutputPosition()95     public void _getStartOutputPosition() {
96         addr = oObj.getStartOutputPosition();
97         tRes.tested("getStartOutputPosition()", true);
98     }
99 
100     /**
101     * Test calls the method and stores returned value. <p>
102     * Has <b> OK </b> status if the method successfully returns. <p>
103     */
_getUseColumnHeaders()104     public void _getUseColumnHeaders() {
105         useColumnHeaders = oObj.getUseColumnHeaders();
106         tRes.tested("getUseColumnHeaders()", true);
107     }
108 
109     /**
110     * Test calls the method and stores returned value. <p>
111     * Has <b> OK </b> status if the method successfully returns. <p>
112     */
_getUseRowHeaders()113     public void _getUseRowHeaders() {
114         useRowHeaders = oObj.getUseRowHeaders();
115         tRes.tested("getUseRowHeaders()", true);
116     }
117 
118     /**
119     * Test sets the new current function, gets current function
120     * and compare function gotten by method <code>getFunction()</code> with
121     * function that was set. <p>
122     * Has <b> OK </b> status if the functions aren't equal. <p>
123     * The following method tests are to be completed successfully before :
124     * <ul>
125     *  <li> <code> getFunction() </code> : to have current value of
126     *  the function by which the ranges are consolidated </li>
127     * </ul>
128     */
_setFunction()129     public void _setFunction() {
130         requiredMethod("getFunction()");
131         GeneralFunction aFunction2 = null;
132         if (aFunction.equals(GeneralFunction.SUM)) {
133             aFunction2 = GeneralFunction.COUNT;
134         }
135         else {
136             aFunction2 = GeneralFunction.SUM;
137         }
138         oObj.setFunction(aFunction2);
139         aFunction2 = oObj.getFunction();
140         tRes.tested("setFunction()", !aFunction.equals(aFunction2));
141     }
142 
143     /**
144     * Test sets property to value that negative to the current value
145     * and compares returned value with value that was set. <p>
146     * Has <b> OK </b> status if returned value isn't equal to value that was
147     * stored by method <code>getInsertLinks()</code>. <p>
148     * The following method tests are to be completed successfully before :
149     * <ul>
150     *  <li> <code> getInsertLinks() </code> : to have current value of
151     *  this property </li>
152     * </ul>
153     */
_setInsertLinks()154     public void _setInsertLinks() {
155         requiredMethod("getInsertLinks()");
156         oObj.setInsertLinks( !insertLinks );
157         boolean insertLinks2 = oObj.getInsertLinks();
158         tRes.tested("setInsertLinks()", insertLinks != insertLinks2);
159     }
160 
161     /**
162     * Test sets new cell ranges and compares cell ranges gotten by method
163     * <code>getSources()</code> with the cell range that was set. <p>
164     * Has <b> OK </b> status if returned value isn't equal to value that was
165     * stored by method <code>getSources()</code>. <p>
166     * The following method tests are to be completed successfully before :
167     * <ul>
168     *  <li> <code> getSources() </code> : to have the cell ranges which
169     *  are consolidated </li>
170     * </ul>
171     */
_setSources()172     public void _setSources() {
173         requiredMethod("getSources()");
174         oObj.setSources(newCRaddr());
175         CellRangeAddress[] CRaddr2 = oObj.getSources();
176         tRes.tested("setSources()",!ValueComparer.equalValue(CRaddr, CRaddr2));
177     }
178 
179     /**
180     * Test sets new cell address for start output position and compares
181     * cell address gotten by method <code>getStartOutputPosition()</code>
182     * with the cell address that was set. <p>
183     * Has <b> OK </b> status if returned value isn't equal to value that was
184     * stored by method <code>getStartOutputPosition()</code>. <p>
185     * The following method tests are to be completed successfully before :
186     * <ul>
187     *  <li> <code> getStartOutputPosition() </code> : to have the cell address
188     *  of start output position </li>
189     * </ul>
190     */
_setStartOutputPosition()191     public void _setStartOutputPosition() {
192         requiredMethod("getStartOutputPosition()");
193         CellAddress addr2 = new CellAddress();
194         addr2.Column = addr.Column + 1;
195         addr2.Row = addr.Row + 1;
196         oObj.setStartOutputPosition(addr2);
197         tRes.tested("setStartOutputPosition()",
198             !ValueComparer.equalValue(addr, addr2));
199     }
200 
201     /**
202     * Test sets property to value that negative to the current value
203     * and compares returned value with value that was set. <p>
204     * Has <b> OK </b> status if returned value isn't equal to value that was
205     * stored by method <code>getUseColumnHeaders()</code>. <p>
206     * The following method tests are to be completed successfully before :
207     * <ul>
208     *  <li> <code> getUseColumnHeaders() </code> : to have current value of
209     *  this property </li>
210     * </ul>
211     */
_setUseColumnHeaders()212     public void _setUseColumnHeaders() {
213         requiredMethod("getUseColumnHeaders()");
214         oObj.setUseColumnHeaders( !useColumnHeaders );
215         boolean uCH = oObj.getUseColumnHeaders();
216         tRes.tested("setUseColumnHeaders()", useColumnHeaders != uCH);
217     }
218 
219     /**
220     * Test sets property to value that negative to the current value
221     * and compares returned value with value that was set. <p>
222     * Has <b> OK </b> status if returned value isn't equal to value that was
223     * stored by method <code>getUseRowHeaders()</code>. <p>
224     * The following method tests are to be completed successfully before :
225     * <ul>
226     *  <li> <code> getUseRowHeaders() </code> : to have current value of
227     *  this property </li>
228     * </ul>
229     */
_setUseRowHeaders()230     public void _setUseRowHeaders() {
231         requiredMethod("getUseRowHeaders()");
232         oObj.setUseRowHeaders(!useRowHeaders);
233         boolean uRH = oObj.getUseRowHeaders();
234         tRes.tested("setUseRowHeaders()", useRowHeaders != uRH );
235     }
236 
237     /**
238     * Constructs new cell range addresses using old cell range addresses.
239     * @return new cell range addresses
240     */
newCRaddr()241     public CellRangeAddress[] newCRaddr() {
242 
243         CellRangeAddress[] back = new CellRangeAddress[1];
244 
245         CellRangeAddress cra1 = new CellRangeAddress();
246         cra1.EndColumn=5;
247         cra1.EndRow=5;
248         cra1.Sheet=(short)0;
249         cra1.StartColumn=1;
250         cra1.StartRow=1;
251         back[0]=cra1;
252 
253         return back;
254     }
255 
256 
257 }  // finish class _XConsolidationDescriptor
258 
259 
260