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 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.table
.CellContentType
;
33 import com
.sun
.star
.table
.XCell
;
37 * Testing <code>com.sun.star.table.XCell</code>
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>
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;
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 :
60 * <li> <code> setFormula() </code> : the method must set proper
61 * formula into cell, so there must be no errors </li>
64 public void _getError() {
65 requiredMethod("setFormula()") ;
67 boolean result
= true;
69 if (oObj
.getError() != 0) {
71 log
.println("getError(): Expected error code is 0, but returned " +
74 oObj
.setFormula("=sqrt(-2)") ; // incorrect formula
75 if (oObj
.getError() == 0) {
77 log
.println("getError(): # Non zero error code expected,"+
81 tRes
.tested("getError()", result
);
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;
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
);
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;
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 ;
116 tRes
.tested ("getType()", result
) ;
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;
127 log
.println("getValue() ...");
129 value
= (double) oObj
.getValue();
131 tRes
.tested("getValue()",result
);
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;
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
) ;
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
);