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