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 28 import com.sun.star.beans.PropertyValue; 29 import com.sun.star.sheet.ConditionOperator; 30 import com.sun.star.sheet.XSheetConditionalEntries; 31 import com.sun.star.table.CellAddress; 32 33 /** 34 * Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code> 35 * interface methods : 36 * <ul> 37 * <li><code> addNew()</code></li> 38 * <li><code> removeByIndex()</code></li> 39 * <li><code> clear()</code></li> 40 * </ul> <p> 41 * @see com.sun.star.sheet.XSheetConditionalEntries 42 */ 43 public class _XSheetConditionalEntries extends MultiMethodTest { 44 public XSheetConditionalEntries oObj = null; 45 int nNum = 0; 46 47 /** 48 * Test adds a conditional entry to the format. <p> 49 * Has <b> OK </b> status if the method successfully returns. <p> 50 */ _addNew()51 public void _addNew() { 52 nNum = oObj.getCount(); 53 oObj.addNew( Conditions(4) ); 54 boolean res = (nNum + 1) == oObj.getCount(); 55 56 tRes.tested("addNew()", res); 57 } 58 59 /** 60 * Test calls the method and checks number of conditional entries in 61 * collection. <p> 62 * Has <b> OK </b> status if number of conditional entries in co0llection 63 * after method call is equal zero. <p> 64 * The following method tests are to be completed successfully before : 65 * <ul> 66 * <li> <code> addNew() </code> : to have one conditional entry in 67 * collection at least </li> 68 * </ul> 69 */ _clear()70 public void _clear() { 71 requiredMethod("removeByIndex()"); 72 oObj.clear(); 73 int anz = oObj.getCount(); 74 tRes.tested("clear()", anz == 0); 75 } 76 77 /** 78 * Test adds a conditional entry, removes entry with index 0 79 * and compares number of entries after adding to number of entries after 80 * removing. <p> 81 * Has <b> OK </b> status if number of entries after adding is greater 82 * than number of entries after removing. <p> 83 * The following method tests are to be completed successfully before : 84 * <ul> 85 * <li> <code> clear() </code> : to be sure that collection hasn't 86 * elements </li> 87 * </ul> 88 */ _removeByIndex()89 public void _removeByIndex() { 90 requiredMethod("addNew()"); 91 oObj.removeByIndex(0); 92 int pastNum = oObj.getCount(); 93 tRes.tested("removeByIndex()", pastNum == nNum); 94 } 95 96 /** 97 * Method creates array of property value for conditional entry using 98 * passed parameter <code>nr</code>. 99 * @param nr number of row for conditional entry 100 */ Conditions(int nr)101 protected PropertyValue[] Conditions(int nr) { 102 PropertyValue[] con = new PropertyValue[5]; 103 CellAddress ca = new CellAddress(); 104 ca.Column = 1; 105 ca.Row = 5; 106 ca.Sheet = 0; 107 con[0] = new PropertyValue(); 108 con[0].Name = "StyleName"; 109 con[0].Value = "Result2"; 110 con[1] = new PropertyValue(); 111 con[1].Name = "Formula1"; 112 con[1].Value = "$Sheet1.$B$"+nr; 113 con[2] = new PropertyValue(); 114 con[2].Name = "Formula2"; 115 con[2].Value = ""; 116 con[3] = new PropertyValue(); 117 con[3].Name = "Operator"; 118 con[3].Value = ConditionOperator.EQUAL; 119 con[4] = new PropertyValue(); 120 con[4].Name = "SourcePosition"; 121 con[4].Value = ca; 122 return con; 123 } 124 125 /** 126 * Forces object environment recreation. 127 */ after()128 protected void after() { 129 this.disposeEnvironment(); 130 } 131 } // finish class _XSheetConditionalEntries 132 133 134