1 /*
2  * This file is part of the LibreOffice project.
3  *
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/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
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 .
17  */
18 
19 package ifc.awt;
20 
21 
22 import lib.MultiMethodTest;
23 
24 import com.sun.star.awt.XNumericField;
25 import util.utils;
26 
27 /**
28 * Testing <code>com.sun.star.awt.XNumericField</code>
29 * interface methods :
30 * <ul>
31 *  <li><code> setValue()</code></li>
32 *  <li><code> getValue()</code></li>
33 *  <li><code> setMin()</code></li>
34 *  <li><code> getMin()</code></li>
35 *  <li><code> setMax()</code></li>
36 *  <li><code> getMax()</code></li>
37 *  <li><code> setFirst()</code></li>
38 *  <li><code> getFirst()</code></li>
39 *  <li><code> setLast()</code></li>
40 *  <li><code> getLast()</code></li>
41 *  <li><code> setSpinSize()</code></li>
42 *  <li><code> getSpinSize()</code></li>
43 *  <li><code> setDecimalDigits()</code></li>
44 *  <li><code> getDecimalDigits()</code></li>
45 *  <li><code> setStrictFormat()</code></li>
46 *  <li><code> isStrictFormat()</code></li>
47 * </ul> <p>
48 * Test is <b> NOT </b> multithread compliant. <p>
49 * @see com.sun.star.awt.XNumericField
50 */
51 public class _XNumericField extends MultiMethodTest {
52 
53     public XNumericField oObj = null;
54     private double val = 0 ;
55     private double min = 0 ;
56     private double max = 0 ;
57     private double first = 0 ;
58     private double last = 0 ;
59     private double spin = 0 ;
60     private short digits = 0 ;
61     private boolean strict = true ;
62 
63     /**
64     * Sets value changed and then compares it to get value. <p>
65     * Has <b>OK</b> status if set and get values are equal.
66     * The following method tests are to be completed successfully before :
67     * <ul>
68     *  <li> <code> getValue </code>  </li>
69     * </ul>
70     */
_setValue()71     public void _setValue() {
72         requiredMethod("getValue()");
73 
74         double value = val + 1.1;
75         oObj.setValue(value) ;
76 
77         tRes.tested("setValue()", utils.approxEqual(oObj.getValue(), value));
78     }
79 
80     /**
81     * Just calls the method and stores value returned. <p>
82     * Has <b>OK</b> status if no runtime exceptions occurred.
83     */
_getValue()84     public void _getValue() {
85         val = oObj.getValue() ;
86 
87         tRes.tested("getValue()", true) ;
88     }
89 
90     /**
91     * Sets minimal value changed and then compares it to get value. <p>
92     * Has <b>OK</b> status if set and get values are equal.
93     * The following method tests are to be completed successfully before :
94     * <ul>
95     *  <li> <code> getMin </code>  </li>
96     * </ul>
97     */
_setMin()98     public void _setMin() {
99         requiredMethod("getMin()") ;
100 
101         double value = min + 1.1;
102         oObj.setMin(value);
103         double ret = oObj.getMin();
104         boolean result = utils.approxEqual(ret, value);
105 
106         tRes.tested("setMin()", result);
107     }
108 
109     /**
110     * Just calls the method and stores value returned. <p>
111     * Has <b>OK</b> status if no runtime exceptions occurred.
112     */
_getMin()113     public void _getMin() {
114 
115         boolean result = true ;
116         min = oObj.getMin() ;
117 
118         tRes.tested("getMin()", result) ;
119     }
120 
121     /**
122     * Sets maximal value changed and then compares it to get value. <p>
123     * Has <b>OK</b> status if set and get values are equal.
124     * The following method tests are to be completed successfully before :
125     * <ul>
126     *  <li> <code> getMax </code>  </li>
127     * </ul>
128     */
_setMax()129     public void _setMax() {
130         requiredMethod("getMax()") ;
131 
132         double value = max + 1.1;
133         oObj.setMax(value);
134         double ret = oObj.getMax();
135         boolean result = utils.approxEqual(ret, value);
136 
137         tRes.tested("setMax()", result) ;
138     }
139 
140     /**
141     * Just calls the method and stores value returned. <p>
142     * Has <b>OK</b> status if no runtime exceptions occurred.
143     */
_getMax()144     public void _getMax() {
145 
146         boolean result = true ;
147         max = oObj.getMax() ;
148 
149         tRes.tested("getMax()", result) ;
150     }
151 
152     /**
153     * Sets value changed and then compares it to get value. <p>
154     * Has <b>OK</b> status if set and get values are equal.
155     * The following method tests are to be completed successfully before :
156     * <ul>
157     *  <li> <code> getFirst </code>  </li>
158     * </ul>
159     */
_setFirst()160     public void _setFirst() {
161         requiredMethod("getFirst()") ;
162 
163         double value = first + 1.1;
164         oObj.setFirst(value);
165         double ret = oObj.getFirst();
166         boolean result = utils.approxEqual(ret, value);
167 
168         tRes.tested("setFirst()", result) ;
169     }
170 
171     /**
172     * Just calls the method and stores value returned. <p>
173     * Has <b>OK</b> status if no runtime exceptions occurred.
174     */
_getFirst()175     public void _getFirst() {
176 
177         boolean result = true ;
178         first = oObj.getFirst() ;
179 
180         tRes.tested("getFirst()", result) ;
181     }
182 
183     /**
184     * Sets value changed and then compares it to get value. <p>
185     * Has <b>OK</b> status if set and get values are equal.
186     * The following method tests are to be completed successfully before :
187     * <ul>
188     *  <li> <code> getLast </code>  </li>
189     * </ul>
190     */
_setLast()191     public void _setLast() {
192         requiredMethod("getLast()") ;
193 
194         double value = last + 1.1;
195         oObj.setLast(value);
196         double ret = oObj.getLast();
197         boolean result = utils.approxEqual(ret, value);
198 
199         tRes.tested("setLast()", result) ;
200     }
201 
202     /**
203     * Just calls the method and stores value returned. <p>
204     * Has <b>OK</b> status if no runtime exceptions occurred.
205     */
_getLast()206     public void _getLast() {
207 
208         boolean result = true ;
209         last = oObj.getLast() ;
210 
211         tRes.tested("getLast()", result) ;
212     }
213 
214     /**
215     * Sets value changed and then compares it to get value. <p>
216     * Has <b>OK</b> status if set and get values are equal.
217     * The following method tests are to be completed successfully before :
218     * <ul>
219     *  <li> <code> getSpinSize </code>  </li>
220     * </ul>
221     */
_setSpinSize()222     public void _setSpinSize() {
223         requiredMethod("getSpinSize()") ;
224 
225         boolean result = true ;
226         double value = spin + 1.1;
227         oObj.setSpinSize(value) ;
228         result = utils.approxEqual(oObj.getSpinSize(), value);
229 
230         tRes.tested("setSpinSize()", result) ;
231     }
232 
233     /**
234     * Just calls the method and stores value returned. <p>
235     * Has <b>OK</b> status if no runtime exceptions occurred.
236     */
_getSpinSize()237     public void _getSpinSize() {
238 
239         boolean result = true ;
240         spin = oObj.getSpinSize() ;
241 
242         tRes.tested("getSpinSize()", result) ;
243     }
244 
245     /**
246     * Sets value changed and then compares it to get value. <p>
247     * Has <b>OK</b> status if set and get values are equal.
248     * The following method tests are to be completed successfully before :
249     * <ul>
250     *  <li> <code> getDecimalDigits </code>  </li>
251     * </ul>
252     */
_setDecimalDigits()253     public void _setDecimalDigits() {
254         requiredMethod("getDecimalDigits()") ;
255 
256         boolean result = true ;
257         oObj.setDecimalDigits((short)(digits + 1)) ;
258 
259         short res = oObj.getDecimalDigits() ;
260         result = res == (digits + 1) ;
261 
262         tRes.tested("setDecimalDigits()", result) ;
263     }
264 
265     /**
266     * Just calls the method and stores value returned. <p>
267     * Has <b>OK</b> status if no runtime exceptions occurred.
268     */
_getDecimalDigits()269     public void _getDecimalDigits() {
270 
271         boolean result = true ;
272         digits = oObj.getDecimalDigits() ;
273 
274         tRes.tested("getDecimalDigits()", result) ;
275     }
276 
277     /**
278     * Sets value changed and then compares it to get value. <p>
279     * Has <b>OK</b> status if set and get values are equal.
280     * The following method tests are to be completed successfully before :
281     * <ul>
282     *  <li> <code> isStrictFormat </code>  </li>
283     * </ul>
284     */
_setStrictFormat()285     public void _setStrictFormat() {
286         requiredMethod("isStrictFormat()") ;
287 
288         boolean result = true ;
289         oObj.setStrictFormat(!strict) ;
290         result = oObj.isStrictFormat() == !strict ;
291 
292         tRes.tested("setStrictFormat()", result) ;
293     }
294 
295     /**
296     * Just calls the method and stores value returned. <p>
297     * Has <b>OK</b> status if no runtime exceptions occurred.
298     */
_isStrictFormat()299     public void _isStrictFormat() {
300 
301         boolean result = true ;
302         strict = oObj.isStrictFormat() ;
303 
304         tRes.tested("isStrictFormat()", result) ;
305     }
306 }
307 
308 
309