xref: /AOO41X/main/qadevOOo/tests/java/ifc/awt/_XTimeField.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.XTimeField;
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir /**
36*cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XTimeField</code>
37*cdf0e10cSrcweir * interface methods :
38*cdf0e10cSrcweir * <ul>
39*cdf0e10cSrcweir *  <li><code> setTime()</code></li>
40*cdf0e10cSrcweir *  <li><code> getTime()</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> setEmpty()</code></li>
50*cdf0e10cSrcweir *  <li><code> isEmpty()</code></li>
51*cdf0e10cSrcweir *  <li><code> setStrictFormat()</code></li>
52*cdf0e10cSrcweir *  <li><code> isStrictFormat()</code></li>
53*cdf0e10cSrcweir * </ul> <p>
54*cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
55*cdf0e10cSrcweir * @see com.sun.star.awt.XTimeField
56*cdf0e10cSrcweir */
57*cdf0e10cSrcweir public class _XTimeField extends MultiMethodTest {
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     public XTimeField oObj = null;
60*cdf0e10cSrcweir     private boolean strict = false ;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     /**
63*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
64*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
65*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
66*cdf0e10cSrcweir     * <ul>
67*cdf0e10cSrcweir     *  <li> <code> getTime </code> </li>
68*cdf0e10cSrcweir     * </ul>
69*cdf0e10cSrcweir     */
70*cdf0e10cSrcweir     public void _setTime() {
71*cdf0e10cSrcweir         requiredMethod("getTime()") ;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir         boolean result = true ;
74*cdf0e10cSrcweir         oObj.setTime(11150000) ;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         result = oObj.getTime() == 11150000 ;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         if (! result ) {
79*cdf0e10cSrcweir             System.out.println("Getting "+oObj.getTime()+ " expected 11150000");
80*cdf0e10cSrcweir         }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir         tRes.tested("setTime()", result) ;
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     /**
86*cdf0e10cSrcweir     * Gets the current value. <p>
87*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
88*cdf0e10cSrcweir     */
89*cdf0e10cSrcweir     public void _getTime() {
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         boolean result = true ;
92*cdf0e10cSrcweir         oObj.getTime() ;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         tRes.tested("getTime()", result) ;
95*cdf0e10cSrcweir     }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     /**
98*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
99*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
100*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
101*cdf0e10cSrcweir     * <ul>
102*cdf0e10cSrcweir     *  <li> <code> getMin </code> </li>
103*cdf0e10cSrcweir     * </ul>
104*cdf0e10cSrcweir     */
105*cdf0e10cSrcweir     public void _setMin() {
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir         boolean result = true ;
108*cdf0e10cSrcweir         oObj.setMin(4978) ;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         result = oObj.getMin() == 4978 ;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir         tRes.tested("setMin()", result) ;
113*cdf0e10cSrcweir     }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     /**
116*cdf0e10cSrcweir     * Gets the current value. <p>
117*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
118*cdf0e10cSrcweir     */
119*cdf0e10cSrcweir     public void _getMin() {
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir         boolean result = true ;
122*cdf0e10cSrcweir         oObj.getMin() ;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         tRes.tested("getMin()", result) ;
125*cdf0e10cSrcweir     }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     /**
128*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
129*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
130*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
131*cdf0e10cSrcweir     * <ul>
132*cdf0e10cSrcweir     *  <li> <code> getMax </code> </li>
133*cdf0e10cSrcweir     * </ul>
134*cdf0e10cSrcweir     */
135*cdf0e10cSrcweir     public void _setMax() {
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         boolean result = true ;
138*cdf0e10cSrcweir         oObj.setMax(27856) ;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         result = oObj.getMax() == 27856 ;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         tRes.tested("setMax()", result) ;
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     /**
146*cdf0e10cSrcweir     * Gets the current value. <p>
147*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
148*cdf0e10cSrcweir     */
149*cdf0e10cSrcweir     public void _getMax() {
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir         boolean result = true ;
152*cdf0e10cSrcweir         oObj.getMax() ;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         tRes.tested("getMax()", result) ;
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     /**
158*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
159*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
160*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
161*cdf0e10cSrcweir     * <ul>
162*cdf0e10cSrcweir     *  <li> <code> getFirst </code> </li>
163*cdf0e10cSrcweir     * </ul>
164*cdf0e10cSrcweir     */
165*cdf0e10cSrcweir     public void _setFirst() {
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir         boolean result = true ;
168*cdf0e10cSrcweir         oObj.setFirst(5118) ;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         result = oObj.getFirst() == 5118 ;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         if (!result) {
173*cdf0e10cSrcweir             log.println("Set to " + 5118 + " but returned " + oObj.getFirst()) ;
174*cdf0e10cSrcweir         }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         tRes.tested("setFirst()", result) ;
177*cdf0e10cSrcweir     }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     /**
180*cdf0e10cSrcweir     * Gets the current value. <p>
181*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
182*cdf0e10cSrcweir     */
183*cdf0e10cSrcweir     public void _getFirst() {
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         boolean result = true ;
186*cdf0e10cSrcweir         int val = oObj.getFirst() ;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir         log.println("getFirst() = " + val) ;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         tRes.tested("getFirst()", result) ;
191*cdf0e10cSrcweir     }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     /**
194*cdf0e10cSrcweir     * Sets a new value and checks if it was correctly set. <p>
195*cdf0e10cSrcweir     * Has <b> OK </b> status if set and get values are equal.
196*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
197*cdf0e10cSrcweir     * <ul>
198*cdf0e10cSrcweir     *  <li> <code> getLast </code> </li>
199*cdf0e10cSrcweir     * </ul>
200*cdf0e10cSrcweir     */
201*cdf0e10cSrcweir     public void _setLast() {
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir         boolean result = true ;
204*cdf0e10cSrcweir         oObj.setLast(23450) ;
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         result = oObj.getLast() == 23450 ;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir         if (!result) {
209*cdf0e10cSrcweir             log.println("Set to " + 23450 + " but returned " + oObj.getLast()) ;
210*cdf0e10cSrcweir         }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         tRes.tested("setLast()", result) ;
213*cdf0e10cSrcweir     }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir     /**
216*cdf0e10cSrcweir     * Gets the current value. <p>
217*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
218*cdf0e10cSrcweir     */
219*cdf0e10cSrcweir     public void _getLast() {
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir         boolean result = true ;
222*cdf0e10cSrcweir         int val = oObj.getLast() ;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir         log.println("getLast() = " + val) ;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir         tRes.tested("getLast()", result) ;
227*cdf0e10cSrcweir     }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     /**
230*cdf0e10cSrcweir     * Sets the value to empty. <p>
231*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
232*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
233*cdf0e10cSrcweir     * <ul>
234*cdf0e10cSrcweir     *  <li> <code> setTime </code> : value must be not empty </li>
235*cdf0e10cSrcweir     * </ul>
236*cdf0e10cSrcweir     */
237*cdf0e10cSrcweir     public void _setEmpty() {
238*cdf0e10cSrcweir         requiredMethod("setTime()") ;
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir         boolean result = true ;
241*cdf0e10cSrcweir         oObj.setEmpty() ;
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir         tRes.tested("setEmpty()", result) ;
244*cdf0e10cSrcweir     }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     /**
247*cdf0e10cSrcweir     * Checks if the field is empty. <p>
248*cdf0e10cSrcweir     * Has <b> OK </b> status if the value is empty.<p>
249*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
250*cdf0e10cSrcweir     * <ul>
251*cdf0e10cSrcweir     *  <li> <code> setEmpty() </code>  </li>
252*cdf0e10cSrcweir     * </ul>
253*cdf0e10cSrcweir     */
254*cdf0e10cSrcweir     public void _isEmpty() {
255*cdf0e10cSrcweir         requiredMethod("setEmpty()") ;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir         boolean result = true ;
258*cdf0e10cSrcweir         result = oObj.isEmpty() ;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         tRes.tested("isEmpty()", result) ;
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     /**
264*cdf0e10cSrcweir     * Checks strict state. <p>
265*cdf0e10cSrcweir     * Has <b> OK </b> status if strict format is set.
266*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
267*cdf0e10cSrcweir     * <ul>
268*cdf0e10cSrcweir     *  <li> <code> isStrictFormat </code> </li>
269*cdf0e10cSrcweir     * </ul>
270*cdf0e10cSrcweir     */
271*cdf0e10cSrcweir     public void _setStrictFormat() {
272*cdf0e10cSrcweir         requiredMethod("isStrictFormat()") ;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         boolean result = true ;
275*cdf0e10cSrcweir         oObj.setStrictFormat(!strict) ;
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir         result = oObj.isStrictFormat() == !strict ;
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir         tRes.tested("setStrictFormat()", result) ;
280*cdf0e10cSrcweir     }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     /**
283*cdf0e10cSrcweir     * Gets strict state and stores it. <p>
284*cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured.
285*cdf0e10cSrcweir     */
286*cdf0e10cSrcweir     public void _isStrictFormat() {
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir         boolean result = true ;
289*cdf0e10cSrcweir         strict = oObj.isStrictFormat() ;
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         tRes.tested("isStrictFormat()", result) ;
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 
296