1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.sheet;
29 
30 import lib.MultiMethodTest;
31 import util.ValueChanger;
32 
33 import com.sun.star.sheet.ConditionOperator;
34 import com.sun.star.sheet.XSheetCondition;
35 import com.sun.star.table.CellAddress;
36 
37 /**
38 * Testing <code>com.sun.star.sheet.XSheetCondition</code>
39 * interface methods :
40 * <ul>
41 *  <li><code> getOperator()</code></li>
42 *  <li><code> setOperator()</code></li>
43 *  <li><code> getFormula1()</code></li>
44 *  <li><code> setFormula1()</code></li>
45 *  <li><code> getFormula2()</code></li>
46 *  <li><code> setFormula2()</code></li>
47 *  <li><code> getSourcePosition()</code></li>
48 *  <li><code> setSourcePosition()</code></li>
49 * </ul> <p>
50 * @see com.sun.star.sheet.XSheetCondition
51 */
52 public class _XSheetCondition extends MultiMethodTest {
53     public XSheetCondition oObj = null;
54     public String Formula1 = null;
55     public String Formula2 = null;
56     public ConditionOperator Operator = null;
57     public CellAddress SourcePosition = null;
58 
59     /**
60     * Test calls the method, checks and stores returned value. <p>
61     * Has <b> OK </b> status if returned vakue isn't null. <p>
62     */
63     public void _getFormula1() {
64         Formula1 = oObj.getFormula1();
65         tRes.tested("getFormula1()", Formula1 != null);
66     }
67 
68     /**
69     * Test calls the method, checks and stores returned value. <p>
70     * Has <b> OK </b> status if returned vakue isn't null. <p>
71     */
72     public void _getFormula2() {
73         Formula2 = oObj.getFormula2();
74         tRes.tested("getFormula2()", Formula2 != null);
75     }
76 
77     /**
78     * Test calls the method, checks and stores returned value. <p>
79     * Has <b> OK </b> status if returned vakue isn't null. <p>
80     */
81     public void _getOperator() {
82         Operator = oObj.getOperator();
83         tRes.tested("getOperator()", Operator != null);
84     }
85 
86     /**
87     * Test calls the method, checks and stores returned value. <p>
88     * Has <b> OK </b> status if returned vakue isn't null. <p>
89     */
90     public void _getSourcePosition() {
91         SourcePosition = oObj.getSourcePosition();
92         tRes.tested("getSourcePosition()", SourcePosition != null);
93     }
94 
95     /**
96     * Test sets new value of formula1, gets formula1 again and compares
97     * returned value with value that was stored by method
98     * <code>getFormula1()</code>. <p>
99     * Has <b> OK </b> status if values aren't equal. <p>
100     * The following method tests are to be completed successfully before :
101     * <ul>
102     *  <li> <code> getFormula1() </code> : to have value of 'Formula1' </li>
103     * </ul>
104     */
105     public void _setFormula1() {
106         requiredMethod("getFormula1()");
107         oObj.setFormula1("$Sheet1.$C$" + Thread.activeCount());
108         tRes.tested("setFormula1()", !Formula1.equals( oObj.getFormula1() ) );
109     }
110 
111     /**
112     * Test sets new value of formula2, gets formula2 again and compares
113     * returned value with value that was stored by method
114     * <code>getFormula2()</code>. <p>
115     * Has <b> OK </b> status if values aren't equal. <p>
116     * The following method tests are to be completed successfully before :
117     * <ul>
118     *  <li> <code> getFormula2() </code> : to have value of 'Formula2' </li>
119     * </ul>
120     */
121     public void _setFormula2() {
122         requiredMethod("getFormula2()");
123         oObj.setFormula2("$Sheet1.$A$" + Thread.activeCount());
124         tRes.tested("setFormula2()", !Formula2.equals( oObj.getFormula2() ) );
125     }
126 
127     /**
128     * Test sets new value of operator, gets operator and compares
129     * returned value with value that was set. <p>
130     * Has <b> OK </b> status if values aren't equal. <p>
131     */
132     public void _setOperator() {
133         oObj.setOperator(ConditionOperator.BETWEEN);
134         tRes.tested("setOperator()", !Operator.equals( oObj.getOperator() ) );
135     }
136 
137     /**
138     * Test change value that was stored by method
139     * <code>getSourcePosition()</code>, sets this new value, gets source
140     * position again and compares returned value with value that was set. <p>
141     * Has <b> OK </b> status if values aren't equal. <p>
142     * The following method tests are to be completed successfully before :
143     * <ul>
144     *  <li> <code> getSourcePosition() </code> : to have value of source
145     *  position </li>
146     * </ul>
147     */
148     public void _setSourcePosition() {
149         requiredMethod("getSourcePosition()");
150         oObj.setSourcePosition(
151                     (CellAddress)ValueChanger.changePValue(SourcePosition));
152         tRes.tested(
153             "setSourcePosition()",
154             !SourcePosition.equals( oObj.getSourcePosition() ) );
155     }
156 
157 }  // finish class _XSheetCondition
158 
159