1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDateField.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 import lib
.MultiMethodTest
;
36 import com
.sun
.star
.awt
.XDateField
;
39 * Testing <code>com.sun.star.awt.XDateField</code>
42 * <li><code> setDate()</code></li>
43 * <li><code> getDate()</code></li>
44 * <li><code> setMin()</code></li>
45 * <li><code> getMin()</code></li>
46 * <li><code> setMax()</code></li>
47 * <li><code> getMax()</code></li>
48 * <li><code> setFirst()</code></li>
49 * <li><code> getFirst()</code></li>
50 * <li><code> setLast()</code></li>
51 * <li><code> getLast()</code></li>
52 * <li><code> setLongFormat()</code></li>
53 * <li><code> isLongFormat()</code></li>
54 * <li><code> setEmpty()</code></li>
55 * <li><code> isEmpty()</code></li>
56 * <li><code> setStrictFormat()</code></li>
57 * <li><code> isStrictFormat()</code></li>
59 * Test is <b> NOT </b> multithread compilant. <p>
60 * @see com.sun.star.awt.XDateField
62 public class _XDateField
extends MultiMethodTest
{
64 public XDateField oObj
= null;
66 private boolean strict
= false ;
67 private boolean longFormat
= false ;
70 * Sets a new value and checks if it was correctly set. <p>
71 * Has <b> OK </b> status if set and get values are equal.
72 * The following method tests are to be completed successfully before :
74 * <li> <code> getTime </code> </li>
77 public void _setDate() {
78 requiredMethod("getDate()") ;
80 boolean result
= true ;
81 oObj
.setDate(19000101) ;
83 result
= oObj
.getDate() == 19000101 ;
86 System
.out
.println("getDate: "+oObj
.getDate()+" , expected 19000101");
89 tRes
.tested("setDate()", result
) ;
93 * Gets the current value. <p>
94 * Has <b> OK </b> status if no runtime exceptions occured
96 public void _getDate() {
98 boolean result
= true ;
101 tRes
.tested("getDate()", result
) ;
105 * Sets a new value and checks if it was correctly set. <p>
106 * Has <b> OK </b> status if set and get values are equal.
107 * The following method tests are to be completed successfully before :
109 * <li> <code> getMin </code> </li>
112 public void _setMin() {
114 boolean result
= true ;
117 result
= oObj
.getMin() == 4978 ;
119 tRes
.tested("setMin()", result
) ;
123 * Gets the current value. <p>
124 * Has <b> OK </b> status if no runtime exceptions occured
126 public void _getMin() {
128 boolean result
= true ;
131 tRes
.tested("getMin()", result
) ;
135 * Sets a new value and checks if it was correctly set. <p>
136 * Has <b> OK </b> status if set and get values are equal.
137 * The following method tests are to be completed successfully before :
139 * <li> <code> getMax </code> </li>
142 public void _setMax() {
144 boolean result
= true ;
147 result
= oObj
.getMax() == 27856 ;
149 tRes
.tested("setMax()", result
) ;
153 * Gets the current value. <p>
154 * Has <b> OK </b> status if no runtime exceptions occured
156 public void _getMax() {
158 boolean result
= true ;
161 tRes
.tested("getMax()", result
) ;
165 * Sets a new value and checks if it was correctly set. <p>
166 * Has <b> OK </b> status if set and get values are equal.
167 * The following method tests are to be completed successfully before :
169 * <li> <code> getFirst </code> </li>
172 public void _setFirst() {
174 boolean result
= true ;
175 oObj
.setFirst(5118) ;
177 result
= oObj
.getFirst() == 5118 ;
180 log
.println("Set to " + 5118 + " but returned " + oObj
.getFirst()) ;
183 tRes
.tested("setFirst()", result
) ;
187 * Gets the current value. <p>
188 * Has <b> OK </b> status if no runtime exceptions occured
190 public void _getFirst() {
192 boolean result
= true ;
193 int val
= oObj
.getFirst() ;
195 log
.println("getFirst() = " + val
) ;
197 tRes
.tested("getFirst()", result
) ;
201 * Sets a new value and checks if it was correctly set. <p>
202 * Has <b> OK </b> status if set and get values are equal.
203 * The following method tests are to be completed successfully before :
205 * <li> <code> getLast </code> </li>
208 public void _setLast() {
210 boolean result
= true ;
211 oObj
.setLast(23450) ;
213 result
= oObj
.getLast() == 23450 ;
216 log
.println("Set to " + 23450 + " but returned " + oObj
.getLast()) ;
219 tRes
.tested("setLast()", result
) ;
223 * Gets the current value. <p>
224 * Has <b> OK </b> status if no runtime exceptions occured
226 public void _getLast() {
228 boolean result
= true ;
229 int val
= oObj
.getLast() ;
231 log
.println("getLast() = " + val
) ;
233 tRes
.tested("getLast()", result
) ;
237 * Sets the value to empty. <p>
238 * Has <b> OK </b> status if no runtime exceptions occured
239 * The following method tests are to be completed successfully before :
241 * <li> <code> setTime </code> : value must be not empty </li>
244 public void _setEmpty() {
245 requiredMethod("setDate()") ;
247 boolean result
= true ;
250 tRes
.tested("setEmpty()", result
) ;
254 * Checks if the field is empty. <p>
255 * Has <b> OK </b> status if the value is empty.<p>
256 * The following method tests are to be completed successfully before :
258 * <li> <code> setEmpty() </code> </li>
261 public void _isEmpty() {
262 requiredMethod("setEmpty()") ;
264 boolean result
= true ;
265 result
= oObj
.isEmpty() ;
267 tRes
.tested("isEmpty()", result
) ;
271 * Checks strict state. <p>
272 * Has <b> OK </b> status if strict format is properly set.
273 * The following method tests are to be completed successfully before :
275 * <li> <code> isStrictFormat </code> </li>
278 public void _setStrictFormat() {
279 requiredMethod("isStrictFormat()") ;
281 boolean result
= true ;
282 oObj
.setStrictFormat(!strict
) ;
284 result
= oObj
.isStrictFormat() == !strict
;
287 log
.println("Was '" + strict
+ "', set to '" + !strict
+
288 "' but returned '" + oObj
.isStrictFormat() + "'") ;
291 tRes
.tested("setStrictFormat()", result
) ;
295 * Gets strict state and stores it. <p>
296 * Has <b> OK </b> status if no runtime exceptions occured.
298 public void _isStrictFormat() {
300 boolean result
= true ;
301 strict
= oObj
.isStrictFormat() ;
303 tRes
.tested("isStrictFormat()", result
) ;
308 * Checks long format state. <p>
309 * Has <b> OK </b> status if long format is properly set.
310 * The following method tests are to be completed successfully before :
312 * <li> <code> isLongFormat </code> </li>
315 public void _setLongFormat() {
317 boolean result
= true ;
318 oObj
.setLongFormat(!longFormat
) ;
320 result
= oObj
.isLongFormat() == !longFormat
;
323 log
.println("Was '" + longFormat
+ "', set to '" + !longFormat
+
324 "' but returned '" + oObj
.isLongFormat() + "'") ;
327 tRes
.tested("setLongFormat()", result
) ;
331 * Gets long format state and stores it. <p>
332 * Has <b> OK </b> status if no runtime exceptions occured.
334 public void _isLongFormat() {
336 boolean result
= true ;
337 longFormat
= oObj
.isLongFormat() ;
339 tRes
.tested("isLongFormat()", result
) ;