xref: /AOO41X/main/qadevOOo/tests/java/ifc/awt/_XDateField.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package ifc.awt;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir import lib.MultiMethodTest;
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir import com.sun.star.awt.XDateField;
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir /**
36*cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XDateField</code>
37*cdf0e10cSrcweir * interface methods :
38*cdf0e10cSrcweir * <ul>
39*cdf0e10cSrcweir *  <li><code> setDate()</code></li>
40*cdf0e10cSrcweir *  <li><code> getDate()</code></li>
41*cdf0e10cSrcweir *  <li><code> setMin()</code></li>
42*cdf0e10cSrcweir *  <li><code> getMin()</code></li>
43*cdf0e10cSrcweir *  <li><code> setMax()</code></li>
44*cdf0e10cSrcweir *  <li><code> getMax()</code></li>
45*cdf0e10cSrcweir *  <li><code> setFirst()</code></li>
46*cdf0e10cSrcweir *  <li><code> getFirst()</code></li>
47*cdf0e10cSrcweir *  <li><code> setLast()</code></li>
48*cdf0e10cSrcweir *  <li><code> getLast()</code></li>
49*cdf0e10cSrcweir *  <li><code> setLongFormat()</code></li>
50*cdf0e10cSrcweir *  <li><code> isLongFormat()</code></li>
51*cdf0e10cSrcweir *  <li><code> setEmpty()</code></li>
52*cdf0e10cSrcweir *  <li><code> isEmpty()</code></li>
53*cdf0e10cSrcweir *  <li><code> setStrictFormat()</code></li>
54*cdf0e10cSrcweir *  <li><code> isStrictFormat()</code></li>
55*cdf0e10cSrcweir * </ul> <p>
56*cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
57*cdf0e10cSrcweir * @see com.sun.star.awt.XDateField
58*cdf0e10cSrcweir */
59*cdf0e10cSrcweir public class _XDateField extends MultiMethodTest {
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     public XDateField oObj = null;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     private boolean strict = false ;
64*cdf0e10cSrcweir     private boolean longFormat = false ;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     /**
67*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
68*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
69*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
70*cdf0e10cSrcweir     * <ul>
71*cdf0e10cSrcweir     *  <li> <code> getTime </code> </li>
72*cdf0e10cSrcweir     * </ul>
73*cdf0e10cSrcweir     */
74*cdf0e10cSrcweir     public void _setDate() {
75*cdf0e10cSrcweir         requiredMethod("getDate()") ;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir         boolean result = true ;
78*cdf0e10cSrcweir         oObj.setDate(19000101) ;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         result = oObj.getDate() == 19000101 ;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir         if (! result ) {
83*cdf0e10cSrcweir             System.out.println("getDate: "+oObj.getDate()+" , expected 19000101");
84*cdf0e10cSrcweir         }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir         tRes.tested("setDate()", result) ;
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     /**
90*cdf0e10cSrcweir     * Gets the current value. <p>
91*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
92*cdf0e10cSrcweir     */
93*cdf0e10cSrcweir     public void _getDate() {
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         boolean result = true ;
96*cdf0e10cSrcweir         oObj.getDate() ;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         tRes.tested("getDate()", result) ;
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     /**
102*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
103*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
104*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
105*cdf0e10cSrcweir     * <ul>
106*cdf0e10cSrcweir     *  <li> <code> getMin </code> </li>
107*cdf0e10cSrcweir     * </ul>
108*cdf0e10cSrcweir     */
109*cdf0e10cSrcweir     public void _setMin() {
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         boolean result = true ;
112*cdf0e10cSrcweir         oObj.setMin(4978) ;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         result = oObj.getMin() == 4978 ;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         tRes.tested("setMin()", result) ;
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     /**
120*cdf0e10cSrcweir     * Gets the current value. <p>
121*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
122*cdf0e10cSrcweir     */
123*cdf0e10cSrcweir     public void _getMin() {
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         boolean result = true ;
126*cdf0e10cSrcweir         oObj.getMin() ;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         tRes.tested("getMin()", result) ;
129*cdf0e10cSrcweir     }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     /**
132*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
133*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
134*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
135*cdf0e10cSrcweir     * <ul>
136*cdf0e10cSrcweir     *  <li> <code> getMax </code> </li>
137*cdf0e10cSrcweir     * </ul>
138*cdf0e10cSrcweir     */
139*cdf0e10cSrcweir     public void _setMax() {
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         boolean result = true ;
142*cdf0e10cSrcweir         oObj.setMax(27856) ;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         result = oObj.getMax() == 27856 ;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir         tRes.tested("setMax()", result) ;
147*cdf0e10cSrcweir     }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     /**
150*cdf0e10cSrcweir     * Gets the current value. <p>
151*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
152*cdf0e10cSrcweir     */
153*cdf0e10cSrcweir     public void _getMax() {
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir         boolean result = true ;
156*cdf0e10cSrcweir         oObj.getMax() ;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         tRes.tested("getMax()", result) ;
159*cdf0e10cSrcweir     }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     /**
162*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
163*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
164*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
165*cdf0e10cSrcweir     * <ul>
166*cdf0e10cSrcweir     *  <li> <code> getFirst </code> </li>
167*cdf0e10cSrcweir     * </ul>
168*cdf0e10cSrcweir     */
169*cdf0e10cSrcweir     public void _setFirst() {
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         boolean result = true ;
172*cdf0e10cSrcweir         oObj.setFirst(5118) ;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir         result = oObj.getFirst() == 5118 ;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         if (!result) {
177*cdf0e10cSrcweir             log.println("Set to " + 5118 + " but returned " + oObj.getFirst()) ;
178*cdf0e10cSrcweir         }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         tRes.tested("setFirst()", result) ;
181*cdf0e10cSrcweir     }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     /**
184*cdf0e10cSrcweir     * Gets the current value. <p>
185*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
186*cdf0e10cSrcweir     */
187*cdf0e10cSrcweir     public void _getFirst() {
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         boolean result = true ;
190*cdf0e10cSrcweir         int val = oObj.getFirst() ;
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir         log.println("getFirst() = " + val) ;
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir         tRes.tested("getFirst()", result) ;
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     /**
198*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
199*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
200*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
201*cdf0e10cSrcweir     * <ul>
202*cdf0e10cSrcweir     *  <li> <code> getLast </code> </li>
203*cdf0e10cSrcweir     * </ul>
204*cdf0e10cSrcweir     */
205*cdf0e10cSrcweir     public void _setLast() {
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         boolean result = true ;
208*cdf0e10cSrcweir         oObj.setLast(23450) ;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir         result = oObj.getLast() == 23450 ;
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         if (!result) {
213*cdf0e10cSrcweir             log.println("Set to " + 23450 + " but returned " + oObj.getLast()) ;
214*cdf0e10cSrcweir         }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir         tRes.tested("setLast()", result) ;
217*cdf0e10cSrcweir     }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     /**
220*cdf0e10cSrcweir     * Gets the current value. <p>
221*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
222*cdf0e10cSrcweir     */
223*cdf0e10cSrcweir     public void _getLast() {
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir         boolean result = true ;
226*cdf0e10cSrcweir         int val = oObj.getLast() ;
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir         log.println("getLast() = " + val) ;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         tRes.tested("getLast()", result) ;
231*cdf0e10cSrcweir     }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     /**
234*cdf0e10cSrcweir     * Sets the value to empty. <p>
235*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
236*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
237*cdf0e10cSrcweir     * <ul>
238*cdf0e10cSrcweir     *  <li> <code> setTime </code> : value must be not empty </li>
239*cdf0e10cSrcweir     * </ul>
240*cdf0e10cSrcweir     */
241*cdf0e10cSrcweir     public void _setEmpty() {
242*cdf0e10cSrcweir         requiredMethod("setDate()") ;
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         boolean result = true ;
245*cdf0e10cSrcweir         oObj.setEmpty() ;
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir         tRes.tested("setEmpty()", result) ;
248*cdf0e10cSrcweir     }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     /**
251*cdf0e10cSrcweir     * Checks if the field is empty. <p>
252*cdf0e10cSrcweir     * Has <b> OK </b> status if the value is empty.<p>
253*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
254*cdf0e10cSrcweir     * <ul>
255*cdf0e10cSrcweir     *  <li> <code> setEmpty() </code>  </li>
256*cdf0e10cSrcweir     * </ul>
257*cdf0e10cSrcweir     */
258*cdf0e10cSrcweir     public void _isEmpty() {
259*cdf0e10cSrcweir         requiredMethod("setEmpty()") ;
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         boolean result = true ;
262*cdf0e10cSrcweir         result = oObj.isEmpty() ;
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         tRes.tested("isEmpty()", result) ;
265*cdf0e10cSrcweir     }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     /**
268*cdf0e10cSrcweir     * Checks strict state. <p>
269*cdf0e10cSrcweir     * Has <b> OK </b> status if strict format is properly set.
270*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
271*cdf0e10cSrcweir     * <ul>
272*cdf0e10cSrcweir     *  <li> <code> isStrictFormat </code> </li>
273*cdf0e10cSrcweir     * </ul>
274*cdf0e10cSrcweir     */
275*cdf0e10cSrcweir     public void _setStrictFormat() {
276*cdf0e10cSrcweir         requiredMethod("isStrictFormat()") ;
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir         boolean result = true ;
279*cdf0e10cSrcweir         oObj.setStrictFormat(!strict) ;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir         result = oObj.isStrictFormat() == !strict ;
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir         if (!result) {
284*cdf0e10cSrcweir             log.println("Was '" + strict + "', set to '" + !strict +
285*cdf0e10cSrcweir                 "' but returned '" + oObj.isStrictFormat() + "'") ;
286*cdf0e10cSrcweir         }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir         tRes.tested("setStrictFormat()", result) ;
289*cdf0e10cSrcweir     }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     /**
292*cdf0e10cSrcweir     * Gets strict state and stores it. <p>
293*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured.
294*cdf0e10cSrcweir     */
295*cdf0e10cSrcweir     public void _isStrictFormat() {
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         boolean result = true ;
298*cdf0e10cSrcweir         strict = oObj.isStrictFormat() ;
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir         tRes.tested("isStrictFormat()", result) ;
301*cdf0e10cSrcweir     }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     /**
305*cdf0e10cSrcweir     * Checks long format state. <p>
306*cdf0e10cSrcweir     * Has <b> OK </b> status if long format is properly set.
307*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
308*cdf0e10cSrcweir     * <ul>
309*cdf0e10cSrcweir     *  <li> <code> isLongFormat </code> </li>
310*cdf0e10cSrcweir     * </ul>
311*cdf0e10cSrcweir     */
312*cdf0e10cSrcweir     public void _setLongFormat() {
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         boolean result = true ;
315*cdf0e10cSrcweir         oObj.setLongFormat(!longFormat) ;
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir         result = oObj.isLongFormat() == !longFormat ;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir         if (!result) {
320*cdf0e10cSrcweir             log.println("Was '" + longFormat + "', set to '" + !longFormat +
321*cdf0e10cSrcweir                 "' but returned '" + oObj.isLongFormat() + "'") ;
322*cdf0e10cSrcweir         }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir         tRes.tested("setLongFormat()", result) ;
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir     /**
328*cdf0e10cSrcweir     * Gets long format state and stores it. <p>
329*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured.
330*cdf0e10cSrcweir     */
331*cdf0e10cSrcweir     public void _isLongFormat() {
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         boolean result = true ;
334*cdf0e10cSrcweir         longFormat = oObj.isLongFormat() ;
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         tRes.tested("isLongFormat()", result) ;
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 
341