merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / table / _XCell.java
blob90a9be606bd6a26f17218325b831840b2c3a17ff
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: _XCell.java,v $
10 * $Revision: 1.4 $
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.table;
33 import lib.MultiMethodTest;
35 import com.sun.star.table.CellContentType;
36 import com.sun.star.table.XCell;
39 /**
40 * Testing <code>com.sun.star.table.XCell</code>
41 * interface methods :
42 * <ul>
43 * <li><code> getFormula()</code></li>
44 * <li><code> setFormula()</code></li>
45 * <li><code> getValue()</code></li>
46 * <li><code> setValue()</code></li>
47 * <li><code> getType()</code></li>
48 * <li><code> getError()</code></li>
49 * </ul> <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.table.XCell
53 public class _XCell extends MultiMethodTest {
54 public XCell oObj = null;
56 /**
57 * First time errors checked when a proper formula is entered.
58 * Second time an incorrect formula entered and errors are checked.<p>
59 * Has <b> OK </b> status if in the first case error code 0 returned,
60 * and in the second case none-zerro code returned. <p>
61 * The following method tests are to be completed successfully before :
62 * <ul>
63 * <li> <code> setFormula() </code> : the method must set proper
64 * formula into cell, so there must be no errors </li>
65 * </ul>
67 public void _getError() {
68 requiredMethod("setFormula()") ;
70 boolean result = true;
72 if (oObj.getError() != 0) {
73 result = false ;
74 log.println("getError(): Expected error code is 0, but returned " +
75 oObj.getError()) ;
77 oObj.setFormula("=sqrt(-2)") ; // incorrect formula
78 if (oObj.getError() == 0) {
79 result = false ;
80 log.println("getError(): # Non zero error code expected,"+
81 " but 0 returned") ;
84 tRes.tested("getError()", result);
85 } // end getError()
87 /**
88 * Sets a formula and then gets it. <p>
89 * Has <b> OK </b> status if the formula set are the same as get. <p>
91 public void _getFormula() {
92 boolean result = true;
94 String formula = "";
95 log.println("getFormula()");
96 oObj.setFormula("=2+2");
98 formula = (String) oObj.getFormula();
100 result &= formula.endsWith("2+2");
101 tRes.tested("getFormula()", result);
102 } // end getFormula()
105 * Gets the type and check it. <p>
106 * Has <b> OK </b> status if the type is one of valid values. <p>
108 public void _getType() {
109 boolean result = true;
110 result = true ;
111 log.println("getType() ...");
113 if(oObj.getType() == CellContentType.EMPTY) result &= true ;
114 else if (oObj.getType() == CellContentType.VALUE) result &= true ;
115 else if (oObj.getType() == CellContentType.TEXT) result &= true ;
116 else if (oObj.getType() == CellContentType.FORMULA) result &= true ;
117 else result = false;
119 tRes.tested ("getType()", result) ;
120 } // end getType()
123 * Test calls the method. <p>
124 * Has <b> OK </b> status if the method successfully returns
125 * and no exceptions were thrown. <p>
127 public void _getValue() {
128 boolean result = true;
129 double value = 0;
130 log.println("getValue() ...");
132 value = (double) oObj.getValue();
134 tRes.tested("getValue()",result);
135 } // end getValue()
138 * Sets a formula and then gets it. <p>
139 * Has <b> OK </b> status if the formula set are the same as get. <p>
141 public void _setFormula() {
142 boolean result = true;
143 String formula = "";
144 log.println("setFormula() ...");
146 oObj.setFormula("=2/6") ;
148 formula = (String) oObj.getFormula();
150 result &= formula.endsWith("2/6");
151 tRes.tested ("setFormula()", result) ;
152 } // end setFormula
155 * Sets a value and then gets it. <p>
156 * Has <b> OK </b> status if the value set is equal to value get. <p>
158 public void _setValue() {
159 boolean result = true;
160 double cellValue = 0;
161 log.println("setValue() ...");
163 oObj.setValue(222.333) ;
164 cellValue = (double) oObj.getValue() ;
166 result &= (cellValue == 222.333);
167 tRes.tested("setValue()", result);
168 } // end setValue()