Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XCell.java
blob0e29e2cbc644045285d4d6d2ca074bd0fe780047
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package ifc.table;
30 import lib.MultiMethodTest;
32 import com.sun.star.table.CellContentType;
33 import com.sun.star.table.XCell;
36 /**
37 * Testing <code>com.sun.star.table.XCell</code>
38 * interface methods :
39 * <ul>
40 * <li><code> getFormula()</code></li>
41 * <li><code> setFormula()</code></li>
42 * <li><code> getValue()</code></li>
43 * <li><code> setValue()</code></li>
44 * <li><code> getType()</code></li>
45 * <li><code> getError()</code></li>
46 * </ul> <p>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.table.XCell
50 public class _XCell extends MultiMethodTest {
51 public XCell oObj = null;
53 /**
54 * First time errors checked when a proper formula is entered.
55 * Second time an incorrect formula entered and errors are checked.<p>
56 * Has <b> OK </b> status if in the first case error code 0 returned,
57 * and in the second case none-zerro code returned. <p>
58 * The following method tests are to be completed successfully before :
59 * <ul>
60 * <li> <code> setFormula() </code> : the method must set proper
61 * formula into cell, so there must be no errors </li>
62 * </ul>
64 public void _getError() {
65 requiredMethod("setFormula()") ;
67 boolean result = true;
69 if (oObj.getError() != 0) {
70 result = false ;
71 log.println("getError(): Expected error code is 0, but returned " +
72 oObj.getError()) ;
74 oObj.setFormula("=sqrt(-2)") ; // incorrect formula
75 if (oObj.getError() == 0) {
76 result = false ;
77 log.println("getError(): # Non zero error code expected,"+
78 " but 0 returned") ;
81 tRes.tested("getError()", result);
82 } // end getError()
84 /**
85 * Sets a formula and then gets it. <p>
86 * Has <b> OK </b> status if the formula set are the same as get. <p>
88 public void _getFormula() {
89 boolean result = true;
91 String formula = "";
92 log.println("getFormula()");
93 oObj.setFormula("=2+2");
95 formula = (String) oObj.getFormula();
97 result &= formula.endsWith("2+2");
98 tRes.tested("getFormula()", result);
99 } // end getFormula()
102 * Gets the type and check it. <p>
103 * Has <b> OK </b> status if the type is one of valid values. <p>
105 public void _getType() {
106 boolean result = true;
107 result = true ;
108 log.println("getType() ...");
110 if(oObj.getType() == CellContentType.EMPTY) result &= true ;
111 else if (oObj.getType() == CellContentType.VALUE) result &= true ;
112 else if (oObj.getType() == CellContentType.TEXT) result &= true ;
113 else if (oObj.getType() == CellContentType.FORMULA) result &= true ;
114 else result = false;
116 tRes.tested ("getType()", result) ;
117 } // end getType()
120 * Test calls the method. <p>
121 * Has <b> OK </b> status if the method successfully returns
122 * and no exceptions were thrown. <p>
124 public void _getValue() {
125 boolean result = true;
126 double value = 0;
127 log.println("getValue() ...");
129 value = (double) oObj.getValue();
131 tRes.tested("getValue()",result);
132 } // end getValue()
135 * Sets a formula and then gets it. <p>
136 * Has <b> OK </b> status if the formula set are the same as get. <p>
138 public void _setFormula() {
139 boolean result = true;
140 String formula = "";
141 log.println("setFormula() ...");
143 oObj.setFormula("=2/6") ;
145 formula = (String) oObj.getFormula();
147 result &= formula.endsWith("2/6");
148 tRes.tested ("setFormula()", result) ;
149 } // end setFormula
152 * Sets a value and then gets it. <p>
153 * Has <b> OK </b> status if the value set is equal to value get. <p>
155 public void _setValue() {
156 boolean result = true;
157 double cellValue = 0;
158 log.println("setValue() ...");
160 oObj.setValue(222.333) ;
161 cellValue = (double) oObj.getValue() ;
163 result &= (cellValue == 222.333);
164 tRes.tested("setValue()", result);
165 } // end setValue()