Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XCell.java
blob00c393ec2ed2b2fc589179f9778f8abc91fd5be5
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.table;
21 import lib.MultiMethodTest;
23 import com.sun.star.table.CellContentType;
24 import com.sun.star.table.XCell;
27 /**
28 * Testing <code>com.sun.star.table.XCell</code>
29 * interface methods :
30 * <ul>
31 * <li><code> getFormula()</code></li>
32 * <li><code> setFormula()</code></li>
33 * <li><code> getValue()</code></li>
34 * <li><code> setValue()</code></li>
35 * <li><code> getType()</code></li>
36 * <li><code> getError()</code></li>
37 * </ul> <p>
38 * Test is <b> NOT </b> multithread compliant. <p>
39 * @see com.sun.star.table.XCell
41 public class _XCell extends MultiMethodTest {
42 public XCell oObj = null;
44 /**
45 * First time errors checked when a proper formula is entered.
46 * Second time an incorrect formula entered and errors are checked.<p>
47 * Has <b> OK </b> status if in the first case error code 0 returned,
48 * and in the second case none-zerro code returned. <p>
49 * The following method tests are to be completed successfully before :
50 * <ul>
51 * <li> <code> setFormula() </code> : the method must set proper
52 * formula into cell, so there must be no errors </li>
53 * </ul>
55 public void _getError() {
56 requiredMethod("setFormula()") ;
58 boolean result = true;
60 if (oObj.getError() != 0) {
61 result = false ;
62 log.println("getError(): Expected error code is 0, but returned " +
63 oObj.getError()) ;
65 oObj.setFormula("=sqrt(-2)") ; // incorrect formula
66 if (oObj.getError() == 0) {
67 result = false ;
68 log.println("getError(): # Non zero error code expected,"+
69 " but 0 returned") ;
72 tRes.tested("getError()", result);
73 } // end getError()
75 /**
76 * Sets a formula and then gets it. <p>
77 * Has <b> OK </b> status if the formula set are the same as get. <p>
79 public void _getFormula() {
80 boolean result = true;
82 String formula = "";
83 log.println("getFormula()");
84 oObj.setFormula("=2+2");
86 formula = oObj.getFormula();
88 result &= formula.endsWith("2+2");
89 tRes.tested("getFormula()", result);
90 } // end getFormula()
92 /**
93 * Gets the type and check it. <p>
94 * Has <b> OK </b> status if the type is one of valid values. <p>
96 public void _getType() {
97 boolean result = true;
98 result = true ;
99 log.println("getType() ...");
101 if(oObj.getType() == CellContentType.EMPTY) result &= true ;
102 else if (oObj.getType() == CellContentType.VALUE) result &= true ;
103 else if (oObj.getType() == CellContentType.TEXT) result &= true ;
104 else if (oObj.getType() == CellContentType.FORMULA) result &= true ;
105 else result = false;
107 tRes.tested ("getType()", result) ;
108 } // end getType()
111 * Test calls the method. <p>
112 * Has <b> OK </b> status if the method successfully returns
113 * and no exceptions were thrown. <p>
115 public void _getValue() {
116 boolean result = true;
117 log.println("getValue() ...");
119 oObj.getValue();
121 tRes.tested("getValue()",result);
122 } // end getValue()
125 * Sets a formula and then gets it. <p>
126 * Has <b> OK </b> status if the formula set are the same as get. <p>
128 public void _setFormula() {
129 boolean result = true;
130 String formula = "";
131 log.println("setFormula() ...");
133 oObj.setFormula("=2/6") ;
135 formula = oObj.getFormula();
137 result &= formula.endsWith("2/6");
138 tRes.tested ("setFormula()", result) ;
139 } // end setFormula
142 * Sets a value and then gets it. <p>
143 * Has <b> OK </b> status if the value set is equal to value get. <p>
145 public void _setValue() {
146 boolean result = true;
147 double cellValue = 0;
148 log.println("setValue() ...");
150 oObj.setValue(222.333) ;
151 cellValue = oObj.getValue() ;
153 result &= (cellValue == 222.333);
154 tRes.tested("setValue()", result);
155 } // end setValue()