Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XSheetConditionalEntries.java
blobec8976a5d09e5ac77c7f2ad935626b8b3c5de223
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSheetConditionalEntries.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sheet;
33 import lib.MultiMethodTest;
35 import com.sun.star.beans.PropertyValue;
36 import com.sun.star.sheet.ConditionOperator;
37 import com.sun.star.sheet.XSheetConditionalEntries;
38 import com.sun.star.table.CellAddress;
40 /**
41 * Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code>
42 * interface methods :
43 * <ul>
44 * <li><code> addNew()</code></li>
45 * <li><code> removeByIndex()</code></li>
46 * <li><code> clear()</code></li>
47 * </ul> <p>
48 * @see com.sun.star.sheet.XSheetConditionalEntries
50 public class _XSheetConditionalEntries extends MultiMethodTest {
51 public XSheetConditionalEntries oObj = null;
52 int nNum = 0;
54 /**
55 * Test adds a conditional entry to the format. <p>
56 * Has <b> OK </b> status if the method successfully returns. <p>
58 public void _addNew() {
59 nNum = oObj.getCount();
60 oObj.addNew( Conditions(4) );
61 boolean res = (nNum + 1) == oObj.getCount();
63 tRes.tested("addNew()", res);
66 /**
67 * Test calls the method and checks number of conditional entries in
68 * collection. <p>
69 * Has <b> OK </b> status if number of conditional entries in co0llection
70 * after method call is equal zero. <p>
71 * The following method tests are to be completed successfully before :
72 * <ul>
73 * <li> <code> addNew() </code> : to have one conditional entry in
74 * collection at least </li>
75 * </ul>
77 public void _clear() {
78 requiredMethod("removeByIndex()");
79 oObj.clear();
80 int anz = oObj.getCount();
81 tRes.tested("clear()", anz == 0);
84 /**
85 * Test adds a conditional entry, removes entry with index 0
86 * and compares number of entries after adding to number of entries after
87 * removing. <p>
88 * Has <b> OK </b> status if number of entries after adding is greater
89 * than number of entries after removing. <p>
90 * The following method tests are to be completed successfully before :
91 * <ul>
92 * <li> <code> clear() </code> : to be sure that collection hasn't
93 * elements </li>
94 * </ul>
96 public void _removeByIndex() {
97 requiredMethod("addNew()");
98 oObj.removeByIndex(0);
99 int pastNum = oObj.getCount();
100 tRes.tested("removeByIndex()", pastNum == nNum);
104 * Method creates array of property value for conditional entry using
105 * passed parameter <code>nr</code>.
106 * @param nr number of row for conditional entry
108 protected PropertyValue[] Conditions(int nr) {
109 PropertyValue[] con = new PropertyValue[5];
110 CellAddress ca = new CellAddress();
111 ca.Column = 1;
112 ca.Row = 5;
113 ca.Sheet = 0;
114 con[0] = new PropertyValue();
115 con[0].Name = "StyleName";
116 con[0].Value = "Result2";
117 con[1] = new PropertyValue();
118 con[1].Name = "Formula1";
119 con[1].Value = "$Sheet1.$B$"+nr;
120 con[2] = new PropertyValue();
121 con[2].Name = "Formula2";
122 con[2].Value = "";
123 con[3] = new PropertyValue();
124 con[3].Name = "Operator";
125 con[3].Value = ConditionOperator.EQUAL;
126 con[4] = new PropertyValue();
127 con[4].Name = "SourcePosition";
128 con[4].Value = ca;
129 return con;
133 * Forces object environment recreation.
135 protected void after() {
136 this.disposeEnvironment();
138 } // finish class _XSheetConditionalEntries