1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.sheet; 29 30 import lib.MultiMethodTest; 31 import util.ValueComparer; 32 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; 37 38 /** 39 * Testing <code>com.sun.star.sheet.XConsolidationDescriptor</code> 40 * interface methods : 41 * <ul> 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> 54 * </ul> <p> 55 * @see com.sun.star.sheet.XConsolidationDescriptor 56 */ 57 public class _XConsolidationDescriptor extends MultiMethodTest { 58 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; 66 67 /** 68 * Test calls the method, stores and checks returned value. <p> 69 * Has <b> OK </b> status if returned value isn't null. <p> 70 */ 71 public void _getFunction() { 72 aFunction = oObj.getFunction(); 73 tRes.tested("getFunction()", aFunction != null ); 74 } 75 76 /** 77 * Test calls the method and stores returned value. <p> 78 * Has <b> OK </b> status if the method successfully returns. <p> 79 */ 80 public void _getInsertLinks() { 81 insertLinks = oObj.getInsertLinks(); 82 tRes.tested("getInsertLinks()", true); 83 } 84 85 /** 86 * Test calls the method and stores returned value. <p> 87 * Has <b> OK </b> status if the method successfully returns. <p> 88 */ 89 public void _getSources() { 90 CRaddr = oObj.getSources(); 91 int wiev = CRaddr.length; 92 tRes.tested("getSources()", true); 93 } 94 95 /** 96 * Test calls the method and stores returned value. <p> 97 * Has <b> OK </b> status if the method successfully returns. <p> 98 */ 99 public void _getStartOutputPosition() { 100 addr = oObj.getStartOutputPosition(); 101 tRes.tested("getStartOutputPosition()", true); 102 } 103 104 /** 105 * Test calls the method and stores returned value. <p> 106 * Has <b> OK </b> status if the method successfully returns. <p> 107 */ 108 public void _getUseColumnHeaders() { 109 useColumnHeaders = oObj.getUseColumnHeaders(); 110 tRes.tested("getUseColumnHeaders()", true); 111 } 112 113 /** 114 * Test calls the method and stores returned value. <p> 115 * Has <b> OK </b> status if the method successfully returns. <p> 116 */ 117 public void _getUseRowHeaders() { 118 useRowHeaders = oObj.getUseRowHeaders(); 119 tRes.tested("getUseRowHeaders()", true); 120 } 121 122 /** 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 : 128 * <ul> 129 * <li> <code> getFunction() </code> : to have current value of 130 * the function by which the ranges are consolidated </li> 131 * </ul> 132 */ 133 public void _setFunction() { 134 requiredMethod("getFunction()"); 135 GeneralFunction aFunction2 = null; 136 if (aFunction.equals(GeneralFunction.SUM)) { 137 aFunction2 = GeneralFunction.COUNT; 138 } 139 else { 140 aFunction2 = GeneralFunction.SUM; 141 } 142 oObj.setFunction(aFunction2); 143 aFunction2 = oObj.getFunction(); 144 tRes.tested("setFunction()", !aFunction.equals(aFunction2)); 145 } 146 147 /** 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 : 153 * <ul> 154 * <li> <code> getInsertLinks() </code> : to have current value of 155 * this property </li> 156 * </ul> 157 */ 158 public void _setInsertLinks() { 159 requiredMethod("getInsertLinks()"); 160 oObj.setInsertLinks( !insertLinks ); 161 boolean insertLinks2 = oObj.getInsertLinks(); 162 tRes.tested("setInsertLinks()", insertLinks != insertLinks2); 163 } 164 165 /** 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 : 171 * <ul> 172 * <li> <code> getSources() </code> : to have the cell ranges which 173 * are consolidated </li> 174 * </ul> 175 */ 176 public void _setSources() { 177 requiredMethod("getSources()"); 178 oObj.setSources(newCRaddr()); 179 CellRangeAddress[] CRaddr2 = oObj.getSources(); 180 tRes.tested("setSources()",!ValueComparer.equalValue(CRaddr, CRaddr2)); 181 } 182 183 /** 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 : 190 * <ul> 191 * <li> <code> getStartOutputPosition() </code> : to have the cell address 192 * of start output position </li> 193 * </ul> 194 */ 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)); 203 } 204 205 /** 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 : 211 * <ul> 212 * <li> <code> getUseColumnHeaders() </code> : to have current value of 213 * this property </li> 214 * </ul> 215 */ 216 public void _setUseColumnHeaders() { 217 requiredMethod("getUseColumnHeaders()"); 218 oObj.setUseColumnHeaders( !useColumnHeaders ); 219 boolean uCH = oObj.getUseColumnHeaders(); 220 tRes.tested("setUseColumnHeaders()", useColumnHeaders != uCH); 221 } 222 223 /** 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 : 229 * <ul> 230 * <li> <code> getUseRowHeaders() </code> : to have current value of 231 * this property </li> 232 * </ul> 233 */ 234 public void _setUseRowHeaders() { 235 requiredMethod("getUseRowHeaders()"); 236 oObj.setUseRowHeaders(!useRowHeaders); 237 boolean uRH = oObj.getUseRowHeaders(); 238 tRes.tested("setUseRowHeaders()", useRowHeaders != uRH ); 239 } 240 241 /** 242 * Constructs new cell range addresses using old cell range addresses. 243 * @param CRaddr old cell range addresses 244 * @return new cell range addresses 245 */ 246 public CellRangeAddress[] newCRaddr() { 247 248 CellRangeAddress[] back = new CellRangeAddress[1]; 249 250 CellRangeAddress cra1 = new CellRangeAddress(); 251 cra1.EndColumn=5; 252 cra1.EndRow=5; 253 cra1.Sheet=(short)0; 254 cra1.StartColumn=1; 255 cra1.StartRow=1; 256 back[0]=cra1; 257 258 return back; 259 } 260 261 262 } // finish class _XConsolidationDescriptor 263 264 265