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 .
22 import lib
.MultiMethodTest
;
24 import com
.sun
.star
.awt
.XNumericField
;
28 * Testing <code>com.sun.star.awt.XNumericField</code>
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>
48 * Test is <b> NOT </b> multithread compliant. <p>
49 * @see com.sun.star.awt.XNumericField
51 public class _XNumericField
extends MultiMethodTest
{
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 ;
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 :
68 * <li> <code> getValue </code> </li>
71 public void _setValue() {
72 requiredMethod("getValue()");
74 double value
= val
+ 1.1;
75 oObj
.setValue(value
) ;
77 tRes
.tested("setValue()", utils
.approxEqual(oObj
.getValue(), value
));
81 * Just calls the method and stores value returned. <p>
82 * Has <b>OK</b> status if no runtime exceptions occurred.
84 public void _getValue() {
85 val
= oObj
.getValue() ;
87 tRes
.tested("getValue()", true) ;
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 :
95 * <li> <code> getMin </code> </li>
98 public void _setMin() {
99 requiredMethod("getMin()") ;
101 double value
= min
+ 1.1;
103 double ret
= oObj
.getMin();
104 boolean result
= utils
.approxEqual(ret
, value
);
106 tRes
.tested("setMin()", result
);
110 * Just calls the method and stores value returned. <p>
111 * Has <b>OK</b> status if no runtime exceptions occurred.
113 public void _getMin() {
115 boolean result
= true ;
116 min
= oObj
.getMin() ;
118 tRes
.tested("getMin()", result
) ;
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 :
126 * <li> <code> getMax </code> </li>
129 public void _setMax() {
130 requiredMethod("getMax()") ;
132 double value
= max
+ 1.1;
134 double ret
= oObj
.getMax();
135 boolean result
= utils
.approxEqual(ret
, value
);
137 tRes
.tested("setMax()", result
) ;
141 * Just calls the method and stores value returned. <p>
142 * Has <b>OK</b> status if no runtime exceptions occurred.
144 public void _getMax() {
146 boolean result
= true ;
147 max
= oObj
.getMax() ;
149 tRes
.tested("getMax()", result
) ;
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 :
157 * <li> <code> getFirst </code> </li>
160 public void _setFirst() {
161 requiredMethod("getFirst()") ;
163 double value
= first
+ 1.1;
164 oObj
.setFirst(value
);
165 double ret
= oObj
.getFirst();
166 boolean result
= utils
.approxEqual(ret
, value
);
168 tRes
.tested("setFirst()", result
) ;
172 * Just calls the method and stores value returned. <p>
173 * Has <b>OK</b> status if no runtime exceptions occurred.
175 public void _getFirst() {
177 boolean result
= true ;
178 first
= oObj
.getFirst() ;
180 tRes
.tested("getFirst()", result
) ;
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 :
188 * <li> <code> getLast </code> </li>
191 public void _setLast() {
192 requiredMethod("getLast()") ;
194 double value
= last
+ 1.1;
196 double ret
= oObj
.getLast();
197 boolean result
= utils
.approxEqual(ret
, value
);
199 tRes
.tested("setLast()", result
) ;
203 * Just calls the method and stores value returned. <p>
204 * Has <b>OK</b> status if no runtime exceptions occurred.
206 public void _getLast() {
208 boolean result
= true ;
209 last
= oObj
.getLast() ;
211 tRes
.tested("getLast()", result
) ;
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 :
219 * <li> <code> getSpinSize </code> </li>
222 public void _setSpinSize() {
223 requiredMethod("getSpinSize()") ;
225 boolean result
= true ;
226 double value
= spin
+ 1.1;
227 oObj
.setSpinSize(value
) ;
228 result
= utils
.approxEqual(oObj
.getSpinSize(), value
);
230 tRes
.tested("setSpinSize()", result
) ;
234 * Just calls the method and stores value returned. <p>
235 * Has <b>OK</b> status if no runtime exceptions occurred.
237 public void _getSpinSize() {
239 boolean result
= true ;
240 spin
= oObj
.getSpinSize() ;
242 tRes
.tested("getSpinSize()", result
) ;
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 :
250 * <li> <code> getDecimalDigits </code> </li>
253 public void _setDecimalDigits() {
254 requiredMethod("getDecimalDigits()") ;
256 boolean result
= true ;
257 oObj
.setDecimalDigits((short)(digits
+ 1)) ;
259 short res
= oObj
.getDecimalDigits() ;
260 result
= res
== (digits
+ 1) ;
262 tRes
.tested("setDecimalDigits()", result
) ;
266 * Just calls the method and stores value returned. <p>
267 * Has <b>OK</b> status if no runtime exceptions occurred.
269 public void _getDecimalDigits() {
271 boolean result
= true ;
272 digits
= oObj
.getDecimalDigits() ;
274 tRes
.tested("getDecimalDigits()", result
) ;
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 :
282 * <li> <code> isStrictFormat </code> </li>
285 public void _setStrictFormat() {
286 requiredMethod("isStrictFormat()") ;
288 boolean result
= true ;
289 oObj
.setStrictFormat(!strict
) ;
290 result
= oObj
.isStrictFormat() == !strict
;
292 tRes
.tested("setStrictFormat()", result
) ;
296 * Just calls the method and stores value returned. <p>
297 * Has <b>OK</b> status if no runtime exceptions occurred.
299 public void _isStrictFormat() {
301 boolean result
= true ;
302 strict
= oObj
.isStrictFormat() ;
304 tRes
.tested("isStrictFormat()", result
) ;