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