xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java (revision ef39d40d3f5e66cf3f035b3e93783012b340500d)
1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.sheet;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiMethodTest;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
29cdf0e10cSrcweir import com.sun.star.sheet.ConditionOperator;
30cdf0e10cSrcweir import com.sun.star.sheet.XSheetConditionalEntries;
31cdf0e10cSrcweir import com.sun.star.table.CellAddress;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /**
34cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code>
35cdf0e10cSrcweir * interface methods :
36cdf0e10cSrcweir * <ul>
37cdf0e10cSrcweir *  <li><code> addNew()</code></li>
38cdf0e10cSrcweir *  <li><code> removeByIndex()</code></li>
39cdf0e10cSrcweir *  <li><code> clear()</code></li>
40cdf0e10cSrcweir * </ul> <p>
41cdf0e10cSrcweir * @see com.sun.star.sheet.XSheetConditionalEntries
42cdf0e10cSrcweir */
43cdf0e10cSrcweir public class _XSheetConditionalEntries extends MultiMethodTest {
44cdf0e10cSrcweir     public XSheetConditionalEntries oObj = null;
45cdf0e10cSrcweir     int nNum = 0;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     /**
48cdf0e10cSrcweir     * Test adds a conditional entry to the format. <p>
49cdf0e10cSrcweir     * Has <b> OK </b> status if the method successfully returns. <p>
50cdf0e10cSrcweir     */
_addNew()51cdf0e10cSrcweir     public void _addNew() {
52cdf0e10cSrcweir         nNum = oObj.getCount();
53cdf0e10cSrcweir         oObj.addNew( Conditions(4) );
54cdf0e10cSrcweir         boolean res = (nNum + 1) == oObj.getCount();
55cdf0e10cSrcweir 
56cdf0e10cSrcweir         tRes.tested("addNew()", res);
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /**
60cdf0e10cSrcweir     * Test calls the method and checks number of conditional entries in
61cdf0e10cSrcweir     * collection. <p>
62cdf0e10cSrcweir     * Has <b> OK </b> status if number of conditional entries in co0llection
63cdf0e10cSrcweir     * after method call is equal zero. <p>
64cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
65cdf0e10cSrcweir     * <ul>
66cdf0e10cSrcweir     *  <li> <code> addNew() </code> : to have one conditional entry in
67cdf0e10cSrcweir     *  collection at least </li>
68cdf0e10cSrcweir     * </ul>
69cdf0e10cSrcweir     */
_clear()70cdf0e10cSrcweir     public void _clear() {
71cdf0e10cSrcweir         requiredMethod("removeByIndex()");
72cdf0e10cSrcweir         oObj.clear();
73cdf0e10cSrcweir         int anz = oObj.getCount();
74cdf0e10cSrcweir         tRes.tested("clear()", anz == 0);
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /**
78cdf0e10cSrcweir     * Test adds a conditional entry, removes entry with index 0
79cdf0e10cSrcweir     * and compares number of entries after adding to number of entries after
80cdf0e10cSrcweir     * removing. <p>
81cdf0e10cSrcweir     * Has <b> OK </b> status if number of entries after adding is greater
82cdf0e10cSrcweir     * than number of entries after removing. <p>
83cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
84cdf0e10cSrcweir     * <ul>
85cdf0e10cSrcweir     *  <li> <code> clear() </code> : to be sure that collection hasn't
86cdf0e10cSrcweir     *  elements </li>
87cdf0e10cSrcweir     * </ul>
88cdf0e10cSrcweir     */
_removeByIndex()89cdf0e10cSrcweir     public void _removeByIndex() {
90cdf0e10cSrcweir         requiredMethod("addNew()");
91cdf0e10cSrcweir         oObj.removeByIndex(0);
92cdf0e10cSrcweir         int pastNum = oObj.getCount();
93cdf0e10cSrcweir         tRes.tested("removeByIndex()", pastNum == nNum);
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     /**
97cdf0e10cSrcweir     * Method creates array of property value for conditional entry using
98cdf0e10cSrcweir     * passed parameter <code>nr</code>.
99cdf0e10cSrcweir     * @param nr number of row for conditional entry
100cdf0e10cSrcweir     */
Conditions(int nr)101cdf0e10cSrcweir     protected PropertyValue[] Conditions(int nr) {
102cdf0e10cSrcweir         PropertyValue[] con = new PropertyValue[5];
103cdf0e10cSrcweir         CellAddress ca = new CellAddress();
104cdf0e10cSrcweir         ca.Column = 1;
105cdf0e10cSrcweir         ca.Row = 5;
106cdf0e10cSrcweir         ca.Sheet = 0;
107cdf0e10cSrcweir         con[0] = new PropertyValue();
108cdf0e10cSrcweir         con[0].Name = "StyleName";
109cdf0e10cSrcweir         con[0].Value = "Result2";
110cdf0e10cSrcweir         con[1] = new PropertyValue();
111cdf0e10cSrcweir         con[1].Name = "Formula1";
112cdf0e10cSrcweir         con[1].Value = "$Sheet1.$B$"+nr;
113cdf0e10cSrcweir         con[2] = new PropertyValue();
114cdf0e10cSrcweir         con[2].Name = "Formula2";
115cdf0e10cSrcweir         con[2].Value = "";
116cdf0e10cSrcweir         con[3] = new PropertyValue();
117cdf0e10cSrcweir         con[3].Name = "Operator";
118cdf0e10cSrcweir         con[3].Value = ConditionOperator.EQUAL;
119cdf0e10cSrcweir         con[4] = new PropertyValue();
120cdf0e10cSrcweir         con[4].Name = "SourcePosition";
121cdf0e10cSrcweir         con[4].Value = ca;
122cdf0e10cSrcweir         return con;
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     /**
126cdf0e10cSrcweir     * Forces object environment recreation.
127cdf0e10cSrcweir     */
after()128cdf0e10cSrcweir     protected void after() {
129cdf0e10cSrcweir         this.disposeEnvironment();
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir }  // finish class _XSheetConditionalEntries
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134