bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XDateField.java
blobc70d34ab161e2fb753e696a47d64ae1ab2750ce7
1 /*
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 .
19 package ifc.awt;
22 import lib.MultiMethodTest;
24 import com.sun.star.awt.XDateField;
25 import com.sun.star.util.Date;
27 /**
28 * Testing <code>com.sun.star.awt.XDateField</code>
29 * interface methods :
30 * <ul>
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>
47 * </ul> <p>
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 ;
58 /**
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 :
62 * <ul>
63 * <li> <code> getTime </code> </li>
64 * </ul>
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;
74 if (! result ) {
75 System.out.println("getDate: " + oObj.getDate() + " , expected 1900-01-01");
78 tRes.tested("setDate()", result) ;
81 /**
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 ;
88 oObj.getDate() ;
90 tRes.tested("getDate()", result) ;
93 /**
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 :
97 * <ul>
98 * <li> <code> getMin </code> </li>
99 * </ul>
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 ;
118 oObj.getMin() ;
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 :
127 * <ul>
128 * <li> <code> getMax </code> </li>
129 * </ul>
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 ;
148 oObj.getMax() ;
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 :
157 * <ul>
158 * <li> <code> getFirst </code> </li>
159 * </ul>
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;
168 if (!result) {
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 :
193 * <ul>
194 * <li> <code> getLast </code> </li>
195 * </ul>
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;
204 if (!result) {
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 :
229 * <ul>
230 * <li> <code> setTime </code> : value must be not empty </li>
231 * </ul>
233 public void _setEmpty() {
234 requiredMethod("setDate()") ;
236 boolean result = true ;
237 oObj.setEmpty() ;
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 :
246 * <ul>
247 * <li> <code> setEmpty() </code> </li>
248 * </ul>
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 :
263 * <ul>
264 * <li> <code> isStrictFormat </code> </li>
265 * </ul>
267 public void _setStrictFormat() {
268 requiredMethod("isStrictFormat()") ;
270 boolean result = true ;
271 oObj.setStrictFormat(!strict) ;
273 result = oObj.isStrictFormat() == !strict ;
275 if (!result) {
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 :
300 * <ul>
301 * <li> <code> isLongFormat </code> </li>
302 * </ul>
304 public void _setLongFormat() {
306 boolean result = true ;
307 oObj.setLongFormat(!longFormat) ;
309 result = oObj.isLongFormat() == !longFormat ;
311 if (!result) {
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) ;