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
.XDateField
;
25 import com
.sun
.star
.util
.Date
;
28 * Testing <code>com.sun.star.awt.XDateField</code>
31 * <li><code> setDate()</code></li>
32 * <li><code> getDate()</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> setLongFormat()</code></li>
42 * <li><code> isLongFormat()</code></li>
43 * <li><code> setEmpty()</code></li>
44 * <li><code> isEmpty()</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.XDateField
51 public class _XDateField
extends MultiMethodTest
{
53 public XDateField oObj
= null;
55 private boolean strict
= false ;
56 private boolean longFormat
= false ;
59 * Sets a new value and checks if it was correctly set. <p>
60 * Has <b> OK </b> status if set and get values are equal.
61 * The following method tests are to be completed successfully before :
63 * <li> <code> getTime </code> </li>
66 public void _setDate() {
67 requiredMethod("getDate()") ;
69 boolean result
= true ;
70 oObj
.setDate(new Date((short)1, (short)1, (short)1900)) ;
71 Date date
= oObj
.getDate();
72 result
= date
.Day
== 1 && date
.Month
== 1 && date
.Year
== 1900;
75 System
.out
.println("getDate: " + oObj
.getDate() + " , expected 1900-01-01");
78 tRes
.tested("setDate()", result
) ;
82 * Gets the current value. <p>
83 * Has <b> OK </b> status if no runtime exceptions occurred
85 public void _getDate() {
87 boolean result
= true ;
90 tRes
.tested("getDate()", result
) ;
94 * Sets a new value and checks if it was correctly set. <p>
95 * Has <b> OK </b> status if set and get values are equal.
96 * The following method tests are to be completed successfully before :
98 * <li> <code> getMin </code> </li>
101 public void _setMin() {
103 boolean result
= true ;
104 oObj
.setMin(new Date((short)5, (short)2, (short)1963));
105 Date date
= oObj
.getMin();
106 result
= date
.Day
== 5 && date
.Month
== 2 && date
.Year
== 1963;
108 tRes
.tested("setMin()", result
) ;
112 * Gets the current value. <p>
113 * Has <b> OK </b> status if no runtime exceptions occurred
115 public void _getMin() {
117 boolean result
= true ;
120 tRes
.tested("getMin()", result
) ;
124 * Sets a new value and checks if it was correctly set. <p>
125 * Has <b> OK </b> status if set and get values are equal.
126 * The following method tests are to be completed successfully before :
128 * <li> <code> getMax </code> </li>
131 public void _setMax() {
133 boolean result
= true ;
134 oObj
.setMax(new Date((short)18, (short)9, (short)2117)) ;
135 Date date
= oObj
.getMax();
136 result
= date
.Day
== 18 && date
.Month
== 9 && date
.Year
== 2117;
138 tRes
.tested("setMax()", result
) ;
142 * Gets the current value. <p>
143 * Has <b> OK </b> status if no runtime exceptions occurred
145 public void _getMax() {
147 boolean result
= true ;
150 tRes
.tested("getMax()", result
) ;
154 * Sets a new value and checks if it was correctly set. <p>
155 * Has <b> OK </b> status if set and get values are equal.
156 * The following method tests are to be completed successfully before :
158 * <li> <code> getFirst </code> </li>
161 public void _setFirst() {
163 boolean result
= true ;
164 oObj
.setFirst(new Date((short)7, (short)12, (short)1972)) ;
165 Date date
= oObj
.getFirst();
166 result
= date
.Day
== 7 && date
.Month
== 12 && date
.Year
== 1972;
169 log
.println("Set to " + 5118 + " but returned " + oObj
.getFirst()) ;
172 tRes
.tested("setFirst()", result
) ;
176 * Gets the current value. <p>
177 * Has <b> OK </b> status if no runtime exceptions occurred
179 public void _getFirst() {
181 boolean result
= true ;
182 com
.sun
.star
.util
.Date val
= oObj
.getFirst() ;
184 log
.println("getFirst() = " + val
) ;
186 tRes
.tested("getFirst()", result
) ;
190 * Sets a new value and checks if it was correctly set. <p>
191 * Has <b> OK </b> status if set and get values are equal.
192 * The following method tests are to be completed successfully before :
194 * <li> <code> getLast </code> </li>
197 public void _setLast() {
199 boolean result
= true ;
200 oObj
.setLast(new Date((short)23, (short)8, (short)2053)) ;
201 Date date
= oObj
.getLast();
202 result
= date
.Day
== 23 && date
.Month
== 8 && date
.Year
== 2053;
205 log
.println("Set to 2053-08-23 but returned " + oObj
.getLast()) ;
208 tRes
.tested("setLast()", result
) ;
212 * Gets the current value. <p>
213 * Has <b> OK </b> status if no runtime exceptions occurred
215 public void _getLast() {
217 boolean result
= true ;
218 com
.sun
.star
.util
.Date val
= oObj
.getLast() ;
220 log
.println("getLast() = " + val
) ;
222 tRes
.tested("getLast()", result
) ;
226 * Sets the value to empty. <p>
227 * Has <b> OK </b> status if no runtime exceptions occurred
228 * The following method tests are to be completed successfully before :
230 * <li> <code> setTime </code> : value must be not empty </li>
233 public void _setEmpty() {
234 requiredMethod("setDate()") ;
236 boolean result
= true ;
239 tRes
.tested("setEmpty()", result
) ;
243 * Checks if the field is empty. <p>
244 * Has <b> OK </b> status if the value is empty.<p>
245 * The following method tests are to be completed successfully before :
247 * <li> <code> setEmpty() </code> </li>
250 public void _isEmpty() {
251 requiredMethod("setEmpty()") ;
253 boolean result
= true ;
254 result
= oObj
.isEmpty() ;
256 tRes
.tested("isEmpty()", result
) ;
260 * Checks strict state. <p>
261 * Has <b> OK </b> status if strict format is properly set.
262 * The following method tests are to be completed successfully before :
264 * <li> <code> isStrictFormat </code> </li>
267 public void _setStrictFormat() {
268 requiredMethod("isStrictFormat()") ;
270 boolean result
= true ;
271 oObj
.setStrictFormat(!strict
) ;
273 result
= oObj
.isStrictFormat() == !strict
;
276 log
.println("Was '" + strict
+ "', set to '" + !strict
+
277 "' but returned '" + oObj
.isStrictFormat() + "'") ;
280 tRes
.tested("setStrictFormat()", result
) ;
284 * Gets strict state and stores it. <p>
285 * Has <b> OK </b> status if no runtime exceptions occurred.
287 public void _isStrictFormat() {
289 boolean result
= true ;
290 strict
= oObj
.isStrictFormat() ;
292 tRes
.tested("isStrictFormat()", result
) ;
297 * Checks long format state. <p>
298 * Has <b> OK </b> status if long format is properly set.
299 * The following method tests are to be completed successfully before :
301 * <li> <code> isLongFormat </code> </li>
304 public void _setLongFormat() {
306 boolean result
= true ;
307 oObj
.setLongFormat(!longFormat
) ;
309 result
= oObj
.isLongFormat() == !longFormat
;
312 log
.println("Was '" + longFormat
+ "', set to '" + !longFormat
+
313 "' but returned '" + oObj
.isLongFormat() + "'") ;
316 tRes
.tested("setLongFormat()", result
) ;
320 * Gets long format state and stores it. <p>
321 * Has <b> OK </b> status if no runtime exceptions occurred.
323 public void _isLongFormat() {
325 boolean result
= true ;
326 longFormat
= oObj
.isLongFormat() ;
328 tRes
.tested("isLongFormat()", result
) ;